Revision 29001 branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/objects/DwgLwPolyline.java
DwgLwPolyline.java | ||
---|---|---|
51 | 51 |
import org.gvsig.dwg.lib.util.FMapUtil; |
52 | 52 |
import org.gvsig.dwg.lib.util.GisModelCurveCalculator; |
53 | 53 |
import org.gvsig.fmap.geom.Geometry; |
54 |
import org.gvsig.fmap.geom.GeometryFactory; |
|
55 |
import org.gvsig.fmap.geom.GeometryManager; |
|
56 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
57 |
import org.gvsig.fmap.geom.primitive.NullGeometry; |
|
54 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
58 | 55 |
|
59 | 56 |
|
60 | 57 |
/** |
... | ... | |
219 | 216 |
* @see com.iver.cit.jdwglib.dwg.IDwgPolyline#calculateGisModel(java.util.List) |
220 | 217 |
*/ |
221 | 218 |
public void calculateGisModel(DwgFile dwgFile) { |
222 |
if (getVertices() == null) |
|
219 |
if (getVertices() == null) {
|
|
223 | 220 |
return; |
221 |
} |
|
224 | 222 |
int flags = getFlag(); |
225 | 223 |
List pts = getVertices(); |
226 | 224 |
double[] bulges = getBulges(); |
... | ... | |
234 | 232 |
newBulges = new double[bulges.length]; |
235 | 233 |
//dwg spec says numVertex (numSegments + 1) |
236 | 234 |
//TODO Check this |
237 |
for(int i = 0; i < newBulges.length; i++) |
|
235 |
for(int i = 0; i < newBulges.length; i++) {
|
|
238 | 236 |
bulges[i] = 0d; |
237 |
} |
|
239 | 238 |
newBulges = new double[bulges.length]; |
240 | 239 |
System.arraycopy(bulges, 0, newBulges, 0, bulges.length); |
241 | 240 |
} |
... | ... | |
273 | 272 |
* @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion() |
274 | 273 |
*/ |
275 | 274 |
public void applyExtrussion() { |
276 |
if (getVertices() == null) |
|
275 |
if (getVertices() == null) {
|
|
277 | 276 |
return; |
277 |
} |
|
278 | 278 |
List vertices = getVertices(); |
279 | 279 |
double[] lwPolylineExt = getNormal(); |
280 | 280 |
// Normals and Extrusions aren`t the same |
281 |
if (lwPolylineExt[0]==0 && lwPolylineExt[1]==0 && lwPolylineExt[2]==0) |
|
282 |
lwPolylineExt[2] = 1.0; |
|
281 |
if (lwPolylineExt[0]==0 && lwPolylineExt[1]==0 && lwPolylineExt[2]==0) { |
|
282 |
lwPolylineExt[2] = 1.0; |
|
283 |
} |
|
283 | 284 |
|
284 | 285 |
double elev = getElevation(); |
285 | 286 |
List lwPolylinePoints3D = new ArrayList(); |
... | ... | |
308 | 309 |
public double getZ() { |
309 | 310 |
return getElevation(); |
310 | 311 |
} |
311 |
public Geometry toFMapGeometry(boolean is3DFile) { |
|
312 |
int index = this.getIndex(); |
|
313 |
GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory(); |
|
314 |
List vertices = getVertices(); |
|
315 |
double elev = getElevation(); |
|
316 | 312 |
|
317 |
if (vertices != null && vertices.size()>0){ |
|
318 |
GeneralPathX gp = new GeneralPathX(); |
|
319 |
Object vertice = vertices.get(0); |
|
320 |
if(vertice instanceof double[]){ |
|
321 |
gp.moveTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
322 |
} else if (vertice instanceof Point2D){ |
|
323 |
gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
324 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
325 |
} |
|
326 |
for (int i = 1; i < vertices.size(); i++) { |
|
327 |
vertice = vertices.get(i); |
|
328 |
if(vertice instanceof double[]){ |
|
329 |
gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue()); |
|
330 |
} else if (vertice instanceof Point2D){ |
|
331 |
gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(), |
|
332 |
new Double(((Point2D)vertice).getY()).floatValue()); |
|
333 |
} |
|
334 |
} |
|
335 |
if (is3DFile) { |
|
336 |
return gFactory.createPolyline3D(gp,new double[] {elev}); |
|
337 |
} else { |
|
338 |
return gFactory.createPolyline2D(gp); |
|
339 |
} |
|
340 |
} else { |
|
341 |
return new NullGeometry(); |
|
342 |
} |
|
313 |
public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException { |
|
314 |
return FMapUtil.ptsToMultiCurve(getVertices(), |
|
315 |
getGeometrySubType(is3DFile)); |
|
343 | 316 |
} |
317 |
|
|
344 | 318 |
public String toFMapString(boolean is3DFile) { |
345 |
if(is3DFile) |
|
319 |
if(is3DFile) {
|
|
346 | 320 |
return "FPolyline3D"; |
347 |
else
|
|
321 |
} else {
|
|
348 | 322 |
return "FPolyline2D"; |
323 |
} |
|
349 | 324 |
} |
350 | 325 |
|
351 | 326 |
public String toString(){ |
... | ... | |
411 | 386 |
|
412 | 387 |
} |
413 | 388 |
|
389 |
public int getGeometrySubType(boolean is3DFile) { |
|
390 |
if (is3DFile) { |
|
391 |
return Geometry.SUBTYPES.GEOM3D; |
|
392 |
} else { |
|
393 |
return Geometry.SUBTYPES.GEOM2D; |
|
394 |
} |
|
395 |
} |
|
396 |
|
|
397 |
public int getGeometryType() { |
|
398 |
return Geometry.TYPES.MULTICURVE; |
|
399 |
} |
|
400 |
|
|
414 | 401 |
} |
Also available in: Unified diff