Revision 2770 trunk/extensions/extDwg/src/es/iver/gvsig/drivers/dwg/DwgMemoryDriver.java

View differences:

DwgMemoryDriver.java
164 164
		System.out.println("Tiempo empleado por la librer?a en tratar el fichero dwg = " + (t2-t1));
165 165
		dwgObjects = dwg.getDwgObjects();
166 166
		dwg.testDwg3D();
167
		dwg.blockManagement();
167 168
		
168 169
		// TODO: Atributos extra de los objectos
169 170
		//int nAtt = featureMaker.getAttributes().size();
......
192 193
    	
193 194
		t1 = System.currentTimeMillis();
194 195
		
195
    	boolean addingToBlock = false;
196
    	//boolean addingToBlock = false;
196 197
    	
197 198
		for (int i=0;i<dwgObjects.size();i++) {
198 199
			
......
201 202
            auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue();
202 203
			
203 204
			DwgObject entity = (DwgObject)dwgObjects.get(i);
204
			if (entity instanceof DwgArc && !addingToBlock) {
205
			if (entity instanceof DwgArc) {// && !addingToBlock) {
205 206
				//System.out.println("Encuentra un Arc ...");
206 207
				double[] c = ((DwgArc)entity).getCenter();
207 208
				Point2D center = new Point2D.Double(c[0], c[1]);
......
244 245
                	}
245 246
            	}*/
246 247
				addShape(arcc, auxRow);
247
			} else if (entity instanceof DwgEllipse && !addingToBlock) {
248
			} else if (entity instanceof DwgEllipse) {// && !addingToBlock) {
248 249
				//System.out.println("Encuentra una Ellipse ...");
249 250
				double[] c = ((DwgEllipse)entity).getCenter();
250 251
				Point2D center = new Point2D.Double(c[0], c[1]);
......
289 290
                	}
290 291
            	}*/
291 292
				addShape(arcc, auxRow);
292
			} else if (entity instanceof DwgCircle && !addingToBlock) {
293
			} else if (entity instanceof DwgCircle) {// && !addingToBlock) {
293 294
				//System.out.println("Encuentra un Circle ...");
294 295
				double[] c = ((DwgCircle)entity).getCenter();
295 296
				Point2D center = new Point2D.Double(c[0], c[1]);
......
330 331
                	}
331 332
            	}*/
332 333
				addShape(arcc, auxRow);
333
			} else if (entity instanceof DwgPolyline2D && !addingToBlock) {
334
			} else if (entity instanceof DwgPolyline2D) {// && !addingToBlock) {
334 335
				//System.out.println("Encuentra una Polyline2D ...");
335 336
				Point2D[] points = ((DwgPolyline2D)entity).getPts();
336 337
				double elev = ((DwgPolyline2D)entity).getElevation();
......
371 372
	            	}*/
372 373
	            	addShape(pline, auxRow);
373 374
				}
374
			} else if (entity instanceof DwgPolyline3D && !addingToBlock) {
375
			} else if (entity instanceof DwgPolyline3D) {// && !addingToBlock) {
375 376
				//System.out.println("Encuentra una Polyline3D ...");
376 377
				double[][] points3D = ((DwgPolyline3D)entity).getPts();
377 378
				FPolyline2D pline; 
......
418 419
	            	}*/
419 420
	            	addShape(pline, auxRow);
420 421
				}
421
			} else if (entity instanceof DwgLwPolyline && !addingToBlock) {
422
			} else if (entity instanceof DwgLwPolyline) {// && !addingToBlock) {
422 423
				//System.out.println("Encuentra una Lwpolyline ...");
423 424
				Point2D[] pts = ((DwgLwPolyline)entity).getVertices();
424 425
				double elev = ((DwgLwPolyline)entity).getElevation();
......
459 460
	            	}*/
460 461
					addShape(lwpline, auxRow);
461 462
				}
