aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphui/classes/jogamp/graph/ui/TreeTool.java2
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java39
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java155
3 files changed, 81 insertions, 115 deletions
diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
index 979c6a3b1..1309775a0 100644
--- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java
+++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
@@ -63,7 +63,7 @@ public class TreeTool {
return true;
} else if( s instanceof Container ) {
final Container c = (Container)s;
- if( !c.contains(shape) ) { // fast-path: skip container
+ if( !contains(c, shape) ) { // fast-path: skip container
continue;
}
pmv.pushMv();
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index 85b29c1aa..f3db64198 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -919,27 +919,24 @@ public final class OutlineShape implements Comparable<OutlineShape> {
final Outline outline = getOutline(cc);
final int vertexCount = outline.getVertexCount();
for(int i=0; i < vertexCount; i++) {
- final Vertex current = outline.getVertex(i);
- if(current.isOnCurve() || current == a || current == b || current == c) {
- continue;
- }
- final Vertex nextV = outline.getVertex((i+1)%vertexCount);
- final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
-
- //skip neighboring triangles
- if(prevV == c || nextV == a) {
- continue;
- }
-
- if( VectorUtil.isInTriangle3(a.getCoord(), b.getCoord(), c.getCoord(),
- current.getCoord(), nextV.getCoord(), prevV.getCoord(),
- tmpV1, tmpV2, tmpV3) ) {
- return current;
- }
- if(VectorUtil.testTri2SegIntersection(a, b, c, prevV, current) ||
- VectorUtil.testTri2SegIntersection(a, b, c, current, nextV) ||
- VectorUtil.testTri2SegIntersection(a, b, c, prevV, nextV) ) {
- return current;
+ final Vertex currV = outline.getVertex(i);
+ if( !currV.isOnCurve() && currV != a && currV != b && currV != c) {
+ final Vertex nextV = outline.getVertex((i+1)%vertexCount);
+ final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
+
+ //skip neighboring triangles
+ if(prevV != c && nextV != a) {
+ if( VectorUtil.isInTriangle3(a.getCoord(), b.getCoord(), c.getCoord(),
+ currV.getCoord(), nextV.getCoord(), prevV.getCoord(),
+ tmpV1, tmpV2, tmpV3) ) {
+ return currV;
+ }
+ if(VectorUtil.testTri2SegIntersection(a, b, c, prevV, currV) ||
+ VectorUtil.testTri2SegIntersection(a, b, c, currV, nextV) ||
+ VectorUtil.testTri2SegIntersection(a, b, c, prevV, nextV) ) {
+ return currV;
+ }
+ }
}
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
index aaf74d376..2d7c27ffa 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
@@ -222,23 +222,9 @@ public class Loop {
return closestV;
}
- /**
- public static void printPerf(final PrintStream out) {
- out.printf("Graph.Intersection: cut[count %,d, td %,f ms], isect[count %,d, td %,f ms], isec/cut[count %f, td %f]%n",
- perf_cut_count, perf_cut_td_ns/1000000.0, perf_isect_count, perf_isect_td_ns/1000000.0,
- (double)perf_isect_count/(double)perf_cut_count, (double)perf_isect_td_ns/(double)perf_cut_td_ns);
- }
- private static long perf_isect_td_ns = 0;
- private static long perf_isect_count = 0;
- private static long perf_cut_td_ns = 0;
- private static long perf_cut_count = 0;
- */
public final Triangle cut(final boolean delaunay){
if( !CDTriangulator2D.DEBUG ) {
- // final long t0 = Clock.currentNanos();
return cut0(delaunay);
- // perf_cut_td_ns += Clock.currentNanos() - t0;
- // perf_cut_count++;
} else {
return cutDbg(delaunay);
}
@@ -331,85 +317,65 @@ public class Loop {
return t;
}
- private boolean intersectsOutline(final Vertex a1, final Vertex a2, final Vertex b) {
- // final long t0 = Clock.currentNanos();
+ private final boolean intersectsOutline(final Vertex a1, final Vertex a2, final Vertex b) {
for(final GraphOutline outline : outlines) {
- if( intersectsOutline(outline, a1, a2, b) ) {
- // perf_isect_td_ns += Clock.currentNanos() - t0;
- // perf_isect_count++;
- return true;
- }
- }
- // perf_isect_td_ns += Clock.currentNanos() - t0;
- // perf_isect_count++;
- return false;
- }
- private boolean intersectsOutline(final GraphOutline outline, final Vertex a1, final Vertex a2, final Vertex b) {
- final ArrayList<GraphVertex> vertices = outline.getGraphPoint();
- final int sz = vertices.size();
- if( sz < 2 ) {
- return false;
- }
- Vertex v0 = vertices.get(0).getPoint();
- for(int i=1; i< sz; i++){
- final Vertex v1 = vertices.get(i).getPoint();
- if( !( v0 == b || v1 == b ) ) {
- if( !( v0 == a1 || v1 == a1 ) &&
- VectorUtil.testSeg2SegIntersection(a1, b, v0, v1) ) {
- return true;
- }
- if( !( v0 == a2 || v1 == a2 ) &&
- VectorUtil.testSeg2SegIntersection(a2, b, v0, v1) ) {
- return true;
+ final ArrayList<GraphVertex> vertices = outline.getGraphPoint();
+ final int sz = vertices.size();
+ if( sz >= 2 ) {
+ Vertex v0 = vertices.get(0).getPoint();
+ for(int i=1; i< sz; i++){
+ final Vertex v1 = vertices.get(i).getPoint();
+ if( v0 != b && v1 != b ) {
+ if( v0 != a1 && v1 != a1 &&
+ VectorUtil.testSeg2SegIntersection(a1, b, v0, v1) ) {
+ return true;
+ }
+ if( v0 != a2 && v1 != a2 &&
+ VectorUtil.testSeg2SegIntersection(a2, b, v0, v1) ) {
+ return true;
+ }
+ }
+ v0 = v1;
}
}
- v0 = v1;
}
return false;
}
- private boolean intersectsOutlineDbg(final Vertex a1, final Vertex a2, final Vertex b) {
+ private final boolean intersectsOutlineDbg(final Vertex a1, final Vertex a2, final Vertex b) {
for(final GraphOutline outline : outlines) {
- if( intersectsOutlineDbg(outline, a1, a2, b) ) {
- return true;
- }
- }
- return false;
- }
- private boolean intersectsOutlineDbg(final GraphOutline outline, final Vertex a1, final Vertex a2, final Vertex b) {
- final ArrayList<GraphVertex> vertices = outline.getGraphPoint();
- final int sz = vertices.size();
- if( sz < 2 ) {
- return false;
- }
- Vertex v0 = vertices.get(0).getPoint();
- for(int i=1; i< sz; i++){
- final Vertex v1 = vertices.get(i).getPoint();
- if( !( v0 == b || v1 == b ) ) {
- if( !( v0 == a1 || v1 == a1 ) &&
- VectorUtil.testSeg2SegIntersection(a1, b, v0, v1) ) {
- System.err.printf("Loop.intersection.b-a1.1: %d/%d %s to%n-a1 %s, with%n-v0 %s%n-v1 %s%n", i, sz-1, b, a1, v0, v1);
- return true;
- }
- if( !( v0 == a2 || v1 == a2 ) &&
- VectorUtil.testSeg2SegIntersection(a2, b, v0, v1) ) {
- System.err.printf("Loop.intersection.b-a2.1: %d/%d %s to%n-a2 %s, with%n-v0 %s%n-v1 %s%n", i, sz-1, b, a2, v0, v1);
- return true;
+ final ArrayList<GraphVertex> vertices = outline.getGraphPoint();
+ final int sz = vertices.size();
+ if( sz >= 2 ) {
+ Vertex v0 = vertices.get(0).getPoint();
+ for(int i=1; i< sz; i++){
+ final Vertex v1 = vertices.get(i).getPoint();
+ if( v0 != b && v1 != b ) {
+ if( v0 != a1 && v1 != a1 &&
+ VectorUtil.testSeg2SegIntersection(a1, b, v0, v1) ) {
+ System.err.printf("Loop.intersection.b-a1.1: %d/%d %s to%n-a1 %s, with%n-v0 %s%n-v1 %s%n", i, sz-1, b, a1, v0, v1);
+ return true;
+ }
+ if( v0 != a2 && v1 != a2 &&
+ VectorUtil.testSeg2SegIntersection(a2, b, v0, v1) ) {
+ System.err.printf("Loop.intersection.b-a2.1: %d/%d %s to%n-a2 %s, with%n-v0 %s%n-v1 %s%n", i, sz-1, b, a2, v0, v1);
+ return true;
+ }
+ }
+ v0 = v1;
}
}
- v0 = v1;
}
return false;
}
- private HEdge isValidNeighbor(final HEdge candEdge, final boolean delaunay) {
- final HEdge next = root.getNext();
- final Vertex rootPoint = root.getGraphPoint().getPoint();
- final Vertex nextPoint = next.getGraphPoint().getPoint();
+ private final HEdge isValidNeighbor(final HEdge candEdge, final boolean delaunay) {
+ final GraphVertex rootGPoint = root.getGraphPoint();
+ final GraphVertex nextGPoint = root.getNext().getGraphPoint();
+ final Vertex rootPoint = rootGPoint.getPoint();
+ final Vertex nextPoint = nextGPoint.getPoint();
final Vertex candPoint = candEdge.getGraphPoint().getPoint();
- if( !VectorUtil.isCCW( rootPoint, nextPoint, candPoint) ) {
- return null;
- }
- if( complexShape && intersectsOutline(rootPoint, nextPoint, candPoint) ) {
+ if( !VectorUtil.isCCW( rootPoint, nextPoint, candPoint) ||
+ complexShape && intersectsOutline(rootPoint, nextPoint, candPoint) ) {
return null;
}
if( !delaunay ) {
@@ -418,11 +384,12 @@ public class Loop {
HEdge e = candEdge.getNext();
while (e != candEdge){
final GraphVertex egp = e.getGraphPoint();
- if(egp != root.getGraphPoint() &&
- egp != next.getGraphPoint() &&
- egp.getPoint() != candPoint )
+ final Vertex ep = egp.getPoint();
+ if(egp != rootGPoint &&
+ egp != nextGPoint &&
+ ep != candPoint )
{
- if( VectorUtil.isInCircle(rootPoint, nextPoint, candPoint, egp.getPoint()) ) {
+ if( VectorUtil.isInCircle(rootPoint, nextPoint, candPoint, ep) ) {
return null;
}
}
@@ -430,10 +397,11 @@ public class Loop {
}
return candEdge;
}
- private HEdge isValidNeighborDbg(final HEdge candEdge, final boolean delaunay) {
- final HEdge next = root.getNext();
- final Vertex rootPoint = root.getGraphPoint().getPoint();
- final Vertex nextPoint = next.getGraphPoint().getPoint();
+ private final HEdge isValidNeighborDbg(final HEdge candEdge, final boolean delaunay) {
+ final GraphVertex rootGPoint = root.getGraphPoint();
+ final GraphVertex nextGPoint = root.getNext().getGraphPoint();
+ final Vertex rootPoint = rootGPoint.getPoint();
+ final Vertex nextPoint = nextGPoint.getPoint();
final Vertex candPoint = candEdge.getGraphPoint().getPoint();
if( !VectorUtil.isCCW( rootPoint, nextPoint, candPoint) ) {
System.err.printf("Loop.isInCircle.X: !CCW %s, of%n- %s%n- %s%n- %s%n",
@@ -449,18 +417,19 @@ public class Loop {
HEdge e = candEdge.getNext();
while (e != candEdge){
final GraphVertex egp = e.getGraphPoint();
- if(egp != root.getGraphPoint() &&
- egp != next.getGraphPoint() &&
- egp.getPoint() != candPoint )
+ final Vertex ep = egp.getPoint();
+ if(egp != rootGPoint &&
+ egp != nextGPoint &&
+ ep != candPoint )
{
- final double v = VectorUtil.inCircleVal(rootPoint, nextPoint, candPoint, egp.getPoint());
+ final double v = VectorUtil.inCircleVal(rootPoint, nextPoint, candPoint, ep);
if( v > DoubleUtil.EPSILON ) {
System.err.printf("Loop.isInCircle.1: %30.30f: %s, of%n- %s%n- %s%n- %s%n",
- v, candPoint, rootPoint, nextPoint, egp.getPoint());
+ v, candPoint, rootPoint, nextPoint, ep);
return null;
}
System.err.printf("Loop.isInCircle.0: %30.30f: %s, of%n- %s%n- %s%n- %s%n",
- v, candPoint, root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(), egp.getPoint());
+ v, candPoint, rootPoint, nextPoint, ep);
}
e = e.getNext();
}