Revision 1883 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dwg/DwgMemoryDriver.java

View differences:

DwgMemoryDriver.java
180 180
				double endAngle = Math.toDegrees(((Double)data.getValue()).doubleValue());
181 181
				Point2D[] arc = createArc(center, radius, startAngle, endAngle);
182 182
				FPolyline2D arcc = createPolyline3D(arc);
183
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
183
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
184 184
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc"));
185 185
				//int[] layerHandle = (int[])entity.getLayer();
186 186
				String layerName = getLayerName(entity, layerTable);
......
210 210
				data = entity.getDwgObjectSpecificDataItem("RADIUS");
211 211
				double radius = ((Double)data.getValue()).doubleValue();
212 212
				FPolyline2D circle = createCircle(center, radius);
213
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
213
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
214 214
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle"));
215 215
				//int[] layerHandle = (int[])entity.getLayer();
216 216
				String layerName = getLayerName(entity, layerTable);
......
241 241
				coord = (double[])data.getValue();
242 242
				Point2D p2 = new Point2D.Double(coord[0], coord[1]);
243 243
				FPolyline2D line = createLine(p1, p2);
244
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
244
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
245 245
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line"));
246 246
				//int[] layerHandle = (int[])entity.getLayer();
247 247
				String layerName = getLayerName(entity, layerTable);
......
269 269
				double[] coord = (double[])data.getValue();
270 270
				Point2D p = new Point2D.Double(coord[0], coord[1]);
271 271
				FPoint2D point = createPoint(p);
272
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
272
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
273 273
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Point"));
274 274
				//int[] layerHandle = (int[])entity.getLayer();
275 275
				String layerName = getLayerName(entity, layerTable);
......
363 363
					bulges.add(new Double(0));
364 364
				}
365 365
				FPolyline2D pline = createPolyline2D(newPts, bulges);
366
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
366
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
367 367
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D"));
368 368
				//int[] layerHandle = (int[])entity.getLayer();
369 369
				String layerName = getLayerName(entity, layerTable);
......
423 423
					newPts[pts.length] = pts[0];
424 424
				}
425 425
				FPolyline2D pline3d = createPolyline3D(newPts);
426
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
426
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
427 427
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline3D"));
428 428
				//int[] layerHandle = (int[])entity.getLayer();
429 429
				String layerName = getLayerName(entity, layerTable);
......
450 450
				DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("INSERTION_POINT");
451 451
				Point2D p = (Point2D)data.getValue();
452 452
				FPoint2D point = createPoint(p);
453
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
453
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
454 454
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Text"));
455 455
				//int[] layerHandle = (int[])entity.getLayer();
456 456
				String layerName = getLayerName(entity, layerTable);
......
500 500
				addingToBlock = true;
501 501
				//pto = (Point2D.Double)point.get(0);
502 502
				//FShape nuevoShp;
503
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
503
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
504 504
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block"));
505 505
				//int[] layerHandle = (int[])entity.getLayer();
506 506
				String layerName = getLayerName(entity, layerTable);
......
527 527
				addingToBlock = false;
528 528
				//pto = (Point2D.Double)point.get(0);
529 529
				//FShape nuevoShp;
530
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
530
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
531 531
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("EndBlk"));
532 532
				//int[] layerHandle = (int[])entity.getLayer();
533 533
				String layerName = getLayerName(entity, layerTable);
......
554 554
				//addingToBlock = false;
555 555
				//pto = (Point2D.Double)point.get(0);
556 556
				//FShape nuevoShp;
557
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
557
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
558 558
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Control Object"));
559 559
				//int[] layerHandle = (int[])entity.getLayer();
560 560
				String layerName = getLayerName(entity, layerTable);
......
581 581
				addingToBlock = true;
582 582
				//pto = (Point2D.Double)point.get(0);
583 583
				//FShape nuevoShp;
584
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
584
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
585 585
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Block Header"));
586 586
				//int[] layerHandle = (int[])entity.getLayer();
