diff options
author | Rami Santina <[email protected]> | 2011-03-30 16:38:14 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-03-30 16:38:14 +0300 |
commit | 8e5d620eae1dcc1f1178e09c1d5172324541f503 (patch) | |
tree | f2d26265a6d2ee46fba6bae368fbde36428418a8 /src/com/jogamp/graph/curve | |
parent | 133edeb70921dbcae3ec7cc76f1bc6dd0cd36da8 (diff) | |
parent | 630a9ea52b16da6badb31a98b70893f8d294b4e8 (diff) |
Merge with sgothel
Diffstat (limited to 'src/com/jogamp/graph/curve')
-rwxr-xr-x | src/com/jogamp/graph/curve/OutlineShape.java | 35 | ||||
-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, 54 insertions, 56 deletions
diff --git a/src/com/jogamp/graph/curve/OutlineShape.java b/src/com/jogamp/graph/curve/OutlineShape.java index c385b83f5..0c3988db3 100755 --- a/src/com/jogamp/graph/curve/OutlineShape.java +++ b/src/com/jogamp/graph/curve/OutlineShape.java @@ -98,13 +98,13 @@ public class OutlineShape { /** The list of outlines that are part of this
* outline shape.
*/
- 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) {
vertexFactory = factory;
- outlines.add(new Outline<Vertex>());
+ outlines.add(new Outline());
}
/** Returns the associated vertex factory of this outline shape
@@ -120,7 +120,7 @@ public class OutlineShape { * will belong to the new outline
*/
public void addEmptyOutline(){
- outlines.add(new Outline<Vertex>());
+ outlines.add(new Outline());
}
/** Adds an outline to the OutlineShape object
@@ -129,7 +129,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;
}
@@ -197,7 +197,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
@@ -212,13 +212,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;
@@ -242,7 +242,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);
@@ -256,7 +256,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;
@@ -266,7 +266,7 @@ public class OutlineShape { * @return an arraylist of triangles representing the filled region
* which is produced by the combination of the outlines
*/
- public ArrayList<Triangle<Vertex>> triangulate(){
+ public ArrayList<Triangle> triangulate(){
return triangulate(0.5f);
}
@@ -276,21 +276,20 @@ public class OutlineShape { * @return an arraylist of triangles representing the filled region
* which is produced by the combination of the outlines
*/
- 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 a1d888da9..dfeff1b55 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; } |