aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/graph
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp/graph')
-rwxr-xr-xsrc/com/jogamp/graph/curve/OutlineShape.java35
-rwxr-xr-xsrc/com/jogamp/graph/curve/Region.java2
-rw-r--r--src/com/jogamp/graph/curve/opengl/RegionRenderer.java4
-rw-r--r--src/com/jogamp/graph/curve/tess/CDTriangulator2D.java69
-rw-r--r--src/com/jogamp/graph/geom/Outline.java29
-rw-r--r--src/com/jogamp/graph/geom/Triangle.java8
6 files changed, 71 insertions, 76 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;
}
diff --git a/src/com/jogamp/graph/geom/Outline.java b/src/com/jogamp/graph/geom/Outline.java
index 4f8d26783..24f44b5fc 100644
--- a/src/com/jogamp/graph/geom/Outline.java
+++ b/src/com/jogamp/graph/geom/Outline.java
@@ -43,9 +43,9 @@ import com.jogamp.graph.math.VectorUtil;
*
* @see OutlineShape, Region
*/
-public class Outline<T extends Vertex> implements Comparable<Outline<T>>{
+public class Outline implements Comparable<Outline> {
- private ArrayList<T> vertices = new ArrayList<T>(3);
+ private ArrayList<Vertex> vertices = new ArrayList<Vertex>(3);
private boolean closed = false;
private AABBox box = new AABBox();
@@ -61,7 +61,7 @@ public class Outline<T extends Vertex> implements Comparable<Outline<T>>{
* end of the outline loop/strip.
* @param vertex Vertex to be added
*/
- public final void addVertex(T vertex) {
+ public final void addVertex(Vertex vertex) {
vertices.add(vertex);
box.resize(vertex.getX(), vertex.getY(), vertex.getZ());
}
@@ -70,38 +70,36 @@ public class Outline<T extends Vertex> implements Comparable<Outline<T>>{
addVertex(factory, x, y, 0f, onCurve);
}
- @SuppressWarnings("unchecked")
public final void addVertex(Vertex.Factory<? extends Vertex> factory, float x, float y, float z, boolean onCurve) {
Vertex v = factory.create(x, y, z);
v.setOnCurve(onCurve);
- addVertex((T)v);
+ addVertex(v);
}
- @SuppressWarnings("unchecked")
public final void addVertex(Vertex.Factory<? extends Vertex> factory, float[] coordsBuffer, int offset, int length, boolean onCurve) {
Vertex v = factory.create(coordsBuffer, offset, length);
v.setOnCurve(onCurve);
- addVertex((T)v);
+ addVertex(v);
}
- public T getVertex(int index){
+ public Vertex getVertex(int index){
return vertices.get(index);
}
public boolean isEmpty(){
return (vertices.size() == 0);
}
- public T getLastVertex(){
+ public Vertex getLastVertex(){
if(isEmpty()){
return null;
}
return vertices.get(vertices.size()-1);
}
- public ArrayList<T> getVertices() {
+ public ArrayList<Vertex> getVertices() {
return vertices;
}
- public void setVertices(ArrayList<T> vertices) {
+ public void setVertices(ArrayList<Vertex> vertices) {
this.vertices = vertices;
}
public AABBox getBox() {
@@ -120,11 +118,10 @@ public class Outline<T extends Vertex> implements Comparable<Outline<T>>{
public void setClosed(boolean closed) {
this.closed = closed;
if(closed){
- T first = vertices.get(0);
- T last = getLastVertex();
+ Vertex first = vertices.get(0);
+ Vertex last = getLastVertex();
if(!VectorUtil.checkEquality(first.getCoord(), last.getCoord())){
- @SuppressWarnings("unchecked")
- T v = (T) first.clone();
+ Vertex v = first.clone();
vertices.add(v);
}
}
@@ -134,7 +131,7 @@ public class Outline<T extends Vertex> implements Comparable<Outline<T>>{
* as criteria.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Outline<T> outline) {
+ public int compareTo(Outline outline) {
float size = box.getSize();
float newSize = outline.getBox().getSize();
if(size < newSize){
diff --git a/src/com/jogamp/graph/geom/Triangle.java b/src/com/jogamp/graph/geom/Triangle.java
index 7b11ba23d..d13e8ddb1 100644
--- a/src/com/jogamp/graph/geom/Triangle.java
+++ b/src/com/jogamp/graph/geom/Triangle.java
@@ -27,13 +27,13 @@
*/
package com.jogamp.graph.geom;
-public class Triangle<T extends Vertex> {
+public class Triangle {
private int id = Integer.MAX_VALUE;
- final private T[] vertices;
+ final private Vertex[] vertices;
private boolean[] boundaryEdges = new boolean[3];
private boolean[] boundaryVertices = null;
- public Triangle(T ... v123){
+ public Triangle(Vertex ... v123){
vertices = v123;
}
@@ -45,7 +45,7 @@ public class Triangle<T extends Vertex> {
this.id = id;
}
- public T[] getVertices() {
+ public Vertex[] getVertices() {
return vertices;
}