aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-12 06:17:07 +0100
committerSven Göthel <[email protected]>2024-02-12 06:17:07 +0100
commita77b487a44124a9e55fa9a53d1f9c3ae20b9c3ba (patch)
treebb9271e933b09bfaa92253bc76e8295f56174041 /src/jogl/classes/jogamp
parentbf882af1675f390500cc36c5396f75c394372d52 (diff)
Bug 1501: Graph Delaunay: Use default winding outer-boundary:=CCW and inner-hole:=CW w/o using winding determination (might be incorrect)
This simplifies our code further and it has been validated that our polygon shoelace-algo for area >= 0 ? CCW doesn't produce correct results with all curves. Hence rely on given winding depending on outer-boundary and inner-hole if CDTriangulator2D.FixedWindingRule == true (default and fixed). This also removes the more costly winding shoelace calculus, hence Outline ctor only sets dirtyWinding:=true w/o calculating the winding.
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java33
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java14
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);