587 587
				String layerName = getLayerName(entity, layerTable);
......
615 615
				data = entity.getDwgObjectSpecificDataItem("BLOCK_HEADER_HANDLE");
616 616
				int[] blockHandle = (int[])data.getValue();
617 617
				
618
				manageInsert(dwgObjects, layerTable, point, scale, rot, blockHandle, auxRow);
618
				manageInsert(dwgObjects, layerTable, point, scale, rot, blockHandle, i, auxRow);
619 619
				
620
				auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
620
				auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
621 621
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Insert"));
622 622
				//int[] layerHandle = (int[])entity.getLayer();
623 623
				String layerName = getLayerName(entity, layerTable);
......
646 646
				double[] coord = (double[])data.getValue();
647 647
				Point2D p = new Point2D.Double(coord[0], coord[1]);
648 648
				FPoint2D point = createPoint(p);
649
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
649
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
650 650
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("MText"));
651 651
				//int[] layerHandle = (int[])entity.getLayer();
652 652
				String layerName = getLayerName(entity, layerTable);
......
683 683
				coord = (double[])data.getValue();
684 684
				Point2D p4 = new Point2D.Double(coord[0], coord[1]);
685 685
				FPolygon2D solid = createSolid(new Point2D[]{p1, p2, p4, p3});
686
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
686
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
687 687
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Solid"));
688 688
				//int[] layerHandle = (int[])entity.getLayer();
689 689
				String layerName = getLayerName(entity, layerTable);
......
722 722
					 pts[j] = new Point2D.Double(pt[0], pt[1]);
723 723
				}
724 724
				FPolyline2D spline = createLwPolyline(pts);
725
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
725
                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
726 726
                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Spline"));
727 727
				//int[] layerHandle = (int[])entity.getLayer();
728 728
				String layerName = getLayerName(entity, layerTable);
......
763 763
						 pts[j] = new Point2D.Double(pt[0], pt[1]);
764 764
					}
765 765
					FPolyline2D lwpline = createLwPolyline(pts);
766
	                auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
766
	                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
767 767
	                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("LwPolyline"));
768 768
					//int[] layerHandle = (int[])entity.getLayer();
769 769
					String layerName = getLayerName(entity, layerTable);
......
1023 1023
		}
1024 1024
	}
1025 1025
	