462
			} else if (entity instanceof DwgSolid && !addingToBlock) {
463
			} else if (entity instanceof DwgSolid) {// && !addingToBlock) {
463 464
				//System.out.println("Encuentra un Solid ...");
464 465
				double[] p1 = ((DwgSolid)entity).getCorner1();
465 466
				double[] p2 = ((DwgSolid)entity).getCorner2();
......
502 503
                	}
503 504
            	}*/
504 505
				addShape(solid, auxRow);
505
			} else if (entity instanceof DwgLine && !addingToBlock) {
506
			} else if (entity instanceof DwgLine) {// && !addingToBlock) {
506 507
				//System.out.println("Encuentra una Line ...");
507 508
				double[] p1 = ((DwgLine)entity).getP1();
508 509
				Point2D point1 = new Point2D.Double(p1[0], p1[1]);
......
560 561
                	}
561 562
            	}*/
562 563
				addShape(line, auxRow);
563
			} else if (entity instanceof DwgPoint && !addingToBlock) {
564
			} else if (entity instanceof DwgPoint) {// && !addingToBlock) {
564 565
				//System.out.println("Encuentra un Point ...");
565 566
				double[] p = ((DwgPoint)entity).getPoint();
566 567
				FPoint2D point;
......
592 593
                	}
593 594
            	}*/
594 595
				addShape(point, auxRow);
595
			} else if (entity instanceof DwgInsert && !addingToBlock) {
596
			} else if (entity instanceof DwgInsert) {// && !addingToBlock) {
596 597
				//System.out.println("Encuentra un Insert ...");
597 598
				double[] p = ((DwgInsert)entity).getInsertionPoint();
598 599
				Point2D point = new Point2D.Double(p[0], p[1]);
599 600
				FPoint2D fPoint;
600
				double[] scale = ((DwgInsert)entity).getScale();
601
				/*double[] scale = ((DwgInsert)entity).getScale();
601 602
				double rot = ((DwgInsert)entity).getRotation();
602
				int blockHandle = ((DwgInsert)entity).getBlockHeaderHandle();
603
				manageInsert(dwgObjects, point, scale, rot, blockHandle, i, auxRow);
603
				int blockHandle = ((DwgInsert)entity).getBlockHeaderHandle();*/
604
				//manageInsert(dwgObjects, point, scale, rot, blockHandle, i, auxRow);
604 605
				if (dwg.isDwg3DFile()) {
605 606
				    fPoint = new FPoint3D(p[0], p[1], p[2]);
606 607
	                auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String("FPoint3D"));
......
629 630
                	}
630 631
            	}*/
631 632
				addShape(fPoint, auxRow);
632
			} else if (entity instanceof DwgMText && !addingToBlock) {
633
			} else if (entity instanceof DwgMText) {//) && !addingToBlock) {
633 634
				//System.out.println("Encuentra un MText ...");
634 635
				double[] p = ((DwgMText)entity).getInsertionPoint();
635 636
				FPoint2D fPoint;
......
661 662
                	}
662 663
            	}*/
663 664
				addShape(fPoint, auxRow);
664
			} else if (entity instanceof DwgAttrib && !addingToBlock) {
665
			} else if (entity instanceof DwgAttrib) {// && !addingToBlock) {
665 666
				//System.out.println("Encuentra un Attrib ...");
666
			} else if (entity instanceof DwgText && !addingToBlock) {
667
			} else if (entity instanceof DwgText) {// && !addingToBlock) {
667 668
				//System.out.println("Encuentra un Text ...");
668 669
				Point2D p = ((DwgText)entity).getInsertionPoint();
669 670
				int dflag = ((DwgText)entity).getDataFlag();
......
711 712
				addShape(point, auxRow);
712 713
			} else if (entity instanceof DwgBlock) {
713 714
				//System.out.println("Encuentra un Block ...");
714
				addingToBlock = true;
715
				//addingToBlock = true;
715 716
				String blockName = ((DwgBlock)entity).getName();
716 717
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
717 718
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block"));
......
736 737
				//addShape(point, auxRow);
737 738
			} else if (entity instanceof DwgEndblk) {
738 739
				//System.out.println("Encuentra un Endblk ...");
739
				addingToBlock = false;
740
				//addingToBlock = false;
740 741
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
741 742
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("EndBlk"));
742 743
				String layerName = dwg.getLayerName(entity);
