aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogamp/graph/curve/tess
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-03-30 15:25:18 +0200
committerSven Gothel <[email protected]>2011-03-30 15:25:18 +0200
commit630a9ea52b16da6badb31a98b70893f8d294b4e8 (patch)
tree8ab07c2ff6a670381e2592c09a83bd7cf60a1f2c /src/jogamp/graph/curve/tess
parentd06d5596d18101c876c869a514e42e795ee9357c (diff)
Remove generics notion of Type<Vertex>, since Vertex _is_ the lowest denominator for our implementation and curve API
Diffstat (limited to 'src/jogamp/graph/curve/tess')
-rw-r--r--src/jogamp/graph/curve/tess/GraphOutline.java24
-rw-r--r--src/jogamp/graph/curve/tess/GraphVertex.java34
-rw-r--r--src/jogamp/graph/curve/tess/HEdge.java43
-rw-r--r--src/jogamp/graph/curve/tess/Loop.java114
4 files changed, 106 insertions, 109 deletions
diff --git a/src/jogamp/graph/curve/tess/GraphOutline.java b/src/jogamp/graph/curve/tess/GraphOutline.java
index bb262ce5b..5dae296e5 100644
--- a/src/jogamp/graph/curve/tess/GraphOutline.java
+++ b/src/jogamp/graph/curve/tess/GraphOutline.java
@@ -32,27 +32,27 @@ import java.util.ArrayList;
import com.jogamp.graph.geom.Outline;
import com.jogamp.graph.geom.Vertex;
-public class GraphOutline <T extends Vertex> {
- final private Outline<T> outline;
- final private ArrayList<GraphVertex<T>> controlpoints = new ArrayList<GraphVertex<T>>(3);
+public class GraphOutline {
+ final private Outline outline;
+ final private ArrayList<GraphVertex> controlpoints = new ArrayList<GraphVertex>(3);
public GraphOutline(){
- this.outline = new Outline<T>();
+ this.outline = new Outline();
}
/**Create a control polyline of control vertices
* the curve pieces can be identified by onCurve flag
* of each cp the control polyline is open by default
*/
- public GraphOutline(Outline<T> ol){
+ public GraphOutline(Outline ol){
this.outline = ol;
- ArrayList<T> vertices = this.outline.getVertices();
- for(T v:vertices){
- this.controlpoints.add(new GraphVertex<T>(v));
+ ArrayList<Vertex> vertices = this.outline.getVertices();
+ for(Vertex v:vertices){
+ this.controlpoints.add(new GraphVertex(v));
}
}
- public Outline<T> getOutline() {
+ public Outline getOutline() {
return outline;
}
@@ -61,11 +61,11 @@ public class GraphOutline <T extends Vertex> {
}*/
- public ArrayList<GraphVertex<T>> getGraphPoint() {
+ public ArrayList<GraphVertex> getGraphPoint() {
return controlpoints;
}
- public ArrayList<T> getPoints() {
+ public ArrayList<Vertex> getPoints() {
return outline.getVertices();
}
@@ -73,7 +73,7 @@ public class GraphOutline <T extends Vertex> {
this.controlpoints = controlpoints;
}*/
- public void addVertex(GraphVertex<T> v) {
+ public void addVertex(GraphVertex v) {
controlpoints.add(v);
outline.addVertex(v.getPoint());
}
diff --git a/src/jogamp/graph/curve/tess/GraphVertex.java b/src/jogamp/graph/curve/tess/GraphVertex.java
index a474a002e..b9f95a0e7 100644
--- a/src/jogamp/graph/curve/tess/GraphVertex.java
+++ b/src/jogamp/graph/curve/tess/GraphVertex.java
@@ -31,16 +31,16 @@ import java.util.ArrayList;
import com.jogamp.graph.geom.Vertex;
-public class GraphVertex <T extends Vertex> {
- private T point;
- private ArrayList<HEdge<T>> edges = null;
+public class GraphVertex {
+ private Vertex point;
+ private ArrayList<HEdge> edges = null;
private boolean boundaryContained = false;
- public GraphVertex(T point) {
+ public GraphVertex(Vertex point) {
this.point = point;
}
- public T getPoint() {
+ public Vertex getPoint() {
return point;
}
@@ -59,25 +59,25 @@ public class GraphVertex <T extends Vertex> {
return point.getCoord();
}
- public void setPoint(T point) {
+ public void setPoint(Vertex point) {
this.point = point;
}
- public ArrayList<HEdge<T>> getEdges() {
+ public ArrayList<HEdge> getEdges() {
return edges;
}
- public void setEdges(ArrayList<HEdge<T>> edges) {
+ public void setEdges(ArrayList<HEdge> edges) {
this.edges = edges;
}
- public void addEdge(HEdge<T> edge){
+ public void addEdge(HEdge edge){
if(edges == null){
- edges = new ArrayList<HEdge<T>>();
+ edges = new ArrayList<HEdge>();
}
edges.add(edge);
}
- public void removeEdge(HEdge<T> edge){
+ public void removeEdge(HEdge edge){
if(edges == null)
return;
edges.remove(edge);
@@ -85,24 +85,24 @@ public class GraphVertex <T extends Vertex> {
edges = null;
}
}
- public HEdge<T> findNextEdge(GraphVertex<T> nextVert){
- for(HEdge<T> e:edges){
+ public HEdge findNextEdge(GraphVertex nextVert){
+ for(HEdge e:edges){
if(e.getNext().getGraphPoint() == nextVert){
return e;
}
}
return null;
}
- public HEdge<T> findBoundEdge(){
- for(HEdge<T> e:edges){
+ public HEdge findBoundEdge(){
+ for(HEdge e:edges){
if((e.getType() == HEdge.BOUNDARY) || (e.getType() == HEdge.HOLE)){
return e;
}
}
return null;
}
- public HEdge<T> findPrevEdge(GraphVertex<T> prevVert){
- for(HEdge<T> e:edges){
+ public HEdge findPrevEdge(GraphVertex prevVert){
+ for(HEdge e:edges){
if(e.getPrev().getGraphPoint() == prevVert){
return e;
}
diff --git a/src/jogamp/graph/curve/tess/HEdge.java b/src/jogamp/graph/curve/tess/HEdge.java
index 5635e2c31..d1bcc6e17 100644
--- a/src/jogamp/graph/curve/tess/HEdge.java
+++ b/src/jogamp/graph/curve/tess/HEdge.java
@@ -31,24 +31,24 @@ import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Triangle;
-public class HEdge <T extends Vertex> {
+public class HEdge {
public static int BOUNDARY = 3;
public static int INNER = 1;
public static int HOLE = 2;
- private GraphVertex<T> vert;
- private HEdge<T> prev = null;
- private HEdge<T> next = null;
- private HEdge<T> sibling = null;
+ private GraphVertex vert;
+ private HEdge prev = null;
+ private HEdge next = null;
+ private HEdge sibling = null;
private int type = BOUNDARY;
- private Triangle<T> triangle = null;
+ private Triangle triangle = null;
- public HEdge(GraphVertex<T> vert, int type) {
+ public HEdge(GraphVertex vert, int type) {
this.vert = vert;
this.type = type;
}
- public HEdge(GraphVertex<T> vert, HEdge<T> prev, HEdge<T> next, HEdge<T> sibling, int type) {
+ public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type) {
this.vert = vert;
this.prev = prev;
this.next = next;
@@ -56,8 +56,7 @@ public class HEdge <T extends Vertex> {
this.type = type;
}
- public HEdge(GraphVertex<T> vert, HEdge<T> prev, HEdge<T> next, HEdge<T> sibling, int type,
- Triangle<T> triangle) {
+ public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type, Triangle triangle) {
this.vert = vert;
this.prev = prev;
this.next = next;
@@ -66,35 +65,35 @@ public class HEdge <T extends Vertex> {
this.triangle = triangle;
}
- public GraphVertex<T> getGraphPoint() {
+ public GraphVertex getGraphPoint() {
return vert;
}
- public void setVert(GraphVertex<T> vert) {
+ public void setVert(GraphVertex vert) {
this.vert = vert;
}
- public HEdge<T> getPrev() {
+ public HEdge getPrev() {
return prev;
}
- public void setPrev(HEdge<T> prev) {
+ public void setPrev(HEdge prev) {
this.prev = prev;
}
- public HEdge<T> getNext() {
+ public HEdge getNext() {
return next;
}
- public void setNext(HEdge<T> next) {
+ public void setNext(HEdge next) {
this.next = next;
}
- public HEdge<T> getSibling() {
+ public HEdge getSibling() {
return sibling;
}
- public void setSibling(HEdge<T> sibling) {
+ public void setSibling(HEdge sibling) {
this.sibling = sibling;
}
@@ -106,20 +105,20 @@ public class HEdge <T extends Vertex> {
this.type = type;
}
- public Triangle<T> getTriangle() {
+ public Triangle getTriangle() {
return triangle;
}
- public void setTriangle(Triangle<T> triangle) {
+ public void setTriangle(Triangle triangle) {
this.triangle = triangle;
}
- public static <T extends Vertex> void connect(HEdge<T> first, HEdge<T> next){
+ public static <T extends Vertex> void connect(HEdge first, HEdge next){
first.setNext(next);
next.setPrev(first);
}
- public static <T extends Vertex> void makeSiblings(HEdge<T> first, HEdge<T> second){
+ public static <T extends Vertex> void makeSiblings(HEdge first, HEdge second){
first.setSibling(second);
second.setSibling(first);
}
diff --git a/src/jogamp/graph/curve/tess/Loop.java b/src/jogamp/graph/curve/tess/Loop.java
index 80b96b939..d2162bbeb 100644
--- a/src/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogamp/graph/curve/tess/Loop.java
@@ -35,56 +35,55 @@ import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.math.VectorUtil;
-public class Loop <T extends Vertex> {
- private HEdge<T> root = null;
+public class Loop {
+ private HEdge root = null;
private AABBox box = new AABBox();
- private GraphOutline<T> initialOutline = null;
+ private GraphOutline initialOutline = null;
- public Loop(GraphOutline<T> polyline, int direction){
+ public Loop(GraphOutline polyline, int direction){
initialOutline = polyline;
this.root = initFromPolyline(initialOutline, direction);
}
- public HEdge<T> getHEdge(){
+ public HEdge getHEdge(){
return root;
}
- public Triangle<T> cut(boolean delaunay){
+ public Triangle cut(boolean delaunay){
if(isSimplex()){
- @SuppressWarnings("unchecked")
- Triangle<T> t = new Triangle<T>(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(),
+ Triangle t = new Triangle(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(),
root.getNext().getNext().getGraphPoint().getPoint());
t.setVerticesBoundary(checkVerticesBoundary(root));
return t;
}
- HEdge<T> prev = root.getPrev();
- HEdge<T> next1 = root.getNext();
+ HEdge prev = root.getPrev();
+ HEdge next1 = root.getNext();
- HEdge<T> next2 =findClosestValidNeighbor(next1.getNext(), delaunay);
+ HEdge next2 = findClosestValidNeighbor(next1.getNext(), delaunay);
if(next2 == null){
root = root.getNext();
return null;
}
- GraphVertex<T> v1 = root.getGraphPoint();
- GraphVertex<T> v2 = next1.getGraphPoint();
- GraphVertex<T> v3 = next2.getGraphPoint();
+ GraphVertex v1 = root.getGraphPoint();
+ GraphVertex v2 = next1.getGraphPoint();
+ GraphVertex v3 = next2.getGraphPoint();
- HEdge<T> v3Edge = new HEdge<T>(v3, HEdge.INNER);
+ HEdge v3Edge = new HEdge(v3, HEdge.INNER);
HEdge.connect(v3Edge, root);
HEdge.connect(next1, v3Edge);
- HEdge<T> v3EdgeSib = v3Edge.getSibling();
+ HEdge v3EdgeSib = v3Edge.getSibling();
if(v3EdgeSib == null){
- v3EdgeSib = new HEdge<T>(v3Edge.getNext().getGraphPoint(), HEdge.INNER);
+ v3EdgeSib = new HEdge(v3Edge.getNext().getGraphPoint(), HEdge.INNER);
HEdge.makeSiblings(v3Edge, v3EdgeSib);
}
HEdge.connect(prev, v3EdgeSib);
HEdge.connect(v3EdgeSib, next2);
- Triangle<T> t = createTriangle(v1.getPoint(), v2.getPoint(), v3.getPoint(), root);
+ Triangle t = createTriangle(v1.getPoint(), v2.getPoint(), v3.getPoint(), root);
this.root = next2;
return t;
}
@@ -97,8 +96,8 @@ public class Loop <T extends Vertex> {
* from the boundary profile
* @param direction requested winding of edges (CCW or CW)
*/
- private HEdge<T> initFromPolyline(GraphOutline<T> outline, int direction){
- ArrayList<GraphVertex<T>> vertices = outline.getGraphPoint();
+ private HEdge initFromPolyline(GraphOutline outline, int direction){
+ ArrayList<GraphVertex> vertices = outline.getGraphPoint();
if(vertices.size()<3) {
throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size());
@@ -107,8 +106,8 @@ public class Loop <T extends Vertex> {
vertices.get(2).getPoint());
boolean invert = isCCW && (direction == VectorUtil.CW);
- HEdge<T> firstEdge = null;
- HEdge<T> lastEdge = null;
+ HEdge firstEdge = null;
+ HEdge lastEdge = null;
int index =0;
int max = vertices.size();
@@ -120,10 +119,10 @@ public class Loop <T extends Vertex> {
}
while(index != max){
- GraphVertex<T> v1 = vertices.get(index);
+ GraphVertex v1 = vertices.get(index);
box.resize(v1.getX(), v1.getY(), v1.getZ());
- HEdge<T> edge = new HEdge<T>(v1, edgeType);
+ HEdge edge = new HEdge(v1, edgeType);
v1.addEdge(edge);
if(lastEdge != null){
@@ -157,22 +156,22 @@ public class Loop <T extends Vertex> {
return firstEdge;
}
- public void addConstraintCurve(GraphOutline<T> polyline) {
+ public void addConstraintCurve(GraphOutline polyline) {
// GraphOutline outline = new GraphOutline(polyline);
/**needed to generate vertex references.*/
initFromPolyline(polyline, VectorUtil.CW);
- GraphVertex<T> v3 = locateClosestVertex(polyline);
- HEdge<T> v3Edge = v3.findBoundEdge();
- HEdge<T> v3EdgeP = v3Edge.getPrev();
- HEdge<T> crossEdge = new HEdge<T>(root.getGraphPoint(), HEdge.INNER);
+ GraphVertex v3 = locateClosestVertex(polyline);
+ HEdge v3Edge = v3.findBoundEdge();
+ HEdge v3EdgeP = v3Edge.getPrev();
+ HEdge crossEdge = new HEdge(root.getGraphPoint(), HEdge.INNER);
HEdge.connect(root.getPrev(), crossEdge);
HEdge.connect(crossEdge, v3Edge);
- HEdge<T> crossEdgeSib = crossEdge.getSibling();
+ HEdge crossEdgeSib = crossEdge.getSibling();
if(crossEdgeSib == null) {
- crossEdgeSib = new HEdge<T>(crossEdge.getNext().getGraphPoint(), HEdge.INNER);
+ crossEdgeSib = new HEdge(crossEdge.getNext().getGraphPoint(), HEdge.INNER);
HEdge.makeSiblings(crossEdge, crossEdgeSib);
}
@@ -186,22 +185,22 @@ public class Loop <T extends Vertex> {
* to search for closestvertices
* @return the vertex that is closest to the newly set root Hedge.
*/
- private GraphVertex<T> locateClosestVertex(GraphOutline<T> polyline) {
- HEdge<T> closestE = null;
- GraphVertex<T> closestV = null;
+ private GraphVertex locateClosestVertex(GraphOutline polyline) {
+ HEdge closestE = null;
+ GraphVertex closestV = null;
float minDistance = Float.MAX_VALUE;
boolean inValid = false;
- ArrayList<GraphVertex<T>> initVertices = initialOutline.getGraphPoint();
- ArrayList<GraphVertex<T>> vertices = polyline.getGraphPoint();
+ ArrayList<GraphVertex> initVertices = initialOutline.getGraphPoint();
+ ArrayList<GraphVertex> vertices = polyline.getGraphPoint();
for(int i=0; i< initVertices.size()-1; i++){
- GraphVertex<T> v = initVertices.get(i);
- GraphVertex<T> nextV = initVertices.get(i+1);
- for(GraphVertex<T> cand:vertices){
+ GraphVertex v = initVertices.get(i);
+ GraphVertex nextV = initVertices.get(i+1);
+ for(GraphVertex cand:vertices){
float distance = VectorUtil.computeLength(v.getCoord(), cand.getCoord());
if(distance < minDistance){
- for (GraphVertex<T> vert:vertices){
+ for (GraphVertex vert:vertices){
if(vert == v || vert == nextV || vert == cand)
continue;
inValid = VectorUtil.inCircle(v.getPoint(), nextV.getPoint(),
@@ -227,20 +226,20 @@ public class Loop <T extends Vertex> {
return closestV;
}
- private HEdge<T> findClosestValidNeighbor(HEdge<T> edge, boolean delaunay) {
- HEdge<T> next = root.getNext();
+ private HEdge findClosestValidNeighbor(HEdge edge, boolean delaunay) {
+ HEdge next = root.getNext();
if(!VectorUtil.ccw(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(),
edge.getGraphPoint().getPoint())){
return null;
}
- HEdge<T> candEdge = edge;
+ HEdge candEdge = edge;
boolean inValid = false;
if(delaunay){
- T cand = candEdge.getGraphPoint().getPoint();
- HEdge<T> e = candEdge.getNext();
+ Vertex cand = candEdge.getGraphPoint().getPoint();
+ HEdge e = candEdge.getNext();
while (e != candEdge){
if(e.getGraphPoint() == root.getGraphPoint()
|| e.getGraphPoint() == next.getGraphPoint()
@@ -270,18 +269,17 @@ public class Loop <T extends Vertex> {
* @param root and edge of this triangle
* @return the triangle iff it satisfies, null otherwise
*/
- private Triangle<T> createTriangle(T v1, T v2, T v3, HEdge<T> rootT){
- @SuppressWarnings("unchecked")
- Triangle<T> t = new Triangle<T>(v1, v2, v3);
+ private Triangle createTriangle(Vertex v1, Vertex v2, Vertex v3, HEdge rootT){
+ Triangle t = new Triangle(v1, v2, v3);
t.setVerticesBoundary(checkVerticesBoundary(rootT));
return t;
}
- private boolean[] checkVerticesBoundary(HEdge<T> rootT) {
+ private boolean[] checkVerticesBoundary(HEdge rootT) {
boolean[] boundary = new boolean[3];
- HEdge<T> e1 = rootT;
- HEdge<T> e2 = rootT.getNext();
- HEdge<T> e3 = rootT.getNext().getNext();
+ HEdge e1 = rootT;
+ HEdge e2 = rootT.getNext();
+ HEdge e3 = rootT.getNext().getNext();
if(e1.getGraphPoint().isBoundaryContained()){
boundary[0] = true;
@@ -300,7 +298,7 @@ public class Loop <T extends Vertex> {
* @param vertex the Vertex
* @return true if the vertex is inside, false otherwise
*/
- public boolean checkInside(T vertex) {
+ public boolean checkInside(Vertex vertex) {
if(!box.contains(vertex.getX(), vertex.getY(), vertex.getZ())){
return false;
}
@@ -308,8 +306,8 @@ public class Loop <T extends Vertex> {
float[] center = box.getCenter();
int hits = 0;
- HEdge<T> current = root;
- HEdge<T> next = root.getNext();
+ HEdge current = root;
+ HEdge next = root.getNext();
while(next!= root){
if(current.getType() == HEdge.INNER || next.getType() == HEdge.INNER){
current = next;
@@ -317,8 +315,8 @@ public class Loop <T extends Vertex> {
continue;
}
- T vert1 = current.getGraphPoint().getPoint();
- T vert2 = next.getGraphPoint().getPoint();
+ Vertex vert1 = current.getGraphPoint().getPoint();
+ Vertex vert2 = next.getGraphPoint().getPoint();
/** The ray is P0+s*D0, where P0 is the ray origin, D0 is a direction vector and s >= 0.
* The segment is P1+t*D1, where P1 and P1+D1 are the endpoints, and 0 <= t <= 1.
@@ -366,7 +364,7 @@ public class Loop <T extends Vertex> {
public int computeLoopSize(){
int size = 0;
- HEdge<T> e = root;
+ HEdge e = root;
do{
size++;
e = e.getNext();