diff options
author | Sven Gothel <[email protected]> | 2011-05-10 23:54:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-05-10 23:54:39 +0200 |
commit | f5ec2dd42244282c2a005269ae4674ab78af269a (patch) | |
tree | 09e97a3f63a48eba51225181110067824bbf95a0 /src | |
parent | 9ceff75afcbf6c446e75c1be6b4be1e62d543f3a (diff) |
Graph: getWinding(ArrayList<Vertex> vertices) test; minor renaming
Diffstat (limited to 'src')
4 files changed, 10 insertions, 6 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java index 55bdbcd33..e0d7d3236 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -94,7 +94,7 @@ public class CDTriangulator2D { else { GraphOutline outline = new GraphOutline(polyline); GraphOutline innerPoly = extractBoundaryTriangles(outline, true); - vertices.addAll(innerPoly.getPoints()); + vertices.addAll(innerPoly.getVertices()); loop.addConstraintCurve(innerPoly); } } @@ -140,7 +140,7 @@ public class CDTriangulator2D { return triangles; } - private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole){ + private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole) { GraphOutline innerOutline = new GraphOutline(); ArrayList<GraphVertex> outVertices = outline.getGraphPoint(); int size = outVertices.size(); diff --git a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java index aae7a8c5c..b91969745 100755 --- a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java @@ -310,7 +310,7 @@ public class VectorUtil { /** Computes the area of a list of vertices to check if ccw
* @param vertices
- * @return positve area if ccw else negative area value
+ * @return positive area if ccw else negative area value
*/
public static float area(ArrayList<Vertex> vertices) {
int n = vertices.size();
@@ -323,4 +323,7 @@ public class VectorUtil { }
return area;
}
+ public static Winding getWinding(ArrayList<Vertex> vertices) {
+ return area(vertices) >= 0 ? Winding.CCW : Winding.CW ;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java index a0d1923a9..d1245f4b8 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java @@ -65,7 +65,7 @@ public class GraphOutline { return controlpoints; } - public ArrayList<Vertex> getPoints() { + public ArrayList<Vertex> getVertices() { return outline.getVertices(); } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index 230bdad0e..acccea503 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -102,6 +102,7 @@ public class Loop { if(vertices.size()<3) { throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size()); } + //final VectorUtil.Winding hasWinding = VectorUtil.getWinding(outline.getVertices()); final VectorUtil.Winding hasWinding = VectorUtil.getWinding( vertices.get(0).getPoint(), vertices.get(1).getPoint(), @@ -110,9 +111,9 @@ public class Loop { // skips inversion CW -> CCW ? final boolean invert = hasWinding != reqWinding && reqWinding == VectorUtil.Winding.CW; - /*if( hasWinding != reqWinding ) { + if( hasWinding != reqWinding ) { System.err.println("Winding: i "+invert+" "+hasWinding+" -> "+reqWinding); - }*/ + } final int max; final int edgeType = reqWinding == VectorUtil.Winding.CCW ? HEdge.BOUNDARY : HEdge.HOLE ; |