......
783 784
				//addShape(point, auxRow);
784 785
			} else if (entity instanceof DwgBlockHeader) {
785 786
				//System.out.println("Encuentra un Block Header ...");
786
				addingToBlock = true;
787
				//addingToBlock = true;
787 788
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
788 789
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Header"));
789 790
				String layerName = dwg.getLayerName(entity);
......
805 806
                	}
806 807
            	}*/
807 808
				//addShape(point, auxRow);
808
			} else if (entity instanceof DwgAttdef && !addingToBlock) {
809
			} else if (entity instanceof DwgAttdef) {// && !addingToBlock) {
809 810
				//System.out.println("Encuentra un Attdef ...");
810 811
			} else {
811 812
				//System.out.println("Detectado dwgObject pendiente de implementar");
......
934 935
		return new FPolygon2D(genPathX);
935 936
	}
936 937
	
937
	private void manageInsert(Vector dwgObjects, Point2D insPoint, double[] scale, double rot, int bHandle, int id, Value[] auxRow) {
938
	/*private void manageInsert(Vector dwgObjects, Point2D insPoint, double[] scale, double rot, int bHandle, int id, Value[] auxRow) {
938 939
	    for (int i=0;i<dwgObjects.size();i++) {
939 940
			DwgObject obj = (DwgObject)dwgObjects.get(i);
940 941
			if (obj instanceof DwgBlockHeader) {
......
983 984
				}
984 985
			}
985 986
		}
986
	}
987
	}*/
987 988
	
988
	private void manageBlockEntity(DwgObject entity, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, int id, Value[] auxRow) {
989
	/*private void manageBlockEntity(DwgObject entity, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, int id, Value[] auxRow) {
989 990
		if (entity instanceof DwgArc) {
990 991
			//System.out.println("Encuentra un arco dentro de un bloque ...");
991 992
			double[] c = ((DwgArc)entity).getCenter();
......
1024 1025
			if (color==256) color = colorByLayer;
1025 1026
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1026 1027
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(c[2]);
1027
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1028
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1028 1029
        	// Attributes
1029 1030
        	//for (int j=0;j<nAtt;j++) {
1030 1031
			//	String[] attributes = new String[2];
......
1034 1035
            //		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1035 1036
            //	}
1036 1037
        	//}
1037
			addShape(arcc, auxRow);
1038
			/*addShape(arcc, auxRow);
1038 1039
		} else if (entity instanceof DwgCircle) {
1039 1040
			//System.out.println("Encuentra un c?rculo dentro de un bloque ...");
1040 1041
			double[] c = ((DwgCircle)entity).getCenter();
......
1070 1071
			if (color==256) color = colorByLayer;
1071 1072
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1072 1073
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(c[2]);
1073
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1074
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1074 1075
        	// Attributes
1075 1076
        	/*for (int j=0;j<nAtt;j++) {
1076 1077
				String[] attributes = new String[2];
......
1080 1081
            		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1081 1082
            	}
1082 1083
        	}*/
1083
			addShape(arcc, auxRow);
1084
			/*addShape(arcc, auxRow);
1084 1085
		} else if (entity instanceof DwgEllipse) {
1085 1086
			double[] center = ((DwgEllipse)entity).getCenter();
1086 1087
			double[] majorAxisVector = ((DwgEllipse)entity).getMajorAxisVector();
......
1118 1119
			if (color==256) color = colorByLayer;
1119 1120
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1120 1121
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(center[2]);
1121
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1122
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1122 1123
        	// Attributes
1123 1124
        	//for (int j=0;j<nAtt;j++) {
1124 1125
			//	String[] attributes = new String[2];
......
1128 1129
            //		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1129 1130
            //	}
1130 1131
        	//}
1131
			addShape(arcc, auxRow);
1132
			/*addShape(arcc, auxRow);
1132 1133
		} else if (entity instanceof DwgLine) {
1133 1134
			//System.out.println("Encuentra una l?nea dentro de un bloque ...");
1134 1135
			double[] p1 = ((DwgLine)entity).getP1();
......
1182 1183
        	} else {
1183 1184
            	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(0.0);
1184 1185
        	}
1185
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1186
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1186 1187
        	// Attributes
1187 1188
        	/*for (int j=0;j<nAtt;j++) {
1188 1189
				String[] attributes = new String[2];
......
1192 1193
            		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1193 1194
            	}
1194 1195
        	}*/
1195
			addShape(line, auxRow);
1196
			/*addShape(line, auxRow);
1196 1197
		} else if (entity instanceof DwgLwPolyline) {
1197 1198
            //System.out.println("Encuentra una DwgLwPolyline dentro de un bloque ...");
1198 1199
			Point2D[] points = ((DwgLwPolyline)entity).getVertices();
......
1229 1230
				if (color==256) color = colorByLayer;
1230 1231
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1231 1232
            	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(elev);
1232
            	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1233
            	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1233 1234
            	// Attributes
1234 1235
            	/*for (int j=0;j<nAtt;j++) {
1235 1236
    				String[] attributes = new String[2];
......
1239 1240
                		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1240 1241
                	}
1241 1242
            	}*/
1242
            	addShape(pline, auxRow);
1243
            	/*addShape(pline, auxRow);
1243 1244
			}
1244 1245
		} else if (entity instanceof DwgMText) {
1245 1246
			
......
1281 1282
				if (color==256) color = colorByLayer;
1282 1283
                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1283 1284
            	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(elev);
1284
            	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1285
            	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1285 1286
            	// Attributes
1286 1287
            	/*for (int j=0;j<nAtt;j++) {
1287 1288
    				String[] attributes = new String[2];
......
1291 1292
                		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1292 1293
                	}
1293 1294
            	}*/
1294
            	addShape(pline, auxRow);
1295
            	/*addShape(pline, auxRow);
1295 1296
			}
1296 1297
		} else if (entity instanceof DwgPolyline3D) {
1297 1298
			
......
1342 1343
			if (color==256) color = colorByLayer;
1343 1344
            auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(color);
1344 1345
        	auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(elev);
1345
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);
1346
        	auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(0.0);*/
1346 1347
        	// Attributes
1347 1348
        	/*for (int j=0;j<nAtt;j++) {
1348 1349
				String[] attributes = new String[2];
......
1352 1353
            		auxRow[9+j] = ValueFactory.createValue(new String(fea.getProp(attributes[0])));
1353 1354
            	}
1354 1355
        	}*/
1355
			addShape(solid, auxRow);
1356
			/*addShape(solid, auxRow);
1356 1357
		} else if (entity instanceof DwgSpline) {
1357 1358
			
1358 1359
		} else if (entity instanceof DwgText) {
......
1369 1370
			double laY = insPoint.getY() + ((pointAux.getX()*scale[0])*Math.sin(rot) + (pointAux.getY()*scale[1])*Math.cos(rot));
1370 1371
			Point2D newInsPoint = new Point2D.Double(laX, laY);
1371 1372
			newScale = new double[]{scale[0]*newScale[0], scale[1]*newScale[1], scale[2]*newScale[2]};
1372
			manageInsert(dwgObjects, newInsPoint, newScale, newRot, newBlockHandle, id, auxRow);
1373
			manageInsert(dwgObjects, newInsPoint, newScale, newRot, newBlockHandle, id, auxRow);*/
1373 1374
			/*auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1374 1375
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
1375 1376
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String("layer"));
......
1387 1388
        	}*/
1388 1389
        	/*FPoint2D fPoint = createPoint(newInsPoint);
1389 1390
			addShape(fPoint, auxRow);*/
1390
		}
1391
	}
1391
		//}
1392
	//}
1392 1393
	
1393 1394
	/* (non-Javadoc)
1394 1395
	 * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)

Also available in: Unified diff