Revision 29001 branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/objects/DwgPolyline3D.java
DwgPolyline3D.java | ||
---|---|---|
39 | 39 |
import java.util.List; |
40 | 40 |
import java.util.Map; |
41 | 41 |
|
42 |
|
|
43 | 42 |
import org.gvsig.dwg.lib.DwgFile; |
44 | 43 |
import org.gvsig.dwg.lib.DwgHandleReference; |
45 | 44 |
import org.gvsig.dwg.lib.DwgObject; |
... | ... | |
48 | 47 |
import org.gvsig.dwg.lib.IDwgBlockMember; |
49 | 48 |
import org.gvsig.dwg.lib.IDwgPolyline; |
50 | 49 |
import org.gvsig.dwg.lib.IDwgVertex; |
50 |
import org.gvsig.dwg.lib.util.FMapUtil; |
|
51 | 51 |
import org.gvsig.fmap.geom.Geometry; |
52 |
import org.gvsig.fmap.geom.GeometryFactory; |
|
53 |
import org.gvsig.fmap.geom.GeometryManager; |
|
54 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
52 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
55 | 53 |
import org.slf4j.Logger; |
56 | 54 |
import org.slf4j.LoggerFactory; |
57 | 55 |
|
... | ... | |
248 | 246 |
DwgObject obj = dwgFile.getDwgObject(i); |
249 | 247 |
if(obj instanceof DwgVertex3D){ |
250 | 248 |
DwgVertex3D vertex = (DwgVertex3D) obj; |
251 |
pt = ((DwgVertex3D)vertex).getPoint();
|
|
249 |
pt = (vertex).getPoint(); |
|
252 | 250 |
pts.add(new double[]{pt[0], pt[1], pt[2]}); |
253 | 251 |
}else if(obj instanceof DwgSeqend){ |
254 | 252 |
//TODO En Polyline2D J.Morell no interrumpia el barrido, |
... | ... | |
340 | 338 |
public boolean has3DData() { |
341 | 339 |
|
342 | 340 |
List pts = getPts(); |
343 |
if(pts == null) |
|
341 |
if(pts == null) {
|
|
344 | 342 |
return false; |
343 |
} |
|
345 | 344 |
double z = 0d; |
346 | 345 |
for (int j = 0; j<pts.size(); j++) { |
347 | 346 |
z = ((double[])pts.get(j))[2]; |
348 |
if (z != 0.0) |
|
347 |
if (z != 0.0) {
|
|
349 | 348 |
return true; |
349 |
} |
|
350 | 350 |
} |
351 | 351 |
return false; |
352 | 352 |
|
... | ... | |
366 | 366 |
break; |
367 | 367 |
} |
368 | 368 |
} |
369 |
if (constantElevation) |
|
369 |
if (constantElevation) {
|
|
370 | 370 |
return firstPt[2]; |
371 |
} |
|
371 | 372 |
} |
372 | 373 |
return 0d; |
373 | 374 |
} |
... | ... | |
388 | 389 |
/* (non-Javadoc) |
389 | 390 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean) |
390 | 391 |
*/ |
391 |
public Geometry toFMapGeometry(boolean is3DFile) { |
|
392 |
GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory(); |
|
393 |
List vertices = getPts(); |
|
394 |
|
|
395 |
if (vertices != null){ |
|
396 |
GeneralPathX gp = new GeneralPathX(); |
|
397 |
for (int i = 0; i < vertices.size(); i++) { |
|
398 |
Object vertice = vertices.get(i); |
|
399 |
if(i==0){ |
|
400 |
if(vertice instanceof double[]){ |
|
401 |
gp.moveTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
402 |
} else if (vertice instanceof Point2D){ |
|
403 |
gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
404 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
405 |
} |
|
406 |
} else { |
|
407 |
if(vertice instanceof double[]){ |
|
408 |
gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
409 |
} else if (vertice instanceof Point2D){ |
|
410 |
gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
411 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
if (is3DFile) { |
|
416 |
return gFactory.createPolyline3D(gp,getPZ()); |
|
417 |
} else { |
|
418 |
return gFactory.createPolyline2D(gp); |
|
419 |
} |
|
420 |
} else { |
|
421 |
return null; |
|
422 |
} |
|
392 |
public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException { |
|
393 |
return FMapUtil.ptsToMultiCurve(getPts(), getGeometrySubType(is3DFile)); |
|
423 | 394 |
} |
424 | 395 |
// public Geometry toFMapGeometry_old(boolean is3DFile) { |
425 | 396 |
// FPolyline2D pline = null; |
... | ... | |
446 | 417 |
* @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean) |
447 | 418 |
*/ |
448 | 419 |
public String toFMapString(boolean is3DFile) { |
449 |
if(is3DFile) |
|
420 |
if(is3DFile) {
|
|
450 | 421 |
return "FPolyline3D"; |
451 |
else
|
|
422 |
} else {
|
|
452 | 423 |
return "FPolyline2D"; |
424 |
} |
|
453 | 425 |
} |
454 | 426 |
|
455 | 427 |
public String toString(){ |
... | ... | |
528 | 500 |
this.vertexHandles.add(handle); |
529 | 501 |
} |
530 | 502 |
|
503 |
public int getGeometrySubType(boolean is3DFile) { |
|
504 |
return Geometry.SUBTYPES.GEOM3D; |
|
505 |
} |
|
531 | 506 |
|
507 |
public int getGeometryType() { |
|
508 |
return Geometry.TYPES.MULTICURVE; |
|
509 |
} |
|
532 | 510 |
|
511 |
|
|
512 |
|
|
533 | 513 |
} |
Also available in: Unified diff