Revision 29001 branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/objects/DwgPFacePolyline.java

View differences:

DwgPFacePolyline.java
82 82
import org.gvsig.dwg.lib.IDwgVertex;
83 83
import org.gvsig.dwg.lib.util.FMapUtil;
84 84
import org.gvsig.fmap.geom.Geometry;
85
import org.gvsig.fmap.geom.aggregate.impl.MultiSurface2D;
86
import org.gvsig.fmap.geom.primitive.impl.Surface2D;
85
import org.gvsig.fmap.geom.GeometryLocator;
86
import org.gvsig.fmap.geom.GeometryManager;
87
import org.gvsig.fmap.geom.aggregate.MultiSurface;
88
import org.gvsig.fmap.geom.exception.CreateGeometryException;
87 89
import org.slf4j.Logger;
88 90
import org.slf4j.LoggerFactory;
89 91

  
......
310 312
	}
311 313

  
312 314

  
313
	public Geometry toFMapGeometry(boolean is3DFile) {
314
//		FGeometryCollection solution = null;
315
//		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
315
	public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException {
316
		GeometryManager gMan = GeometryLocator.getGeometryManager();
316 317

  
317
		MultiSurface2D solution = null;
318
		Surface2D[] geometries = null;
318
		int subType = getGeometrySubType(is3DFile);
319
		MultiSurface solution = (MultiSurface) gMan.create(getGeometryType(),
320
				subType);
319 321
		if(vertices != null && faces != null){
320 322
			if(vertices.size() == 0 || faces.size() == 0){
321
				return solution;
323
				return gMan.createNullGeometry(subType);
322 324
			}
323
			ArrayList geomList = new ArrayList();
324 325
			int numFaces = faces.size();
325 326
			for(int i = 0; i < numFaces; i++){
326 327
				DwgVertexPFaceFace face = (DwgVertexPFaceFace) faces.get(i);
......
346 347
	                }
347 348
				}// for j
348 349

  
349
				Geometry geom = FMapUtil.ptsTo3DPolygon(pts);
350
//				Geometry geom = ShapeFactory.createGeometry(polygon);
351
				geomList.add(geom);
350
				solution.addSurface(FMapUtil.ptsToPolygon(pts, subType));
352 351

  
353 352

  
354 353
// if(!lastWasInvisible){
......
361 360
// }
362 361

  
363 362
			}// for i
364
			geometries = new Surface2D[geomList.size()];
365
			geometries = (Surface2D[]) geomList.toArray(geometries);
366
			solution = new MultiSurface2D(null, null, geometries);
367 363
		}
368 364
		return solution;
369 365

  
......
374 370
	 * @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean)
375 371
	 */
376 372
	public String toFMapString(boolean is3DFile) {
377
		if(is3DFile)
373
		if(is3DFile) {
378 374
			return "FPolyline3D";
379
		else
375
		} else {
380 376
			return "FPolyline2D";
377
		}
381 378
	}
382 379

  
383 380
	public String toString(){
......
387 384
	public void addVertex(IDwgVertex vertex) {
388 385
		// here we save the vertex (not the coordinate) because
389 386
		// this Polyline could have two kind of vertex (pface and pfaceface)
390
		if(vertex instanceof DwgVertexPFaceFace)
387
		if(vertex instanceof DwgVertexPFaceFace) {
391 388
			faces.add(vertex);
392
		else
389
		} else {
393 390
			vertices.add(vertex);
391
		}
394 392
	}
395 393

  
396 394
	public void dump(){
......
417 415
		DwgPFacePolyline transformedEntity = null;
418 416
		List vertices = this.getVertices();
419 417
		if (vertices != null) {
420
			if(vertices.size() == 0)
418
			if(vertices.size() == 0) {
421 419
				return;
420
			}
422 421
		    List transformedVertices = new ArrayList();
423 422
			for (int i=0;i < vertices.size();i++) {
424 423
				double[] pointAux = null;
......
443 442
			handle_objectsWithoutBlocks.put(new Integer(transformedEntity.getHandle().getOffset()), transformedEntity);
444 443
		}// if
445 444
	}
445

  
446
	public int getGeometrySubType(boolean is3DFile) {
447
		if (is3DFile) {
448
			return Geometry.SUBTYPES.GEOM3D;
449
		} else {
450
			return Geometry.SUBTYPES.GEOM2D;
451
		}
452
	}
453

  
454
	public int getGeometryType() {
455
		return Geometry.TYPES.MULTISURFACE;
456
	}
457

  
446 458
}
447 459

  

Also available in: Unified diff