Revision 3188
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/DxfFile.java | ||
---|---|---|
64 | 64 |
|
65 | 65 |
EntityFactory entityMaker = null; |
66 | 66 |
VarSettings headerManager; |
67 |
private boolean dxf3DFlag; |
|
67 | 68 |
|
68 | 69 |
/** |
69 | 70 |
* Crea los objetos en el Modelo correspondiente. |
... | ... | |
276 | 277 |
* @return |
277 | 278 |
*/ |
278 | 279 |
public DxfHeaderVariables getDxfHeaderVars(); |
279 |
|
|
280 |
public boolean isWritedDxf3D(); |
|
281 |
public void loadMinZFromHeader(double d); |
|
282 |
public void loadMaxZFromHeader(double d); |
|
280 | 283 |
}; |
281 | 284 |
|
282 | 285 |
/** |
... | ... | |
500 | 503 |
if (lastVariable.compareTo("$ACADVER") == 0) { |
501 | 504 |
//System.out.println("Aqui llega."); |
502 | 505 |
headerManager.setAcadVersion(v); |
503 |
} else if (lastVariable.compareTo("ENDSEC") == 0) { |
|
504 |
//System.out.println("Llega al ENDSEC."); |
|
505 |
break; |
|
506 |
} else if (lastVariable.compareTo("$EXTMIN") == 0) { |
|
507 |
headerManager.loadMinZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue()); |
|
508 |
} else if (lastVariable.compareTo("$EXTMAX") == 0) { |
|
509 |
headerManager.loadMaxZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue()); |
|
510 |
} else if (lastVariable.compareTo("ENDSEC") == 0) { |
|
511 |
//System.out.println("Llega al ENDSEC."); |
|
512 |
break; |
|
506 | 513 |
} /*else |
507 | 514 |
System.err.println("Dxf: Variable "+lastVariable+" desconocida.");*/ |
508 | 515 |
} |
... | ... | |
735 | 742 |
fw.write(DxfGroup.toString(9, "$EXTMIN")); |
736 | 743 |
fw.write(DxfGroup.toString(10, extent.minX(), 6)); |
737 | 744 |
fw.write(DxfGroup.toString(20, extent.minY(), 6)); |
738 |
fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
745 |
if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.minX(), 6)); |
|
746 |
else fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
739 | 747 |
fw.write(DxfGroup.toString(9, "$EXTMAX")); |
740 | 748 |
fw.write(DxfGroup.toString(10, extent.maxX(), 6)); |
741 | 749 |
fw.write(DxfGroup.toString(20, extent.maxY(), 6)); |
742 |
fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
750 |
if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.maxX(), 6)); |
|
751 |
else fw.write(DxfGroup.toString(30, 0.0, 6)); |
|
743 | 752 |
fw.write(DxfGroup.toString(9, "$LIMMIN")); |
744 | 753 |
fw.write(DxfGroup.toString(10, extent.minX(), 6)); |
745 | 754 |
fw.write(DxfGroup.toString(20, extent.minY(), 6)); |
... | ... | |
1648 | 1657 |
public void setCadFlag(boolean cadFlag) { |
1649 | 1658 |
this.cadFlag = cadFlag; |
1650 | 1659 |
} |
1660 |
|
|
1661 |
/** |
|
1662 |
* @return Returns the dxf3DFlag. |
|
1663 |
*/ |
|
1664 |
public boolean isDxf3DFlag() { |
|
1665 |
return dxf3DFlag; |
|
1666 |
} |
|
1667 |
|
|
1668 |
/** |
|
1669 |
* @param dxf3DFlag The dxf3DFlag to set. |
|
1670 |
*/ |
|
1671 |
public void setDxf3DFlag(boolean dxf3DFlag) { |
|
1672 |
this.dxf3DFlag = dxf3DFlag; |
|
1673 |
} |
|
1651 | 1674 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfFeatureMaker.java | ||
---|---|---|
882 | 882 |
Feature feaBordes = new Feature(); |
883 | 883 |
Feature feaFondos = new Feature(); |
884 | 884 |
int flags = 0; |
885 |
int NumberOfVertices = 0; |
|
885 |
//int NumberOfVertices = 0;
|
|
886 | 886 |
double extx = 0.0; |
887 | 887 |
double exty = 0.0; |
888 | 888 |
double extz = 1.0; |
... | ... | |
891 | 891 |
feaBordes.setProp("dxfEntity", "LwPolyline"); |
892 | 892 |
feaFondos.setProp("dxfEntity", "LwPolyline"); |
893 | 893 |
|
894 |
if (grp.hasCode(8)) { |
|
894 |
//if (grp.hasCode(8)) {
|
|
895 | 895 |
//feature.setProp("layer", grp.getDataAsString(8)); |
896 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
|
897 |
} |
|
896 |
// feaBordes.setProp("layer", grp.getDataAsString(8));
|
|
897 |
//}
|
|
898 | 898 |
|
899 |
feaBordes.setProp("layer", grp.getDataAsString(8)); |
|
899 | 900 |
feaFondos.setProp("layer", grp.getDataAsString(8)); |
900 | 901 |
|
901 | 902 |
if (grp.hasCode(38)) { |
... | ... | |
971 | 972 |
isDoubleFeatured = false; |
972 | 973 |
} |
973 | 974 |
|
974 |
if (grp.hasCode(90)) { |
|
975 |
NumberOfVertices = grp.getDataAsInt(90); |
|
976 |
} |
|
975 |
//if (grp.hasCode(90)) {
|
|
976 |
// NumberOfVertices = grp.getDataAsInt(90);
|
|
977 |
//}
|
|
977 | 978 |
|
978 | 979 |
if (grp.hasCode(210)) { |
979 | 980 |
extx = grp.getDataAsDouble(210); |
... | ... | |
1093 | 1094 |
|
1094 | 1095 |
x = 0.0; |
1095 | 1096 |
y = 0.0; |
1096 |
} else if (g.getCode() == 42) {
|
|
1097 |
} else if (g.getCode() == 42 && ((Double)g.getData()).doubleValue()!=0.0) { // Cuando los bulges eran 0.000 se provocaban errores
|
|
1097 | 1098 |
//System.out.println("createLwPolyline: Lee el bulgeLwp"); |
1098 | 1099 |
hasBulge = true; |
1099 | 1100 |
bulgeLwp = ((Double) g.getData()).doubleValue(); |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfHeaderVariables.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.cresques.px.dxf; |
25 | 25 |
|
26 |
import org.cresques.io.DxfGroupVector; |
|
26 | 27 |
|
28 |
|
|
27 | 29 |
/** |
28 | 30 |
* Definici?n de las variables que definen un DXF. Estas variables est?n |
29 | 31 |
* establecidas en la secci?n HEADER del propio fichero DXF. |
... | ... | |
33 | 35 |
public class DxfHeaderVariables { |
34 | 36 |
private String acadVersion; |
35 | 37 |
private String acadMaintVer; |
38 |
private boolean writedDxf3D; |
|
39 |
private double minZFromHeader; |
|
40 |
private double maxZFromHeader; |
|
36 | 41 |
|
37 | 42 |
/** |
38 | 43 |
* Constructor de DxfHeaderVariables. |
... | ... | |
80 | 85 |
return new String("Unknown codedVersion"); |
81 | 86 |
} |
82 | 87 |
} |
88 |
|
|
89 |
public boolean isWritedDxf3D() { |
|
90 |
// si los ext son como los escribimos devolver true |
|
91 |
writedDxf3D = false; |
|
92 |
double z1 = minZFromHeader; |
|
93 |
double z2 = maxZFromHeader; |
|
94 |
if (z1==999999999.0 && z2==-999999999.0) writedDxf3D = true; |
|
95 |
return writedDxf3D; |
|
96 |
} |
|
97 |
|
|
98 |
public void loadMinZFromHeader(double d) { |
|
99 |
minZFromHeader = d; |
|
100 |
} |
|
101 |
|
|
102 |
public void loadMaxZFromHeader(double d) { |
|
103 |
maxZFromHeader = d; |
|
104 |
} |
|
83 | 105 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfHeaderManager.java | ||
---|---|---|
67 | 67 |
public String getAcadVersion() { |
68 | 68 |
return dxfHeadVars.getAcadVersion(); |
69 | 69 |
} |
70 |
|
|
71 |
public boolean isWritedDxf3D() { |
|
72 |
return dxfHeadVars.isWritedDxf3D(); |
|
73 |
} |
|
74 |
|
|
75 |
public void loadMinZFromHeader(double d) { |
|
76 |
dxfHeadVars.loadMinZFromHeader(d); |
|
77 |
} |
|
78 |
|
|
79 |
public void loadMaxZFromHeader(double d) { |
|
80 |
dxfHeadVars.loadMaxZFromHeader(d); |
|
81 |
} |
|
70 | 82 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfPolyline.java | ||
---|---|---|
26 | 26 |
import org.cresques.cts.ICoordTrans; |
27 | 27 |
import org.cresques.cts.IProjection; |
28 | 28 |
|
29 |
import org.cresques.geo.Point3D; |
|
29 | 30 |
import org.cresques.geo.ViewPortData; |
30 | 31 |
|
31 | 32 |
import org.cresques.io.DxfGroup; |
... | ... | |
56 | 57 |
boolean hasFaces = false; |
57 | 58 |
private Vector bulges; |
58 | 59 |
private Color color = baseColor; //Color(255,214,132,255); |
60 |
private double elevation; |
|
61 |
private String subclassMarker; |
|
59 | 62 |
|
60 | 63 |
/** |
61 | 64 |
* Constructor de DxfPolyline. |
... | ... | |
250 | 253 |
sb = new StringBuffer(DxfGroup.toString(0, "POLYLINE")); |
251 | 254 |
sb.append(DxfGroup.toString(5, getHandle())); |
252 | 255 |
sb.append(DxfGroup.toString(100, "AcDbEntity")); |
256 |
sb.append(DxfGroup.toString(100, getSubclassMarker())); |
|
253 | 257 |
sb.append(DxfGroup.toString(8, layer.getName())); |
254 | 258 |
sb.append(DxfGroup.toString(62, dxfColor)); |
255 |
sb.append(DxfGroup.toString(100, "AcDb2dPolyline")); |
|
256 | 259 |
sb.append(DxfGroup.toString(70, flags)); |
257 | 260 |
sb.append(DxfGroup.toString(66, 1)); |
258 | 261 |
|
259 |
Point2D pt = null;
|
|
262 |
Point3D pt = null;
|
|
260 | 263 |
Iterator iter = pts.iterator(); |
261 | 264 |
System.out.println("pts.size() = " + pts.size()); |
262 | 265 |
|
266 |
int i=1; |
|
263 | 267 |
while (iter.hasNext()) { |
264 |
pt = (Point2D) iter.next();
|
|
268 |
pt = (Point3D) iter.next();
|
|
265 | 269 |
sb.append(DxfGroup.toString(0, "VERTEX")); |
266 |
sb.append(DxfGroup.toString(5, getHandle())); |
|
270 |
sb.append(DxfGroup.toString(5, getHandle()+i));
|
|
267 | 271 |
sb.append(DxfGroup.toString(100, "AcDbEntity")); |
268 | 272 |
sb.append(DxfGroup.toString(8, layer.getName())); |
269 | 273 |
sb.append(DxfGroup.toString(100, "AcDbVertex")); |
270 |
sb.append(DxfGroup.toString(100, "AcDb2dVertex")); |
|
274 |
sb.append(DxfGroup.toString(100, "AcDb3dPolylineVertex")); |
|
275 |
sb.append(DxfGroup.toString(70, 32)); |
|
271 | 276 |
sb.append(DxfGroup.toString(10, pt.getX(), 6)); |
272 | 277 |
sb.append(DxfGroup.toString(20, pt.getY(), 6)); |
273 |
sb.append(DxfGroup.toString(30, 0.0, 6)); |
|
278 |
sb.append(DxfGroup.toString(30, pt.getZ(), 6)); |
|
279 |
i++; |
|
274 | 280 |
} |
275 | 281 |
|
276 | 282 |
sb.append(DxfGroup.toString(0, "SEQEND")); |
277 |
sb.append(DxfGroup.toString(5, getHandle())); |
|
283 |
sb.append(DxfGroup.toString(5, getHandle()+i));
|
|
278 | 284 |
sb.append(DxfGroup.toString(100, "AcDbEntity")); |
279 | 285 |
sb.append(DxfGroup.toString(8, layer.getName())); |
280 | 286 |
|
... | ... | |
338 | 344 |
public void setBulges(Vector bulges) { |
339 | 345 |
this.bulges = bulges; |
340 | 346 |
} |
347 |
|
|
348 |
/** |
|
349 |
* @return Returns the elevation. |
|
350 |
*/ |
|
351 |
public double getElevation() { |
|
352 |
return elevation; |
|
353 |
} |
|
354 |
|
|
355 |
/** |
|
356 |
* @param elevation The elevation to set. |
|
357 |
*/ |
|
358 |
public void setElevation(double elevation) { |
|
359 |
this.elevation = elevation; |
|
360 |
} |
|
361 |
|
|
362 |
/** |
|
363 |
* @return Returns the subclassMarker. |
|
364 |
*/ |
|
365 |
public String getSubclassMarker() { |
|
366 |
return subclassMarker; |
|
367 |
} |
|
368 |
|
|
369 |
/** |
|
370 |
* @param subclassMarker The subclassMarker to set. |
|
371 |
*/ |
|
372 |
public void setSubclassMarker(String subclassMarker) { |
|
373 |
this.subclassMarker = subclassMarker; |
|
374 |
} |
|
341 | 375 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfEntityMaker.java | ||
---|---|---|
153 | 153 |
entity.setHandle(entities.size() + 40); |
154 | 154 |
} |
155 | 155 |
|
156 |
if (grp.hasCode(100)) { |
|
157 |
entity.setSubclassMarker(grp.getDataAsString(100)); |
|
158 |
} |
|
159 |
|
|
156 | 160 |
double x = 0.0; |
157 | 161 |
double y = 0.0; |
158 | 162 |
double z = 0.0; |
... | ... | |
168 | 172 |
|
169 | 173 |
if (grp.hasCode(30)) { |
170 | 174 |
z = grp.getDataAsDouble(30); |
175 |
entity.setElevation(z); |
|
171 | 176 |
} |
172 | 177 |
|
173 | 178 |
/*if (grp.hasCode(39)) |
... | ... | |
353 | 358 |
|
354 | 359 |
Point3D point_in = new Point3D(x, y, z); |
355 | 360 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ); |
356 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
361 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
357 | 362 |
|
358 | 363 |
if (((flags & 0x80) == 0x80) && ((flags & 0x40) == 0)) { |
359 | 364 |
int[] face = { 0, 0, 0, 0 }; |
... | ... | |
365 | 370 |
} else { |
366 | 371 |
x = point_out.getX(); |
367 | 372 |
y = point_out.getY(); |
373 |
z = point_out.getZ(); |
|
368 | 374 |
|
369 |
Point2D pt = proj.createPoint(x, y); |
|
375 |
Point2D ptaux = proj.createPoint(x, y); |
|
376 |
Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z); |
|
370 | 377 |
((DxfPolyline) lastEntity).add(pt); |
371 | 378 |
|
372 | 379 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
... | ... | |
384 | 391 |
|
385 | 392 |
Point3D point_in = new Point3D(x, y, z); |
386 | 393 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ); |
387 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
394 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
388 | 395 |
x = point_out.getX(); |
389 | 396 |
y = point_out.getY(); |
397 |
z = point_out.getZ(); |
|
390 | 398 |
|
391 |
Point2D pt = proj.createPoint(x, y); |
|
399 |
Point2D ptaux = proj.createPoint(x, y); |
|
400 |
Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z); |
|
392 | 401 |
((DxfPolyline) lastEntity).add(pt); |
393 | 402 |
|
394 | 403 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
... | ... | |
411 | 420 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1); |
412 | 421 |
|
413 | 422 |
for (int i = 0; i < arc.size(); i++) { |
414 |
pt = proj.createPoint(((Point2D) arc.get(i)).getX(), |
|
423 |
ptaux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
|
415 | 424 |
((Point2D) arc.get(i)).getY()); |
425 |
pt = new Point3D(ptaux.getX(), ptaux.getY(), z); |
|
416 | 426 |
((DxfPolyline) lastEntity).add(pt); |
417 | 427 |
|
418 | 428 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
... | ... | |
434 | 444 |
|
435 | 445 |
Point3D point_in = new Point3D(x, y, z); |
436 | 446 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ); |
437 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
447 |
Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
|
|
438 | 448 |
x = point_out.getX(); |
439 | 449 |
y = point_out.getY(); |
450 |
z = point_out.getZ(); |
|
440 | 451 |
|
441 |
Point2D pt = proj.createPoint(x, y); |
|
452 |
Point2D ptaux = proj.createPoint(x, y); |
|
453 |
Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z); |
|
442 | 454 |
((DxfPolyline) lastEntity).add(pt); |
443 | 455 |
|
444 | 456 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
... | ... | |
461 | 473 |
((DxfPolyline) lastEntity).pts.remove(cnt - 1); |
462 | 474 |
|
463 | 475 |
for (int i = arc.size() - 1; i >= 0; i--) { |
464 |
pt = proj.createPoint(((Point2D) arc.get(i)).getX(), |
|
476 |
ptaux = proj.createPoint(((Point2D) arc.get(i)).getX(),
|
|
465 | 477 |
((Point2D) arc.get(i)).getY()); |
478 |
pt = new Point3D(ptaux.getX(), ptaux.getY(), z); |
|
466 | 479 |
((DxfPolyline) lastEntity).add(pt); |
467 | 480 |
|
468 | 481 |
if (((DxfPolyline) lastEntity).pts.size() == 1) { |
... | ... | |
496 | 509 |
double exty = 0.0; |
497 | 510 |
double extz = 1.0; |
498 | 511 |
|
512 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
|
513 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer); |
|
514 |
|
|
499 | 515 |
if (grp.hasCode(38)) { |
500 |
elev = grp.getDataAsDouble(38);
|
|
516 |
entity.setElevation(grp.getDataAsDouble(38));
|
|
501 | 517 |
} |
502 | 518 |
|
503 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
|
504 |
DxfLwPolyline entity = new DxfLwPolyline(proj, layer); |
|
505 |
|
|
506 | 519 |
if (grp.hasCode(5)) { |
507 | 520 |
String hexS = grp.getDataAsString(5); |
508 | 521 |
Integer hexI = Integer.decode("0x" + hexS); |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfLwPolyline.java | ||
---|---|---|
67 | 67 |
sb.append(DxfGroup.toString(100, "AcDbPolyline")); |
68 | 68 |
sb.append(DxfGroup.toString(90, pts.size())); |
69 | 69 |
sb.append(DxfGroup.toString(70, flags)); |
70 |
sb.append(DxfGroup.toString(38, new Double(getElevation()))); |
|
70 | 71 |
|
71 | 72 |
Point2D pt = null; |
72 | 73 |
double bulge; |
Also available in: Unified diff