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