Revision 37855

View differences:

branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/utils/SHPMultiLine.java
315 315
	private void obtainsPoints(Primitive primitive, List arrayPoints, List arrayParts, List arrayZs, boolean is3D){		
316 316
		PathIterator theIterator = primitive.getPathIterator(null, geomManager.getFlatness()); 
317 317
		double[] theData = new double[6];
318
		int numParts = 0;
319 318
		java.awt.geom.Point2D pFirst = null;
320 319
		int pos=0;
321
		
322
		arrayParts.add(new Integer(arrayPoints.size()));
320
				
323 321
		boolean first = true;
324 322
		
325 323
		Double firstZ = null;
......
329 327
				case PathIterator.SEG_MOVETO:
330 328
					if (first) {
331 329
						first = false;
330
						arrayParts.add(new Integer(0));
332 331
					} else {
333 332
						if (m_type==SHP.POLYGON2D ||
334 333
								m_type==SHP.POLYGON3D ||
......
341 340
										arrayZs.add(firstZ);
342 341
									}
343 342
								}
343
								arrayParts.add(new Integer(arrayPoints.size()));
344 344
							} catch (CreateGeometryException e) {
345 345
								logger.error("Error creating a point", e);
346 346
							}
......
348 348
						
349 349
					}
350 350

  
351
					numParts++;
352 351
					pFirst = new java.awt.geom.Point2D.Double(theData[0], theData[1]);
353 352
					try {
354 353
						arrayPoints.add(geomManager.createPoint(theData[0], theData[1], SUBTYPES.GEOM2D));
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/InternalPolygonCADTool.java
24 24
import java.awt.Component;
25 25
import java.awt.event.InputEvent;
26 26
import java.awt.event.MouseEvent;
27
import java.awt.geom.PathIterator;
28 27
import java.util.ArrayList;
29 28
import java.util.List;
30 29

  
......
32 31

  
33 32
import com.vividsolutions.jts.geom.GeometryCollection;
34 33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
35 37
import org.gvsig.andami.PluginServices;
36 38
import org.gvsig.andami.messages.NotificationManager;
37 39
import org.gvsig.editing.CADExtension;
......
48 50
import org.gvsig.fmap.dal.feature.FeatureStore;
49 51
import org.gvsig.fmap.geom.Geometry;
50 52
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
53
import org.gvsig.fmap.geom.aggregate.MultiSurface;
54
import org.gvsig.fmap.geom.operation.GeometryOperationException;
55
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
51 56
import org.gvsig.fmap.geom.primitive.GeneralPathX;
52 57
import org.gvsig.fmap.geom.primitive.Point;
58
import org.gvsig.fmap.geom.primitive.Surface;
53 59
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
54 60
import org.gvsig.tools.dispose.DisposableIterator;
55 61
import org.gvsig.tools.dispose.DisposeUtils;
......
60 66
 * @author Vicente Caballero Navarro
61 67
 */
62 68
public class InternalPolygonCADTool extends DefaultCADTool {
69
    private static final Logger LOG = LoggerFactory
70
        .getLogger(InternalPolygonCADTool.class);
63 71

  
64 72
    protected InternalPolygonCADToolContext _fsm;
65 73
    protected List<Point> points = new ArrayList<Point>();
......
290 298
    public void addValue(double d) {
291 299
    }
292 300

  
293
    private Geometry createNewPolygon(Geometry geometry, List<Point> points) {
294
        GeneralPathX newGp = new GeneralPathX();
295
        double[] theData = new double[6];
296

  
297
        PathIterator theIterator;
298
        int theType;
299
        int numParts = 0;
300

  
301
        theIterator = geometry.getPathIterator(null, geomManager.getFlatness());
302
        while (!theIterator.isDone()) {
303
            theType = theIterator.currentSegment(theData);
304
            switch (theType) {
305

  
306
            case PathIterator.SEG_MOVETO:
307
                numParts++;
308
                newGp.moveTo(theData[0], theData[1]);
309
                break;
310

  
311
            case PathIterator.SEG_LINETO:
312
                newGp.lineTo(theData[0], theData[1]);
313
                break;
314

  
315
            case PathIterator.SEG_QUADTO:
316
                newGp.quadTo(theData[0], theData[1], theData[2], theData[3]);
317
                break;
318

  
319
            case PathIterator.SEG_CUBICTO:
320
                newGp.curveTo(theData[0], theData[1], theData[2], theData[3],
321
                    theData[4], theData[5]);
322
                break;
323

  
324
            case PathIterator.SEG_CLOSE:
325
                newGp.closePath();
326
                break;
327
            } // end switch
328

  
329
            theIterator.next();
330
        } // end while loop
301
    private Geometry createNewPolygon(Geometry geometry, List<Point> points) {        
302
        Geometry newGeometry = geometry.cloneGeometry();
303
                  
331 304
        GeneralPathX gpxInternal = new GeneralPathX();
332 305
        gpxInternal.moveTo(points.get(points.size() - 1));
333 306
        for (int i = points.size() - 2; i >= 0; i--) {
......
338 311
        if (!gpxInternal.isCCW()) {
339 312
            gpxInternal.flip();
340 313
        }
341
        newGp.append(gpxInternal.getPathIterator(null), false);
314
        
315
        if (newGeometry.getGeometryType().isTypeOf(Geometry.TYPES.SURFACE)){
316
            GeneralPathX newGp = newGeometry.getGeneralPath();
317
            newGp.append(gpxInternal.getPathIterator(null), false);
318
        }else if (newGeometry.getGeometryType().isTypeOf(Geometry.TYPES.MULTISURFACE)){
319
            MultiSurface multiSurface = (MultiSurface)newGeometry;
320
            for (int i=0 ; i<multiSurface.getPrimitivesNumber() ; i++){
321
                Surface surcafe = multiSurface.getSurfaceAt(i);
322
                try {
323
                    if (createSurface(gpxInternal).intersects(surcafe)){
324
                        GeneralPathX newGp = surcafe.getGeneralPath();
325
                        newGp.append(gpxInternal.getPathIterator(null), false);
326
                    }
327
                } catch (GeometryOperationNotSupportedException e) {
328
                    LOG.error("Erro calculating the intersection", e);
329
                } catch (GeometryOperationException e) {
330
                    LOG.error("Erro calculating the intersection", e);
331
                }
332
            }
333
        }
342 334

  
343
        return createSurface(newGp);
335
        return newGeometry;
344 336
    }
345 337

  
346 338
    private Geometry createNewPolygonGC(MultiPrimitive multiPrimitive,

Also available in: Unified diff