1026
	private void manageInsert(Vector dwgObjects, Vector layerTable, Point2D insPoint, double[] scale, double rot, int[] blockHandle, Value[] auxRow) {
1026
	private void manageInsert(Vector dwgObjects, Vector layerTable, Point2D insPoint, double[] scale, double rot, int[] blockHandle, int id, Value[] auxRow) {
1027 1027
		byte[] blockHandleBytes = new byte[]{0,0,0,0};
1028 1028
		if (blockHandle.length>2) blockHandleBytes[3] = (byte)blockHandle[2];
1029 1029
		if (blockHandle.length>3) blockHandleBytes[2] = (byte)blockHandle[3];
......
1114 1114
								if (blockEntityHandle.size()>4) blockEntityHandleBytes[1] = ((Integer)blockEntityHandle.get(4)).byteValue();
1115 1115
								if (blockEntityHandle.size()>5) blockEntityHandleBytes[0] = ((Integer)blockEntityHandle.get(5)).byteValue();
1116 1116
								int bEntityHandle = ByteUtils.bytesToInt(blockEntityHandleBytes, new int[]{0});
1117
								manageBlockEntity(blockEntity, layerTable, bPoint, insPoint, scale, rot, block, auxRow);
1117
								manageBlockEntity(blockEntity, layerTable, bPoint, insPoint, scale, rot, block, id, auxRow);
1118 1118
								l++;
1119 1119
								if (bEntityHandle==lastHandle && ((Integer)entHandle.get(1)).intValue()==lastEntityHandle[1]) {
1120 1120
									break;
......
1127 1127
		}
1128 1128
	}
1129 1129
	
1130
	private void manageBlockEntity(DwgObject entity, Vector layerTable, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, Value[] auxRow) {
1130
	private void manageBlockEntity(DwgObject entity, Vector layerTable, double[] bPoint, Point2D insPoint, double[] scale, double rot, DwgObject block, int id, Value[] auxRow) {
1131 1131
		if (entity.getType()==0x11) {
1132 1132
			System.out.println("Encuentra un arco dentro de un bloque ...");
1133 1133
			DwgObjectSpecificDataItem data = entity.getDwgObjectSpecificDataItem("CENTER");
......
1148 1148
				arc[i] = new Point2D.Double(laX, laY);
1149 1149
			}
1150 1150
			FPolyline2D arcc = createPolyline3D(arc);
1151
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1151
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(id);
1152 1152
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Arc"));
1153 1153
			String layerName = getLayerName(block, layerTable);
1154 1154
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
......
1186 1186
			radius = radius * scale[0];
1187 1187
			
1188 1188
			FPolyline2D circle = createCircle(center, radius);
1189
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1189
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(id);
1190 1190
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Circle"));
1191 1191
			String layerName = getLayerName(block, layerTable);
1192 1192
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
......
1227 1227
			p2 = new Point2D.Double(laX, laY);
1228 1228
			
1229 1229
			FPolyline2D line = createLine(p1, p2);
1230
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1230
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(id);
1231 1231
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Line"));
1232 1232
			String layerName = getLayerName(block, layerTable);
1233
			System.out.println("layerName = " + layerName);
1233 1234
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
1234 1235
			int color = entity.getColor();
1235 1236
			int colorByLayer = getColorByLayer(entity, layerTable);
......
1268 1269
			
1269 1270
			newScale = new double[]{scale[0]*newScale[0], scale[1]*newScale[1], scale[2]*newScale[2]};
1270 1271
			
1271
			manageInsert(dwgObjects, layerTable, newInsPoint, newScale, newRot, newBlockHandle, auxRow);
1272
			manageInsert(dwgObjects, layerTable, newInsPoint, newScale, newRot, newBlockHandle, id, auxRow);
1272 1273
			
1273 1274
			/*auxRow[ID_FIELD_ID] = ValueFactory.createValue(0);
1274 1275
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("dxfEntity"));
......
1367 1368
			}
1368 1369
			
1369 1370
			FPolyline2D pline = createPolyline2D(newPts, bulges);
1370
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(handleBinToHandleInt(entity.getHandle()));
1371
            auxRow[ID_FIELD_ID] = ValueFactory.createValue(id);
1371 1372
            auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String("Polyline2D"));
1372 1373
			String layerName = getLayerName(block, layerTable);
1373 1374
            auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(layerName);
......
1442 1443
			if (layerHandleVect.size()>4) layerHandleBytes[1] = (byte)((Integer)layerHandleVect.get(4)).intValue();
1443 1444
			if (layerHandleVect.size()>5) layerHandleBytes[0] = (byte)((Integer)layerHandleVect.get(5)).intValue();
1444 1445
			int lHandle = ByteUtils.bytesToInt(layerHandleBytes, new int[]{0});
1445
			/*int[] layerControlHandle = (int[])layerTableRecord.get(3);
1446
			byte[] layerControlBytes = new byte[]{0,0,0,0};
1447
			if (layerControlHandle.length>2) layerControlBytes[3] = (byte)layerControlHandle[2];
1448
			if (layerControlHandle.length>3) layerControlBytes[2] = (byte)layerControlHandle[3];
1449
			if (layerControlHandle.length>4) layerControlBytes[1] = (byte)layerControlHandle[4];
1450
			if (layerControlHandle.length>5) layerControlBytes[0] = (byte)layerControlHandle[5];
1451
			int layerControl = ByteUtils.bytesToInt(layerControlBytes, new int[]{0});*/
1452 1446
			System.out.println("lHandle = " + lHandle);
1453 1447
			System.out.println("layer = " + layer);
1454 1448
			if (lHandle==layer) {

Also available in: Unified diff