summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/tess
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/tess')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java5
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java87
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java16
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java19
4 files changed, 66 insertions, 61 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java
index 715b812c1..9772b860f 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java
@@ -36,6 +36,7 @@ import com.jogamp.graph.geom.Outline;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.plane.Winding;
+import com.jogamp.opengl.math.Vec2f;
import com.jogamp.opengl.math.VectorUtil;
import jogamp.opengl.Debug;
@@ -145,13 +146,13 @@ public class CDTriangulator2D implements Triangulator {
}
}
if( TEST_ENABLED ) {
- final float[] tempV2 = new float[2];
+ final Vec2f tempV2 = new Vec2f();
final CDTriangulator2DExpAddOn addOn = new CDTriangulator2DExpAddOn();
final int sinkSize = sink.size();
if( TEST_MARK_LINE ) {
for(int i=0; i<sinkSize; i++) {
final Triangle t0 = sink.get(i);
- addOn.markLineInTriangle(t0, tempV2);
+ addOn.markLineInTriangle(t0);
}
} else if ( TEST_LINE_AA ){
for(int i=0; i<sinkSize-1; i+=2) {
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java
index a836e2023..86edf7d61 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java
@@ -30,7 +30,8 @@ package jogamp.graph.curve.tess;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.math.Vec2f;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.VectorUtil;
/**
@@ -40,10 +41,10 @@ import com.jogamp.opengl.math.VectorUtil;
*/
public class CDTriangulator2DExpAddOn {
- private final float[] tempV3a = new float[3];
- private final float[] tempV3b = new float[3];
+ private final Vec3f tempV3a = new Vec3f();
+ private final Vec3f tempV3b = new Vec3f();
- protected final void markLineInTriangle(final Triangle tri1, final float[] tempV2) {
+ protected final void markLineInTriangle(final Triangle tri1) {
if( !tri1.isOnCurve() || !tri1.isLine() ) {
return;
}
@@ -56,19 +57,19 @@ public class CDTriangulator2DExpAddOn {
int lineSegCount = 0;
final boolean v0IsLS, v1IsLS, v2IsLS;
- if( v0.isOnCurve() && VectorUtil.isVec2Zero(v0.getTexCoord(), 0) && !boundVs[0] ) {
+ if( v0.isOnCurve() && VectorUtil.isVec2Zero(v0.getTexCoord()) && !boundVs[0] ) {
v0IsLS = true;
lineSegCount++;
} else {
v0IsLS = false;
}
- if( v1.isOnCurve() && VectorUtil.isVec2Zero(v1.getTexCoord(), 0) && !boundVs[1] ) {
+ if( v1.isOnCurve() && VectorUtil.isVec2Zero(v1.getTexCoord()) && !boundVs[1] ) {
v1IsLS = true;
lineSegCount++;
} else {
v1IsLS = false;
}
- if( v2.isOnCurve() && VectorUtil.isVec2Zero(v2.getTexCoord(), 0) && !boundVs[2] ) {
+ if( v2.isOnCurve() && VectorUtil.isVec2Zero(v2.getTexCoord()) && !boundVs[2] ) {
v2IsLS = true;
lineSegCount++;
} else {
@@ -155,17 +156,17 @@ public class CDTriangulator2DExpAddOn {
* </p>
* @param tri2
* @param checkThisOnCurve
- * @param tempV2 temp float[2] storage
+ * @param temp temp storage
*/
- protected final float[] processLineAA(final int i, final Triangle tri1, final Triangle tri2, final float[] tempV2) {
+ protected final Vec2f processLineAA(final int i, final Triangle tri1, final Triangle tri2, final Vec2f temp) {
if(CDTriangulator2D.DEBUG){
System.err.println("CDTri.genP2["+i+"].1: ? t1 "+tri1);
System.err.println("CDTri.genP2["+i+"].1: ? t2 "+tri2);
}
- final float[] rect = processLineAAImpl(tri1, tri2, tempV2);
+ final Vec2f rect = processLineAAImpl(tri1, tri2, temp);
if(CDTriangulator2D.DEBUG){
if( null != rect ) {
- System.err.println("CDTri.genP2["+i+"].1: RECT ["+rect[0]+", "+rect[1]+"]");
+ System.err.println("CDTri.genP2["+i+"].1: RECT ["+rect.x()+", "+rect.y()+"]");
System.err.println("CDTri.genP2["+i+"].1: RECT t1 "+tri1);
System.err.println("CDTri.genP2["+i+"].1: RECT t2 "+tri2);
} else {
@@ -175,40 +176,40 @@ public class CDTriangulator2DExpAddOn {
}
return rect;
}
- private final float[] processLineAAImpl(final Triangle tri1, final Triangle tri2, final float[] tempV2) {
+ private final Vec2f processLineAAImpl(final Triangle tri1, final Triangle tri2, final Vec2f temp) {
if( !tri1.isOnCurve() || !tri2.isOnCurve() || !tri1.isLine() || !tri2.isLine() ) {
return null;
}
- final float[] rect;
+ final Vec2f rect;
int eqCount = 0;
final int[] commonIdxA = { -1, -1 };
final int[] commonIdxB = { -1, -1 };
final Vertex[] verts1 = tri1.getVertices();
final Vertex[] verts2 = tri2.getVertices();
- float[] coord = verts1[0].getCoord();
- if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) {
+ Vec3f coord = verts1[0].getCoord();
+ if( coord.isEqual( verts2[0].getCoord() ) ) {
commonIdxA[eqCount] = 0;
commonIdxB[eqCount] = 0;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[1].getCoord() ) ) {
commonIdxA[eqCount] = 0;
commonIdxB[eqCount] = 1;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[2].getCoord() ) ) {
commonIdxA[eqCount] = 0;
commonIdxB[eqCount] = 2;
eqCount++;
}
coord = verts1[1].getCoord();
- if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) {
+ if( coord.isEqual( verts2[0].getCoord() ) ) {
commonIdxA[eqCount] = 1;
commonIdxB[eqCount] = 0;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[1].getCoord() ) ) {
commonIdxA[eqCount] = 1;
commonIdxB[eqCount] = 1;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[2].getCoord() ) ) {
commonIdxA[eqCount] = 1;
commonIdxB[eqCount] = 2;
eqCount++;
@@ -218,15 +219,15 @@ public class CDTriangulator2DExpAddOn {
otherIdxA = 3 - ( commonIdxA[0] + commonIdxA[1] );
} else {
coord = verts1[2].getCoord();
- if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) {
+ if( coord.isEqual( verts2[0].getCoord() ) ) {
commonIdxA[eqCount] = 2;
commonIdxB[eqCount] = 0;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[1].getCoord() ) ) {
commonIdxA[eqCount] = 2;
commonIdxB[eqCount] = 1;
eqCount++;
- } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) {
+ } else if( coord.isEqual( verts2[2].getCoord() ) ) {
commonIdxA[eqCount] = 2;
commonIdxB[eqCount] = 2;
eqCount++;
@@ -265,30 +266,30 @@ public class CDTriangulator2DExpAddOn {
}
final float texZTag = 2f;
- final float[] vOACoords = vOA.getCoord();
- final float dOC0A = VectorUtil.distVec3(vOACoords, vC0A.getCoord());
- final float dOC1A = VectorUtil.distVec3(vOACoords, vC1A.getCoord());
+ final Vec3f vOACoords = vOA.getCoord();
+ final float dOC0A = vOACoords.dist( vC0A.getCoord() );
+ final float dOC1A = vOACoords.dist( vC1A.getCoord() );
if( false ) {
- final float[] vec3Z = { 0f, 0f, -1f };
- final float[] vecLongSide, vecLineHeight;
+ final Vec3f vec3Z = new Vec3f(0f, 0f, -1f);
+ final Vec3f vecLongSide, vecLineHeight;
if( dOC0A < dOC1A ) {
- tempV2[0] = dOC0A; // line width
- tempV2[1] = dOC1A; // long side
- vecLongSide = VectorUtil.normalizeVec3( VectorUtil.subVec2(tempV3a, vOACoords, vC1A.getCoord()) ); // normal long side vector
- vecLineHeight = VectorUtil.crossVec3(tempV3b, vec3Z, tempV3a); // the line-height vector (normal)
+ temp.set( dOC0A, // line width
+ dOC1A); // long side
+ vecLongSide = tempV3a.minus(vOACoords, vC1A.getCoord()).normalize(); // normal long side vector
+ vecLineHeight = tempV3b.cross(vec3Z, tempV3a); // the line-height vector (normal)
vOA.setTexCoord(-1f, -1f, texZTag);
vC1A.setTexCoord(1f, -1f, texZTag);
vOB.setTexCoord(0f, 1f, texZTag);
vC0A.setTexCoord(0f, 1f, texZTag);
} else {
- tempV2[0] = dOC1A; // line width
- tempV2[1] = dOC0A; // long side
- vecLongSide = VectorUtil.normalizeVec3( VectorUtil.subVec2(tempV3a, vOACoords, vC0A.getCoord()) ); // normal long side vector
- vecLineHeight = VectorUtil.crossVec3(tempV3b, vec3Z, tempV3a); // the line-height vector (normal)
+ temp.set( dOC1A, // line width
+ dOC0A); // long side
+ vecLongSide = tempV3a.minus(vOACoords, vC0A.getCoord()).normalize(); // normal long side vector
+ vecLineHeight = tempV3b.cross(vec3Z, tempV3a); // the line-height vector (normal)
}
if(CDTriangulator2D.DEBUG){
- System.err.println("RECT.0 : long-side-vec "+vecLongSide[0]+", "+vecLongSide[1]+", "+vecLongSide[2]);
- System.err.println("RECT.0 : line-height-vec "+vecLineHeight[0]+", "+vecLineHeight[1]+", "+vecLineHeight[2]);
+ System.err.println("RECT.0 : long-side-vec "+vecLongSide);
+ System.err.println("RECT.0 : line-height-vec "+vecLineHeight);
}
} else {
@@ -303,16 +304,16 @@ public class CDTriangulator2DExpAddOn {
final Vertex vL1, vL2, vR1, vR2;
if( dOC0A < dOC1A ) {
lineWidth = dOC0A; // line width
- tempV2[0] = dOC0A; // line width
- tempV2[1] = dOC1A; // long side
+ temp.set( dOC0A, // line width
+ dOC1A); // long side
// Left: vOA, vC1A
// Right: vOB, vC0A
vL1 = vOA; vL2 = vC1A;
vR1 = vOB; vR2 = vC0A;
} else {
lineWidth = dOC1A; // line width
- tempV2[0] = dOC1A; // line width
- tempV2[1] = dOC0A; // long side
+ temp.set( dOC1A, // line width
+ dOC0A); // long side
// Left: vOB, vC1A
// Right: vOA, vC0A
vL1 = vOB; vL2 = vC1A;
@@ -331,7 +332,7 @@ public class CDTriangulator2DExpAddOn {
System.err.println("RECT Right.0: "+vR1+", "+vR2);
}
}
- rect = tempV2;
+ rect = temp;
} else {
rect = null;
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
index 391e71011..275abda23 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
@@ -30,6 +30,7 @@ package jogamp.graph.curve.tess;
import java.util.ArrayList;
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.opengl.math.Vec3f;
public class GraphVertex {
private Vertex point;
@@ -44,18 +45,18 @@ public class GraphVertex {
return point;
}
- public float getX(){
- return point.getX();
+ public float x(){
+ return point.x();
}
- public float getY(){
- return point.getY();
+ public float y(){
+ return point.y();
}
- public float getZ(){
- return point.getZ();
+ public float z(){
+ return point.z();
}
- public float[] getCoord() {
+ public Vec3f getCoord() {
return point.getCoord();
}
@@ -121,6 +122,7 @@ public class GraphVertex {
this.boundaryContained = boundaryContained;
}
+ @Override
public String toString() {
return "GraphVertex[contained "+boundaryContained+", "+point+"]";
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
index 155fbd18d..1939dcb1e 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.plane.Winding;
import com.jogamp.graph.geom.Triangle;
+import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.Vert2fImmutable;
import com.jogamp.opengl.math.geom.AABBox;
@@ -96,9 +97,9 @@ public class Loop {
final int n = vertices.size();
float area = 0.0f;
for (int p = n - 1, q = 0; q < n; p = q++) {
- final float[] pCoord = vertices.get(p).getCoord();
- final float[] qCoord = vertices.get(q).getCoord();
- area += pCoord[0] * qCoord[1] - qCoord[0] * pCoord[1];
+ final Vec3f pCoord = vertices.get(p).getCoord();
+ final Vec3f qCoord = vertices.get(q).getCoord();
+ area += pCoord.x() * qCoord.y() - qCoord.x() * pCoord.y();
}
return area;
}
@@ -136,7 +137,7 @@ public class Loop {
final int max = vertices.size() - 1;
for(int index = 0; index <= max; ++index) {
final GraphVertex v1 = vertices.get(index);
- box.resize(v1.getX(), v1.getY(), v1.getZ());
+ box.resize(v1.x(), v1.y(), v1.z());
final HEdge edge = new HEdge(v1, edgeType);
@@ -157,7 +158,7 @@ public class Loop {
// CCW -> CW
for(int index = vertices.size() - 1; index >= 0; --index) {
final GraphVertex v1 = vertices.get(index);
- box.resize(v1.getX(), v1.getY(), v1.getZ());
+ box.resize(v1.x(), v1.y(), v1.z());
final HEdge edge = new HEdge(v1, edgeType);
@@ -222,7 +223,7 @@ public class Loop {
final GraphVertex nextV = initVertices.get(i+1);
for(int pos=0; pos<vertices.size(); pos++) {
final GraphVertex cand = vertices.get(pos);
- final float distance = VectorUtil.distVec3(v.getCoord(), cand.getCoord());
+ final float distance = v.getCoord().dist( cand.getCoord() );
if(distance < minDistance){
for (final GraphVertex vert:vertices){
if(vert == v || vert == nextV || vert == cand)
@@ -312,7 +313,7 @@ public class Loop {
}
public boolean checkInside(final Vertex v) {
- if(!box.contains(v.getX(), v.getY(), v.getZ())){
+ if(!box.contains(v.x(), v.y(), v.z())){
return false;
}
@@ -323,8 +324,8 @@ public class Loop {
final Vertex v2 = current.getGraphPoint().getPoint();
final Vertex v1 = next.getGraphPoint().getPoint();
- if ( ((v1.getY() > v.getY()) != (v2.getY() > v.getY())) &&
- (v.getX() < (v2.getX() - v1.getX()) * (v.getY() - v1.getY()) / (v2.getY() - v1.getY()) + v1.getX()) ){
+ if ( ((v1.y() > v.y()) != (v2.y() > v.y())) &&
+ (v.x() < (v2.x() - v1.x()) * (v.y() - v1.y()) / (v2.y() - v1.y()) + v1.x()) ){
inside = !inside;
}