From 630a9ea52b16da6badb31a98b70893f8d294b4e8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Mar 2011 15:25:18 +0200 Subject: Remove generics notion of Type, since Vertex _is_ the lowest denominator for our implementation and curve API --- src/com/jogamp/graph/curve/OutlineShape.java | 28 ++++----- src/com/jogamp/graph/curve/Region.java | 2 +- .../jogamp/graph/curve/opengl/RegionRenderer.java | 4 +- .../jogamp/graph/curve/tess/CDTriangulator2D.java | 69 +++++++++++----------- 4 files changed, 51 insertions(+), 52 deletions(-) (limited to 'src/com/jogamp/graph/curve') diff --git a/src/com/jogamp/graph/curve/OutlineShape.java b/src/com/jogamp/graph/curve/OutlineShape.java index 9373808f1..2a6e3745f 100755 --- a/src/com/jogamp/graph/curve/OutlineShape.java +++ b/src/com/jogamp/graph/curve/OutlineShape.java @@ -52,13 +52,13 @@ import com.jogamp.graph.curve.tess.CDTriangulator2D; public class OutlineShape { public static final int QUADRATIC_NURBS = 10; private final Vertex.Factory pointFactory; - private ArrayList> outlines = new ArrayList>(3); + private ArrayList outlines = new ArrayList(3); /** Create a new Outline based Shape */ public OutlineShape(Vertex.Factory factory) { pointFactory = factory; - outlines.add(new Outline()); + outlines.add(new Outline()); } public final Vertex.Factory pointFactory() { return pointFactory; } @@ -68,7 +68,7 @@ public class OutlineShape { * be placed at the end of the outline list. */ public void addEmptyOutline(){ - outlines.add(new Outline()); + outlines.add(new Outline()); } /** Adds an outline to the OutlineShape object @@ -77,7 +77,7 @@ public class OutlineShape { * it will do nothing. * @param outline an Outline object */ - public void addOutline(Outline outline){ + public void addOutline(Outline outline){ if(outline.isEmpty()){ return; } @@ -120,7 +120,7 @@ public class OutlineShape { * of outlines that define the shape * @return the last outline */ - public final Outline getLastOutline(){ + public final Outline getLastOutline(){ return outlines.get(outlines.size()-1); } /** Make sure that the outlines represent @@ -135,13 +135,13 @@ public class OutlineShape { } private void transformOutlinesQuadratic(){ - ArrayList> newOutlines = new ArrayList>(3); + ArrayList newOutlines = new ArrayList(3); /**loop over the outlines and make sure no * adj off-curve vertices */ - for(Outline outline:outlines){ - Outline newOutline = new Outline(); + for(Outline outline:outlines){ + Outline newOutline = new Outline(); ArrayList vertices = outline.getVertices(); int size =vertices.size()-1; @@ -165,7 +165,7 @@ public class OutlineShape { private void generateVertexIds(){ int maxVertexId = 0; - for(Outline outline:outlines){ + for(Outline outline:outlines){ ArrayList vertices = outline.getVertices(); for(Vertex vert:vertices){ vert.setId(maxVertexId); @@ -179,7 +179,7 @@ public class OutlineShape { */ public ArrayList getVertices(){ ArrayList vertices = new ArrayList(); - for(Outline polyline:outlines){ + for(Outline polyline:outlines){ vertices.addAll(polyline.getVertices()); } return vertices; @@ -189,21 +189,21 @@ public class OutlineShape { /** Triangluate the graph object * @param sharpness sharpness of the curved regions default = 0.5 */ - public ArrayList> triangulate(float sharpness){ + public ArrayList triangulate(float sharpness){ if(outlines.size() == 0){ return null; } sortOutlines(); generateVertexIds(); - CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness); + CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness); for(int index = 0; index< outlines.size();index++){ - Outline outline = outlines.get(index); + Outline outline = outlines.get(index); triangulator2d.addCurve(outline); } - ArrayList> triangles = triangulator2d.generateTriangulation(); + ArrayList triangles = triangulator2d.generateTriangulation(); triangulator2d.reset(); return triangles; diff --git a/src/com/jogamp/graph/curve/Region.java b/src/com/jogamp/graph/curve/Region.java index f3a87bb7f..143b6f502 100755 --- a/src/com/jogamp/graph/curve/Region.java +++ b/src/com/jogamp/graph/curve/Region.java @@ -80,7 +80,7 @@ public interface Region { * * @see update() */ - public void addTriangles(ArrayList> tris); + public void addTriangles(ArrayList tris); /** Get the current number of vertices associated * with this region. This number is not necessary equal to diff --git a/src/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/com/jogamp/graph/curve/opengl/RegionRenderer.java index 4be1506d5..602399010 100644 --- a/src/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -63,7 +63,7 @@ public abstract class RegionRenderer extends Renderer { outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList> triangles = (ArrayList>) outlineShape.triangulate(sharpness); + ArrayList triangles = (ArrayList) outlineShape.triangulate(sharpness); ArrayList vertices = (ArrayList) outlineShape.getVertices(); region.addVertices(vertices); region.addTriangles(triangles); @@ -84,7 +84,7 @@ public abstract class RegionRenderer extends Renderer { for(OutlineShape outlineShape:outlineShapes){ outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList> triangles = outlineShape.triangulate(sharpness); + ArrayList triangles = outlineShape.triangulate(sharpness); region.addTriangles(triangles); ArrayList vertices = outlineShape.getVertices(); diff --git a/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java index 0a7cf08d4..beef2d4a5 100644 --- a/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -46,15 +46,15 @@ import jogamp.opengl.Debug; * Closed Regions with optional n holes. * */ -public class CDTriangulator2D { +public class CDTriangulator2D { protected static final boolean DEBUG = Debug.debug("Triangulation"); private float sharpness = 0.5f; - private ArrayList> loops; - private ArrayList vertices; + private ArrayList loops; + private ArrayList vertices; - private ArrayList> triangles; + private ArrayList triangles; private int maxTriID = 0; @@ -76,31 +76,31 @@ public class CDTriangulator2D { */ public void reset() { maxTriID = 0; - vertices = new ArrayList(); - triangles = new ArrayList>(3); - loops = new ArrayList>(); + vertices = new ArrayList(); + triangles = new ArrayList(3); + loops = new ArrayList(); } /** Add a curve to the list of profiles provided * @param polyline a bounding Outline */ - public void addCurve(Outline polyline){ - Loop loop = null; + public void addCurve(Outline polyline){ + Loop loop = null; if(!loops.isEmpty()){ loop = getContainerLoop(polyline); } if(loop == null) { - GraphOutline outline = new GraphOutline(polyline); - GraphOutline innerPoly = extractBoundaryTriangles(outline, false); + GraphOutline outline = new GraphOutline(polyline); + GraphOutline innerPoly = extractBoundaryTriangles(outline, false); vertices.addAll(polyline.getVertices()); - loop = new Loop(innerPoly, VectorUtil.CCW); + loop = new Loop(innerPoly, VectorUtil.CCW); loops.add(loop); } else { - GraphOutline outline = new GraphOutline(polyline); - GraphOutline innerPoly = extractBoundaryTriangles(outline, true); + GraphOutline outline = new GraphOutline(polyline); + GraphOutline innerPoly = extractBoundaryTriangles(outline, true); vertices.addAll(innerPoly.getPoints()); loop.addConstraintCurve(innerPoly); } @@ -109,13 +109,13 @@ public class CDTriangulator2D { /** Generate the triangulation of the provided * List of Outlines */ - public ArrayList> generateTriangulation(){ + public ArrayList generateTriangulation(){ for(int i=0;i loop = loops.get(i); + Loop loop = loops.get(i); int numTries = 0; int size = loop.computeLoopSize(); while(!loop.isSimplex()){ - Triangle tri = null; + Triangle tri = null; if(numTries > size){ tri = loop.cut(false); } @@ -140,41 +140,40 @@ public class CDTriangulator2D { break; } } - Triangle tri = loop.cut(true); + Triangle tri = loop.cut(true); if(tri != null) triangles.add(tri); } return triangles; } - @SuppressWarnings("unchecked") - private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole){ - GraphOutline innerOutline = new GraphOutline(); - ArrayList> outVertices = outline.getGraphPoint(); + private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole){ + GraphOutline innerOutline = new GraphOutline(); + ArrayList outVertices = outline.getGraphPoint(); 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; + GraphVertex currentVertex = outVertices.get(i); + GraphVertex gv0 = outVertices.get((i+size-1)%size); + GraphVertex gv2 = outVertices.get((i+1)%size); + GraphVertex gv1 = currentVertex; if(!currentVertex.getPoint().isOnCurve()) { - T v0 = (T) gv0.getPoint().clone(); - T v2 = (T) gv2.getPoint().clone(); - T v1 = (T) gv1.getPoint().clone(); + Vertex v0 = gv0.getPoint().clone(); + Vertex v2 = gv2.getPoint().clone(); + Vertex v1 = gv1.getPoint().clone(); gv0.setBoundaryContained(true); gv1.setBoundaryContained(true); gv2.setBoundaryContained(true); - Triangle t= null; + Triangle t= null; boolean holeLike = false; if(VectorUtil.ccw(v0,v1,v2)){ - t = new Triangle(v0, v1, v2); + t = new Triangle(v0, v1, v2); } else { holeLike = true; - t = new Triangle(v2, v1, v0); + t = new Triangle(v2, v1, v0); } t.setId(maxTriID++); triangles.add(t); @@ -203,10 +202,10 @@ public class CDTriangulator2D { return innerOutline; } - private Loop getContainerLoop(Outline polyline){ - T v = polyline.getVertex(0); + private Loop getContainerLoop(Outline polyline){ + Vertex v = polyline.getVertex(0); - for (Loop loop:loops){ + for (Loop loop:loops){ if(loop.checkInside(v)){ return loop; } -- cgit v1.2.3