From 3dc6b1b9205e3e6e381903f8a1499253f11f64ae Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 1 Mar 2014 17:15:35 +0100 Subject: Bug 801: Cleanup CDTriangulator2D - CDTriangulator2D.getContainerLoop(..) can exit at first 'inside' loop - Make loops field 'final' and clear at reset. - Add more 'final' qualifier --- .../jogamp/graph/curve/tess/CDTriangulator2D.java | 42 ++++++++++------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'src/jogl/classes/jogamp') diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index 0034c8f57..35263407d 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -48,8 +48,7 @@ public class CDTriangulator2D implements Triangulator { protected static final boolean DEBUG = Debug.debug("Triangulation"); - private ArrayList loops; - // FIXME ? private ArrayList vertices; + private final ArrayList loops = new ArrayList(); private int maxTriID = 0; @@ -63,8 +62,7 @@ public class CDTriangulator2D implements Triangulator { @Override public final void reset() { maxTriID = 0; - // vertices = new ArrayList(); - loops = new ArrayList(); + loops.clear(); } @Override @@ -92,7 +90,7 @@ public class CDTriangulator2D implements Triangulator { @Override public final void generate(List sink) { for(int i=0;i sink, final GraphOutline outline, final boolean hole, final float sharpness) { - GraphOutline innerOutline = new GraphOutline(); - ArrayList outVertices = outline.getGraphPoint(); - int size = outVertices.size(); + final GraphOutline innerOutline = new GraphOutline(); + final ArrayList outVertices = outline.getGraphPoint(); + final int size = outVertices.size(); for(int i=0; i < size; i++) { - GraphVertex currentVertex = outVertices.get(i); - GraphVertex gv0 = outVertices.get((i+size-1)%size); - GraphVertex gv2 = outVertices.get((i+1)%size); - GraphVertex gv1 = currentVertex; + final GraphVertex currentVertex = outVertices.get(i); + final GraphVertex gv0 = outVertices.get((i+size-1)%size); + final GraphVertex gv2 = outVertices.get((i+1)%size); + final GraphVertex gv1 = currentVertex; - if(!currentVertex.getPoint().isOnCurve()) { + if( !currentVertex.getPoint().isOnCurve() ) { final Vertex v0 = gv0.getPoint().clone(); final Vertex v2 = gv2.getPoint().clone(); final Vertex v1 = gv1.getPoint().clone(); @@ -171,9 +169,8 @@ public class CDTriangulator2D implements Triangulator { v2.setTexCoord(1, 0.1f); v1.setTexCoord(0.5f, sharpness+0.1f); } - } - else { - if(!gv2.getPoint().isOnCurve() || !gv0.getPoint().isOnCurve()){ + } else { + if( !gv2.getPoint().isOnCurve() || !gv0.getPoint().isOnCurve() ) { currentVertex.setBoundaryContained(true); } innerOutline.addVertex(currentVertex); @@ -183,16 +180,13 @@ public class CDTriangulator2D implements Triangulator { } private Loop getContainerLoop(Outline polyline) { - ArrayList vertices = polyline.getVertices(); + final ArrayList vertices = polyline.getVertices(); for(int i=0; i < loops.size(); i++) { - Loop loop = loops.get(i); - boolean inside = false; + final Loop loop = loops.get(i); for(int j=0; j < vertices.size(); j++) { - Vertex v = vertices.get(j); - inside |= loop.checkInside(v); - } - if(inside) { - return loop; + if( loop.checkInside( vertices.get(j) ) ) { + return loop; + } } } return null; -- cgit v1.2.3