diff options
author | Sven Gothel <[email protected]> | 2011-03-30 15:25:18 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-03-30 15:25:18 +0200 |
commit | 630a9ea52b16da6badb31a98b70893f8d294b4e8 (patch) | |
tree | 8ab07c2ff6a670381e2592c09a83bd7cf60a1f2c /src/com/jogamp/graph/curve | |
parent | d06d5596d18101c876c869a514e42e795ee9357c (diff) |
Remove generics notion of Type<Vertex>, since Vertex _is_ the lowest denominator for our implementation and curve API
Diffstat (limited to 'src/com/jogamp/graph/curve')
-rwxr-xr-x | src/com/jogamp/graph/curve/OutlineShape.java | 28 | ||||
-rwxr-xr-x | src/com/jogamp/graph/curve/Region.java | 2 | ||||
-rw-r--r-- | src/com/jogamp/graph/curve/opengl/RegionRenderer.java | 4 | ||||
-rw-r--r-- | src/com/jogamp/graph/curve/tess/CDTriangulator2D.java | 69 |
4 files changed, 51 insertions, 52 deletions
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<? extends Vertex> pointFactory;
- private ArrayList<Outline<Vertex>> outlines = new ArrayList<Outline<Vertex>>(3);
+ private ArrayList<Outline> outlines = new ArrayList<Outline>(3);
/** Create a new Outline based Shape
*/
public OutlineShape(Vertex.Factory<? extends Vertex> factory) {
pointFactory = factory;
- outlines.add(new Outline<Vertex>());
+ outlines.add(new Outline());
}
public final Vertex.Factory<? extends Vertex> 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<Vertex>());
+ 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<Vertex> 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<Vertex> 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<Outline<Vertex>> newOutlines = new ArrayList<Outline<Vertex>>(3);
+ ArrayList<Outline> newOutlines = new ArrayList<Outline>(3);
/**loop over the outlines and make sure no
* adj off-curve vertices
*/
- for(Outline<Vertex> outline:outlines){
- Outline<Vertex> newOutline = new Outline<Vertex>();
+ for(Outline outline:outlines){
+ Outline newOutline = new Outline();
ArrayList<Vertex> vertices = outline.getVertices();
int size =vertices.size()-1;
@@ -165,7 +165,7 @@ public class OutlineShape { private void generateVertexIds(){
int maxVertexId = 0;
- for(Outline<Vertex> outline:outlines){
+ for(Outline outline:outlines){
ArrayList<Vertex> vertices = outline.getVertices();
for(Vertex vert:vertices){
vert.setId(maxVertexId);
@@ -179,7 +179,7 @@ public class OutlineShape { */
public ArrayList<Vertex> getVertices(){
ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- for(Outline<Vertex> 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<Triangle<Vertex>> triangulate(float sharpness){
+ public ArrayList<Triangle> triangulate(float sharpness){
if(outlines.size() == 0){
return null;
}
sortOutlines();
generateVertexIds();
- CDTriangulator2D<Vertex> triangulator2d = new CDTriangulator2D<Vertex>(sharpness);
+ CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness);
for(int index = 0; index< outlines.size();index++){
- Outline<Vertex> outline = outlines.get(index);
+ Outline outline = outlines.get(index);
triangulator2d.addCurve(outline);
}
- ArrayList<Triangle<Vertex>> triangles = triangulator2d.generateTriangulation();
+ ArrayList<Triangle> 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<Triangle<Vertex>> tris);
+ public void addTriangles(ArrayList<Triangle> 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<Triangle<Vertex>> triangles = (ArrayList<Triangle<Vertex>>) outlineShape.triangulate(sharpness); + ArrayList<Triangle> triangles = (ArrayList<Triangle>) outlineShape.triangulate(sharpness); ArrayList<Vertex> vertices = (ArrayList<Vertex>) 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<Triangle<Vertex>> triangles = outlineShape.triangulate(sharpness); + ArrayList<Triangle> triangles = outlineShape.triangulate(sharpness); region.addTriangles(triangles); ArrayList<Vertex> 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 <T extends Vertex> { +public class CDTriangulator2D { protected static final boolean DEBUG = Debug.debug("Triangulation"); private float sharpness = 0.5f; - private ArrayList<Loop<T>> loops; - private ArrayList<T> vertices; + private ArrayList<Loop> loops; + private ArrayList<Vertex> vertices; - private ArrayList<Triangle<T>> triangles; + private ArrayList<Triangle> triangles; private int maxTriID = 0; @@ -76,31 +76,31 @@ public class CDTriangulator2D <T extends Vertex> { */ public void reset() { maxTriID = 0; - vertices = new ArrayList<T>(); - triangles = new ArrayList<Triangle<T>>(3); - loops = new ArrayList<Loop<T>>(); + vertices = new ArrayList<Vertex>(); + triangles = new ArrayList<Triangle>(3); + loops = new ArrayList<Loop>(); } /** Add a curve to the list of profiles provided * @param polyline a bounding Outline */ - public void addCurve(Outline<T> polyline){ - Loop<T> loop = null; + public void addCurve(Outline polyline){ + Loop loop = null; if(!loops.isEmpty()){ loop = getContainerLoop(polyline); } if(loop == null) { - GraphOutline<T> outline = new GraphOutline<T>(polyline); - GraphOutline<T> innerPoly = extractBoundaryTriangles(outline, false); + GraphOutline outline = new GraphOutline(polyline); + GraphOutline innerPoly = extractBoundaryTriangles(outline, false); vertices.addAll(polyline.getVertices()); - loop = new Loop<T>(innerPoly, VectorUtil.CCW); + loop = new Loop(innerPoly, VectorUtil.CCW); loops.add(loop); } else { - GraphOutline<T> outline = new GraphOutline<T>(polyline); - GraphOutline<T> 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 <T extends Vertex> { /** Generate the triangulation of the provided * List of Outlines */ - public ArrayList<Triangle<T>> generateTriangulation(){ + public ArrayList<Triangle> generateTriangulation(){ for(int i=0;i<loops.size();i++) { - Loop<T> loop = loops.get(i); + Loop loop = loops.get(i); int numTries = 0; int size = loop.computeLoopSize(); while(!loop.isSimplex()){ - Triangle<T> tri = null; + Triangle tri = null; if(numTries > size){ tri = loop.cut(false); } @@ -140,41 +140,40 @@ public class CDTriangulator2D <T extends Vertex> { break; } } - Triangle<T> tri = loop.cut(true); + Triangle tri = loop.cut(true); if(tri != null) triangles.add(tri); } return triangles; } - @SuppressWarnings("unchecked") - private GraphOutline<T> extractBoundaryTriangles(GraphOutline<T> outline, boolean hole){ - GraphOutline<T> innerOutline = new GraphOutline<T>(); - ArrayList<GraphVertex<T>> outVertices = outline.getGraphPoint(); + private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole){ + GraphOutline innerOutline = new GraphOutline(); + ArrayList<GraphVertex> outVertices = outline.getGraphPoint(); int size = outVertices.size(); for(int i=0; i < size; i++) { - GraphVertex<T> currentVertex = outVertices.get(i); - GraphVertex<T> gv0 = outVertices.get((i+size-1)%size); - GraphVertex<T> gv2 = outVertices.get((i+1)%size); - GraphVertex<T> 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> t= null; + Triangle t= null; boolean holeLike = false; if(VectorUtil.ccw(v0,v1,v2)){ - t = new Triangle<T>(v0, v1, v2); + t = new Triangle(v0, v1, v2); } else { holeLike = true; - t = new Triangle<T>(v2, v1, v0); + t = new Triangle(v2, v1, v0); } t.setId(maxTriID++); triangles.add(t); @@ -203,10 +202,10 @@ public class CDTriangulator2D <T extends Vertex> { return innerOutline; } - private Loop<T> getContainerLoop(Outline<T> polyline){ - T v = polyline.getVertex(0); + private Loop getContainerLoop(Outline polyline){ + Vertex v = polyline.getVertex(0); - for (Loop<T> loop:loops){ + for (Loop loop:loops){ if(loop.checkInside(v)){ return loop; } |