diff options
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java | 33 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/graph/curve/tess/Loop.java | 14 |
2 files changed, 22 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index d27b7a584..1c2f0b323 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -79,31 +79,24 @@ public class CDTriangulator2D implements Triangulator { } + /* pp */ static final boolean FixedWindingRule = true; + @Override public final void addCurve(final List<Triangle> sink, final Outline polyline, final float sharpness) { Loop loop = getContainerLoop(polyline); - final Winding winding = polyline.getWinding(); if( null == loop ) { // HEdge.BOUNDARY -> Winding.CCW - int edgeType; - boolean hole; - if( Winding.CCW != winding ) { - System.err.println("CDT2.add.xx.BOUNDARY: !CCW but "+winding); - // polyline.print(System.err); - if( false ) { - edgeType = HEdge.HOLE; - hole = true; - } else { - edgeType = HEdge.BOUNDARY; - hole = false; - polyline.setWinding(Winding.CCW); + final int edgeType = HEdge.BOUNDARY; + final boolean hole = false; + if( !FixedWindingRule ) { + final Winding winding = polyline.getWinding(); + if( Winding.CCW != winding ) { + System.err.println("CDT2.add.xx.BOUNDARY: !CCW but "+winding); + // polyline.print(System.err); + polyline.setWinding(Winding.CCW); // FIXME: Too late? } - } else { - edgeType = HEdge.BOUNDARY; - hole = false; } - // Too late: polyline.setWinding(winding); final GraphOutline outline = new GraphOutline(polyline); final GraphOutline innerPoly = extractBoundaryTriangles(sink, outline, hole, sharpness); // vertices.addAll(polyline.getVertices()); @@ -140,12 +133,14 @@ public class CDTriangulator2D implements Triangulator { Thread.dumpStack(); } } else { + final int edgeType = HEdge.HOLE; + final boolean hole = true; // HEdge.HOLE -> Winding.CW, but Winding.CCW is also accepted! // Winding.CW not required, handled in Loop.initFromPolyline(): polyline.setWinding(winding); final GraphOutline outline = new GraphOutline(polyline); - final GraphOutline innerPoly = extractBoundaryTriangles(sink, outline, true, sharpness); + final GraphOutline innerPoly = extractBoundaryTriangles(sink, outline, hole, sharpness); // vertices.addAll(innerPoly.getVertices()); - loop.addConstraintCurve(innerPoly); + loop.addConstraintCurve(innerPoly, edgeType); } } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index d94ab775d..4961ce895 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -122,8 +122,8 @@ public class Loop { } return null; } - final Winding winding = outline.getOutline().getWinding(); final Winding edgeWinding = HEdge.BOUNDARY == edgeType ? Winding.CCW : Winding.CW; + final Winding winding = CDTriangulator2D.FixedWindingRule ? edgeWinding : outline.getOutline().getWinding(); if( HEdge.BOUNDARY == edgeType && Winding.CCW != winding ) { // XXXX @@ -135,7 +135,7 @@ public class Loop { HEdge lastEdge = null; if( winding == edgeWinding || HEdge.BOUNDARY == edgeType ) { - // Correct Winding or skipped CW -> CCW (no inversion possible here, too late ??) + // Correct Winding or skipped CW -> CCW (no inversion possible here, too late) final int max = vertices.size() - 1; for(int index = 0; index <= max; ++index) { final GraphVertex v1 = vertices.get(index); @@ -156,7 +156,7 @@ public class Loop { } lastEdge = edge; } - } else { // if( hasWinding == Winding.CW ) { + } else { // if( winding == Winding.CW ) { // CCW <-> CW for(int index = vertices.size() - 1; index >= 0; --index) { final GraphVertex v1 = vertices.get(index); @@ -182,13 +182,15 @@ public class Loop { return firstEdge; } - public void addConstraintCurve(final GraphOutline polyline) { + public void addConstraintCurve(final GraphOutline polyline, final int edgeType) { // GraphOutline outline = new GraphOutline(polyline); /**needed to generate vertex references.*/ - if( null == initFromPolyline(polyline, HEdge.HOLE) ) { + if( null == initFromPolyline(polyline, edgeType) ) { // 'usually' HEdge.HOLE return; } - addConstraintCurveImpl(polyline); + if( HEdge.HOLE == edgeType ) { + addConstraintCurveImpl(polyline); + } } private void addConstraintCurveImpl(final GraphOutline polyline) { final GraphVertex v3 = locateClosestVertex(polyline); |