From 526af50c03af2e00a028caf4b8504e6c3f3c4221 Mon Sep 17 00:00:00 2001 From: Rami Santina Date: Fri, 25 Mar 2011 12:00:55 +0200 Subject: Refactored Vertex Point PointTex GraphPoint namings Vertex class --> SVertex (Simple vertex wwhere memory impl is float[]) Point interface --> Vertex (which combines in it PointTex Interface) GraphPoint --> GraphVertex --- src/com/jogamp/graph/curve/HwRegionRenderer.java | 14 +- src/com/jogamp/graph/curve/OutlineShape.java | 68 ++++---- src/com/jogamp/graph/curve/Region.java | 6 +- .../jogamp/graph/curve/tess/CDTriangulator2D.java | 16 +- .../jogamp/graph/curve/text/HwTextRenderer.java | 17 +- src/com/jogamp/graph/font/FontFactory.java | 7 +- src/com/jogamp/graph/geom/Line.java | 2 +- src/com/jogamp/graph/geom/Outline.java | 14 +- src/com/jogamp/graph/geom/Point.java | 78 --------- src/com/jogamp/graph/geom/PointTex.java | 37 ----- src/com/jogamp/graph/geom/Triangle.java | 2 +- src/com/jogamp/graph/geom/Vertex.java | 82 ++++++++++ src/com/jogamp/graph/geom/opengl/SVertex.java | 179 ++++++++++++++++++++ src/com/jogamp/graph/geom/opengl/Vertex.java | 180 --------------------- src/demo/GPURegionNewtDemo01.java | 4 +- src/demo/GPURegionNewtDemo02.java | 6 +- src/demo/GPUTextNewtDemo01.java | 6 +- src/demo/GPUTextNewtDemo02.java | 6 +- src/jogamp/graph/curve/opengl/VBORegion2PGL3.java | 22 +-- src/jogamp/graph/curve/opengl/VBORegionSPES2.java | 24 +-- src/jogamp/graph/curve/tess/GraphOutline.java | 12 +- src/jogamp/graph/curve/tess/GraphPoint.java | 120 -------------- src/jogamp/graph/curve/tess/GraphVertex.java | 120 ++++++++++++++ src/jogamp/graph/curve/tess/HEdge.java | 20 +-- src/jogamp/graph/curve/tess/Loop.java | 32 ++-- src/jogamp/graph/curve/text/GlyphShape.java | 31 ++-- src/jogamp/graph/curve/text/GlyphString.java | 27 ++-- src/jogamp/graph/font/typecast/TypecastFont.java | 10 +- .../graph/font/typecast/TypecastFontFactory.java | 8 +- .../graph/font/typecast/TypecastRenderer.java | 6 +- src/jogamp/graph/geom/plane/AffineTransform.java | 36 ++--- src/jogamp/graph/geom/plane/Path2D.java | 10 +- src/jogamp/graph/math/VectorFloatUtil.java | 10 +- 33 files changed, 587 insertions(+), 625 deletions(-) delete mode 100644 src/com/jogamp/graph/geom/Point.java delete mode 100644 src/com/jogamp/graph/geom/PointTex.java create mode 100644 src/com/jogamp/graph/geom/Vertex.java create mode 100644 src/com/jogamp/graph/geom/opengl/SVertex.java delete mode 100644 src/com/jogamp/graph/geom/opengl/Vertex.java delete mode 100644 src/jogamp/graph/curve/tess/GraphPoint.java create mode 100644 src/jogamp/graph/curve/tess/GraphVertex.java diff --git a/src/com/jogamp/graph/curve/HwRegionRenderer.java b/src/com/jogamp/graph/curve/HwRegionRenderer.java index 3c3142061..2caa6bb7e 100755 --- a/src/com/jogamp/graph/curve/HwRegionRenderer.java +++ b/src/com/jogamp/graph/curve/HwRegionRenderer.java @@ -40,7 +40,7 @@ import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import jogamp.opengl.Debug; import com.jogamp.opengl.util.PMVMatrix; @@ -71,7 +71,7 @@ public class HwRegionRenderer { /** Create a Hardware accelerated Region Renderer * @param context OpenGL rendering context - * @param factory optional Point.Factory for PointTex construction. Default is Vertex.Factory. + * @param factory optional Point.Factory for Vertex construction. Default is Vertex.Factory. */ public HwRegionRenderer(GLContext context) { this.context = context; @@ -248,8 +248,8 @@ public class HwRegionRenderer { outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList> triangles = (ArrayList>) outlineShape.triangulate(sharpness); - ArrayList vertices = (ArrayList) outlineShape.getVertices(); + ArrayList> triangles = (ArrayList>) outlineShape.triangulate(sharpness); + ArrayList vertices = (ArrayList) outlineShape.getVertices(); region.addVertices(vertices); region.addTriangles(triangles); @@ -265,11 +265,11 @@ public class HwRegionRenderer { for(OutlineShape outlineShape:outlineShapes){ outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList> triangles = outlineShape.triangulate(sharpness); + ArrayList> triangles = outlineShape.triangulate(sharpness); region.addTriangles(triangles); - ArrayList vertices = outlineShape.getVertices(); - for(PointTex vert:vertices){ + ArrayList vertices = outlineShape.getVertices(); + for(Vertex vert:vertices){ vert.setId(numVertices++); } region.addVertices(vertices); diff --git a/src/com/jogamp/graph/curve/OutlineShape.java b/src/com/jogamp/graph/curve/OutlineShape.java index d939d7427..b48804b4d 100755 --- a/src/com/jogamp/graph/curve/OutlineShape.java +++ b/src/com/jogamp/graph/curve/OutlineShape.java @@ -35,8 +35,8 @@ import jogamp.graph.math.VectorFloatUtil; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Line; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.curve.tess.CDTriangulator2D; @@ -54,24 +54,24 @@ import com.jogamp.graph.curve.tess.CDTriangulator2D; */ public class OutlineShape { public static final int QUADRATIC_NURBS = 10; - private final Point.Factory pointFactory; - private ArrayList> outlines = new ArrayList>(3); + private final Vertex.Factory pointFactory; + private ArrayList> outlines = new ArrayList>(3); /** Create a new Outline based Shape */ - public OutlineShape(Point.Factory factory) { + public OutlineShape(Vertex.Factory factory) { pointFactory = factory; - outlines.add(new Outline()); + outlines.add(new Outline()); } - public final Point.Factory pointFactory() { return pointFactory; } + public final Vertex.Factory pointFactory() { return pointFactory; } /** Add a new empty outline * to the shape, this new outline will * be placed at the end of the outline list. */ public void addEmptyOutline(){ - outlines.add(new Outline()); + outlines.add(new Outline()); } /** Adds an outline to the OutlineShape object @@ -80,7 +80,7 @@ public class OutlineShape { * it will do nothing. * @param outline an Outline object */ - public void addOutline(Outline outline){ + public void addOutline(Outline outline){ if(outline.isEmpty()){ return; } @@ -94,7 +94,7 @@ public class OutlineShape { * shape * @param point */ - public final void addVertex(PointTex point){ + public final void addVertex(Vertex point){ getLastOutline().addVertex(point); } @@ -123,7 +123,7 @@ public class OutlineShape { * of outlines that define the shape * @return the last outline */ - public final Outline getLastOutline(){ + public final Outline getLastOutline(){ return outlines.get(outlines.size()-1); } /** Make sure that the outlines represent @@ -138,19 +138,19 @@ public class OutlineShape { } private void transformOutlinesQuadratic(){ - ArrayList> newOutlines = new ArrayList>(3); + ArrayList> newOutlines = new ArrayList>(3); /**loop over the outlines and make sure no * adj off-curve vertices */ - for(Outline outline:outlines){ - Outline newOutline = new Outline(); + for(Outline outline:outlines){ + Outline newOutline = new Outline(); - ArrayList vertices = outline.getVertices(); + ArrayList vertices = outline.getVertices(); int size =vertices.size()-1; for(int i=0;i outline:outlines){ - ArrayList vertices = outline.getVertices(); - for(PointTex vert:vertices){ + for(Outline outline:outlines){ + ArrayList vertices = outline.getVertices(); + for(Vertex vert:vertices){ vert.setId(maxVertexId); maxVertexId++; } @@ -180,9 +180,9 @@ public class OutlineShape { /** @return the list of vertices associated with the * {@code Outline} list of this object */ - public ArrayList getVertices(){ - ArrayList vertices = new ArrayList(); - for(Outline polyline:outlines){ + public ArrayList getVertices(){ + ArrayList vertices = new ArrayList(); + for(Outline polyline:outlines){ vertices.addAll(polyline.getVertices()); } return vertices; @@ -193,17 +193,17 @@ public class OutlineShape { * parts of this graph * @return arraylist of lines */ - public ArrayList> getLines(){ - ArrayList> lines = new ArrayList>(); - for(Outline outline:outlines){ - ArrayList outVertices = outline.getVertices(); + public ArrayList> getLines(){ + ArrayList> lines = new ArrayList>(); + for(Outline outline:outlines){ + ArrayList outVertices = outline.getVertices(); int size = outVertices.size(); for(int i=0; i < size; i++) { - PointTex currentVertex = outVertices.get(i); + Vertex currentVertex = outVertices.get(i); if(currentVertex.isOnCurve()) { - PointTex v2 = outVertices.get((i+1)%size); + Vertex v2 = outVertices.get((i+1)%size); if(v2.isOnCurve()){ - lines.add(new Line(currentVertex, v2)); + lines.add(new Line(currentVertex, v2)); } } } @@ -214,21 +214,21 @@ public class OutlineShape { /** Triangluate the graph object * @param sharpness sharpness of the curved regions default = 0.5 */ - public ArrayList> triangulate(float sharpness){ + public ArrayList> triangulate(float sharpness){ if(outlines.size() == 0){ return null; } sortOutlines(); generateVertexIds(); - CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness); + CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness); for(int index = 0; index< outlines.size();index++){ - Outline outline = outlines.get(index); + Outline outline = outlines.get(index); triangulator2d.addCurve(outline); } - ArrayList> triangles = triangulator2d.generateTriangulation(); + ArrayList> 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 44f426313..f3a87bb7f 100755 --- a/src/com/jogamp/graph/curve/Region.java +++ b/src/com/jogamp/graph/curve/Region.java @@ -30,7 +30,7 @@ package com.jogamp.graph.curve; import java.util.ArrayList; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.opengl.util.PMVMatrix; /** A Region is the OGL binding of one or more OutlineShapes @@ -80,7 +80,7 @@ public interface Region { * * @see update() */ - public void addTriangles(ArrayList> tris); + public void addTriangles(ArrayList> tris); /** Get the current number of vertices associated * with this region. This number is not necessary equal to @@ -98,7 +98,7 @@ public interface Region { * * @see update() */ - public void addVertices(ArrayList verts); + public void addVertices(ArrayList verts); /** Check if this region is dirty. A region is marked dirty * when new Vertices, Triangles, and or Lines are added after a diff --git a/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java index 936965f0c..00c97d463 100644 --- a/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/com/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -31,13 +31,13 @@ package com.jogamp.graph.curve.tess; import java.util.ArrayList; import jogamp.graph.curve.tess.GraphOutline; -import jogamp.graph.curve.tess.GraphPoint; +import jogamp.graph.curve.tess.GraphVertex; import jogamp.graph.curve.tess.Loop; import jogamp.graph.math.VectorFloatUtil; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import jogamp.opengl.Debug; /** Constrained Delaunay Triangulation @@ -45,7 +45,7 @@ import jogamp.opengl.Debug; * Closed Regions with optional n holes. * */ -public class CDTriangulator2D { +public class CDTriangulator2D { protected static final boolean DEBUG = Debug.debug("Triangulation"); @@ -149,13 +149,13 @@ public class CDTriangulator2D { @SuppressWarnings("unchecked") private GraphOutline extractBoundaryTriangles(GraphOutline outline, boolean hole){ GraphOutline innerOutline = new GraphOutline(); - ArrayList> outVertices = outline.getGraphPoint(); + ArrayList> outVertices = outline.getGraphPoint(); int size = outVertices.size(); for(int i=0; i < size; i++) { - GraphPoint currentVertex = outVertices.get(i); - GraphPoint gv0 = outVertices.get((i+size-1)%size); - GraphPoint gv2 = outVertices.get((i+1)%size); - GraphPoint 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(); diff --git a/src/com/jogamp/graph/curve/text/HwTextRenderer.java b/src/com/jogamp/graph/curve/text/HwTextRenderer.java index 61d8309c7..bbe62f158 100644 --- a/src/com/jogamp/graph/curve/text/HwTextRenderer.java +++ b/src/com/jogamp/graph/curve/text/HwTextRenderer.java @@ -48,9 +48,8 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.PointTex; -import com.jogamp.graph.geom.opengl.Vertex; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.opengl.SVertex; import jogamp.opengl.Debug; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -100,28 +99,28 @@ public class HwTextRenderer { private GLContext context; private FloatBuffer color = FloatBuffer.allocate(3); private HashMap strings = new HashMap(); - private final Point.Factory pointFactory; + private final Vertex.Factory pointFactory; int win_width = 0; int win_height = 0; /** Create a Hardware accelerated Text Renderer * @param context OpenGL rendering context - * @param factory optional Point.Factory for PointTex construction. Default is Vertex.Factory. + * @param factory optional Point.Factory for Vertex construction. Default is Vertex.Factory. */ - public HwTextRenderer(GLContext context, Point.Factory factory, int type) { - this.pointFactory = (null != factory) ? factory : Vertex.factory(); + public HwTextRenderer(GLContext context, Vertex.Factory factory, int type) { + this.pointFactory = (null != factory) ? factory : SVertex.factory(); this.context = context; this.regionType = type; init(context, 0.5f); } - public Font createFont(Point.Factory factory, String name, int size) { + public Font createFont(Vertex.Factory factory, String name, int size) { return fontFactory.createFont(factory, name, size); } - public Font createFont(Point.Factory factory, + public Font createFont(Vertex.Factory factory, String[] families, String style, String variant, diff --git a/src/com/jogamp/graph/font/FontFactory.java b/src/com/jogamp/graph/font/FontFactory.java index d10e1c38b..a96dac1b8 100644 --- a/src/com/jogamp/graph/font/FontFactory.java +++ b/src/com/jogamp/graph/font/FontFactory.java @@ -27,19 +27,18 @@ */ package com.jogamp.graph.font; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; public interface FontFactory { - Font createFont(Point.Factory factory, + Font createFont(Vertex.Factory factory, String[] families, String style, String variant, String weight, String size); - Font createFont(Point.Factory factory, + Font createFont(Vertex.Factory factory, String name, int size); } \ No newline at end of file diff --git a/src/com/jogamp/graph/geom/Line.java b/src/com/jogamp/graph/geom/Line.java index dbdee569c..92d1b007f 100644 --- a/src/com/jogamp/graph/geom/Line.java +++ b/src/com/jogamp/graph/geom/Line.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.geom; -public class Line { +public class Line { private T v1; private T v2; diff --git a/src/com/jogamp/graph/geom/Outline.java b/src/com/jogamp/graph/geom/Outline.java index b8b824a1c..d9bde4177 100644 --- a/src/com/jogamp/graph/geom/Outline.java +++ b/src/com/jogamp/graph/geom/Outline.java @@ -29,7 +29,7 @@ package com.jogamp.graph.geom; import java.util.ArrayList; -import com.jogamp.graph.geom.Point; +import com.jogamp.graph.geom.Vertex; import jogamp.graph.math.VectorFloatUtil; @@ -45,7 +45,7 @@ import jogamp.graph.math.VectorFloatUtil; * @see OutlineShape, Region * */ -public class Outline implements Comparable>{ +public class Outline implements Comparable>{ private ArrayList vertices = new ArrayList(3); private boolean closed = false; @@ -68,20 +68,20 @@ public class Outline implements Comparable>{ box.resize(vertex.getX(), vertex.getY(), vertex.getZ()); } - public final void addVertex(Point.Factory factory, float x, float y, boolean onCurve) { + public final void addVertex(Vertex.Factory factory, float x, float y, boolean onCurve) { addVertex(factory, x, y, 0f, onCurve); } @SuppressWarnings("unchecked") - public final void addVertex(Point.Factory factory, float x, float y, float z, boolean onCurve) { - Point v = factory.create(x, y, z); + public final void addVertex(Vertex.Factory factory, float x, float y, float z, boolean onCurve) { + Vertex v = factory.create(x, y, z); v.setOnCurve(onCurve); addVertex((T)v); } @SuppressWarnings("unchecked") - public final void addVertex(Point.Factory factory, float[] coordsBuffer, int offset, int length, boolean onCurve) { - Point v = factory.create(coordsBuffer, offset, length); + public final void addVertex(Vertex.Factory factory, float[] coordsBuffer, int offset, int length, boolean onCurve) { + Vertex v = factory.create(coordsBuffer, offset, length); v.setOnCurve(onCurve); addVertex((T)v); } diff --git a/src/com/jogamp/graph/geom/Point.java b/src/com/jogamp/graph/geom/Point.java deleted file mode 100644 index 5f85801f8..000000000 --- a/src/com/jogamp/graph/geom/Point.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.graph.geom; - -/** - * A point with custom memory layout using custom factory. - */ -public interface Point extends Comparable, Cloneable { - - public static interface Factory { - T create(); - - T create(float x, float y); - - T create(float x, float y, float z); - - T create(float[] coordsBuffer, int offset, int length); - - // T[] create(T ... v); - } - - void setCoord(float x, float y); - - void setCoord(float x, float y, float z); - - void setCoord(float[] coordsBuffer, int offset, int length); - - float[] getCoord(); - - void setX(float x); - - void setY(float y); - - void setZ(float z); - - float getX(); - - float getY(); - - float getZ(); - - boolean isOnCurve(); - - void setOnCurve(boolean onCurve); - - int getId(); - - void setId(int id); - - int compareTo(Point p); - - Point clone(); -} diff --git a/src/com/jogamp/graph/geom/PointTex.java b/src/com/jogamp/graph/geom/PointTex.java deleted file mode 100644 index 59f7ee0c6..000000000 --- a/src/com/jogamp/graph/geom/PointTex.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.graph.geom; - -/** - * A Point with texture coordinates - */ -public interface PointTex extends Point { - float[] getTexCoord(); - - void setTexCoord(float s, float t); -} diff --git a/src/com/jogamp/graph/geom/Triangle.java b/src/com/jogamp/graph/geom/Triangle.java index 341a4483b..7b11ba23d 100644 --- a/src/com/jogamp/graph/geom/Triangle.java +++ b/src/com/jogamp/graph/geom/Triangle.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.geom; -public class Triangle { +public class Triangle { private int id = Integer.MAX_VALUE; final private T[] vertices; private boolean[] boundaryEdges = new boolean[3]; diff --git a/src/com/jogamp/graph/geom/Vertex.java b/src/com/jogamp/graph/geom/Vertex.java new file mode 100644 index 000000000..9d19c89f6 --- /dev/null +++ b/src/com/jogamp/graph/geom/Vertex.java @@ -0,0 +1,82 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.graph.geom; + +/** + * A Vertex with custom memory layout using custom factory. + */ +public interface Vertex extends Comparable, Cloneable { + + public static interface Factory { + T create(); + + T create(float x, float y); + + T create(float x, float y, float z); + + T create(float[] coordsBuffer, int offset, int length); + + // T[] create(T ... v); + } + + void setCoord(float x, float y); + + void setCoord(float x, float y, float z); + + void setCoord(float[] coordsBuffer, int offset, int length); + + float[] getCoord(); + + void setX(float x); + + void setY(float y); + + void setZ(float z); + + float getX(); + + float getY(); + + float getZ(); + + boolean isOnCurve(); + + void setOnCurve(boolean onCurve); + + int getId(); + + void setId(int id); + + int compareTo(Vertex p); + + float[] getTexCoord(); + + void setTexCoord(float s, float t); + + Vertex clone(); +} diff --git a/src/com/jogamp/graph/geom/opengl/SVertex.java b/src/com/jogamp/graph/geom/opengl/SVertex.java new file mode 100644 index 000000000..86b95854d --- /dev/null +++ b/src/com/jogamp/graph/geom/opengl/SVertex.java @@ -0,0 +1,179 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.graph.geom.opengl; + +import jogamp.graph.math.VectorFloatUtil; + +import com.jogamp.graph.geom.Vertex; + +public class SVertex implements Vertex { + private int id = Integer.MAX_VALUE; + protected float[] coord = new float[3]; + protected boolean onCurve = true; + private float[] texCoord = new float[2]; + + static final Factory factory = new Factory(); + + public static Factory factory() { return factory; } + + public static class Factory implements Vertex.Factory { + @Override + public SVertex create() { + return new SVertex(); + } + + @Override + public SVertex create(float x, float y) { + return new SVertex(x, y); + } + + @Override + public SVertex create(float x, float y, float z) { + return new SVertex(x, y, z); + } + + @Override + public SVertex create(float[] coordsBuffer, int offset, int length) { + return new SVertex(coordsBuffer, offset, length); + } + + /* @Override + public Vertex[] create(Vertex ... v) { + return v; + } */ + } + + public SVertex() { + } + + public SVertex(float x, float y) { + setCoord(x, y); + } + public SVertex(float x, float y, float z) { + setCoord(x, y, z); + } + public SVertex(float[] coordsBuffer, int offset, int length) { + setCoord(coordsBuffer, offset, length); + } + + public void setCoord(float x, float y) { + this.coord[0] = x; + this.coord[1] = y; + this.coord[2] = 0f; + } + + public void setCoord(float x, float y, float z) { + this.coord[0] = x; + this.coord[1] = y; + this.coord[2] = z; + } + + public void setCoord(float[] coordsBuffer, int offset, int length) { + if(length > coordsBuffer.length - offset) { + throw new IndexOutOfBoundsException("coordsBuffer too small: "+coordsBuffer.length+" - "+offset+" < "+length); + } + if(length > 3) { + throw new IndexOutOfBoundsException("length too bug: "+length+" > "+3); + } + int i=0; + while(i { - @Override - public Vertex create() { - return new Vertex(); - } - - @Override - public Vertex create(float x, float y) { - return new Vertex(x, y); - } - - @Override - public Vertex create(float x, float y, float z) { - return new Vertex(x, y, z); - } - - @Override - public Vertex create(float[] coordsBuffer, int offset, int length) { - return new Vertex(coordsBuffer, offset, length); - } - - /* @Override - public Vertex[] create(Vertex ... v) { - return v; - } */ - } - - public Vertex() { - } - - public Vertex(float x, float y) { - setCoord(x, y); - } - public Vertex(float x, float y, float z) { - setCoord(x, y, z); - } - public Vertex(float[] coordsBuffer, int offset, int length) { - setCoord(coordsBuffer, offset, length); - } - - public void setCoord(float x, float y) { - this.coord[0] = x; - this.coord[1] = y; - this.coord[2] = 0f; - } - - public void setCoord(float x, float y, float z) { - this.coord[0] = x; - this.coord[1] = y; - this.coord[2] = z; - } - - public void setCoord(float[] coordsBuffer, int offset, int length) { - if(length > coordsBuffer.length - offset) { - throw new IndexOutOfBoundsException("coordsBuffer too small: "+coordsBuffer.length+" - "+offset+" < "+length); - } - if(length > 3) { - throw new IndexOutOfBoundsException("length too bug: "+length+" > "+3); - } - int i=0; - while(i pointFactory = Vertex.factory(); + Vertex.Factory pointFactory = SVertex.factory(); TextGLListener textGLListener = null; diff --git a/src/demo/GPUTextNewtDemo02.java b/src/demo/GPUTextNewtDemo02.java index b0c7115ec..b048a3a68 100644 --- a/src/demo/GPUTextNewtDemo02.java +++ b/src/demo/GPUTextNewtDemo02.java @@ -38,8 +38,8 @@ import javax.media.opengl.GLProfile; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.text.HwTextRenderer; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.opengl.Vertex; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.opengl.SVertex; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.WindowAdapter; @@ -57,7 +57,7 @@ public class GPUTextNewtDemo02 { } class TextNewtWindow { - Point.Factory pointFactory = Vertex.factory(); + Vertex.Factory pointFactory = SVertex.factory(); TextGLListener textGLListener = null; public TextNewtWindow(){ diff --git a/src/jogamp/graph/curve/opengl/VBORegion2PGL3.java b/src/jogamp/graph/curve/opengl/VBORegion2PGL3.java index c5182059e..4f2714494 100644 --- a/src/jogamp/graph/curve/opengl/VBORegion2PGL3.java +++ b/src/jogamp/graph/curve/opengl/VBORegion2PGL3.java @@ -41,7 +41,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.curve.Region; import com.jogamp.opengl.util.PMVMatrix; @@ -53,8 +53,8 @@ public class VBORegion2PGL3 implements Region{ private IntBuffer t_vboIds; - private ArrayList> triangles = new ArrayList>(); - private ArrayList vertices = new ArrayList(); + private ArrayList> triangles = new ArrayList>(); + private ArrayList vertices = new ArrayList(); private GLContext context; private int numBuffers = 3; @@ -85,7 +85,7 @@ public class VBORegion2PGL3 implements Region{ GL3 gl = context.getGL().getGL3(); ShortBuffer indicies = Buffers.newDirectShortBuffer(triangles.size() * 3); - for(Triangle t:triangles){ + for(Triangle t:triangles){ if(t.getVertices()[0].getId() == Integer.MAX_VALUE){ t.getVertices()[0].setId(numVertices++); t.getVertices()[1].setId(numVertices++); @@ -100,9 +100,9 @@ public class VBORegion2PGL3 implements Region{ indicies.put((short) t.getVertices()[2].getId()); } else{ - PointTex v1 = t.getVertices()[0]; - PointTex v2 = t.getVertices()[1]; - PointTex v3 = t.getVertices()[2]; + Vertex v1 = t.getVertices()[0]; + Vertex v2 = t.getVertices()[1]; + Vertex v3 = t.getVertices()[2]; indicies.put((short) v1.getId()); indicies.put((short) v2.getId()); @@ -112,7 +112,7 @@ public class VBORegion2PGL3 implements Region{ indicies.rewind(); FloatBuffer verticesBuffer = Buffers.newDirectFloatBuffer(vertices.size() * 3); - for(PointTex v:vertices){ + for(Vertex v:vertices){ verticesBuffer.put(v.getX()); if(flipped){ verticesBuffer.put(-1*v.getY()); @@ -127,7 +127,7 @@ public class VBORegion2PGL3 implements Region{ verticesBuffer.rewind(); FloatBuffer texCoordBuffer = Buffers.newDirectFloatBuffer(vertices.size() * 2); - for(PointTex v:vertices){ + for(Vertex v:vertices){ float[] tex = v.getTexCoord(); texCoordBuffer.put(tex[0]); texCoordBuffer.put(tex[1]); @@ -327,7 +327,7 @@ public class VBORegion2PGL3 implements Region{ gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); } - public void addTriangles(ArrayList> tris) { + public void addTriangles(ArrayList> tris) { triangles.addAll(tris); dirty = true; } @@ -336,7 +336,7 @@ public class VBORegion2PGL3 implements Region{ return numVertices; } - public void addVertices(ArrayList verts){ + public void addVertices(ArrayList verts){ vertices.addAll(verts); numVertices = vertices.size(); dirty = true; diff --git a/src/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogamp/graph/curve/opengl/VBORegionSPES2.java index 5ef23d4e0..155d35f0b 100644 --- a/src/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -37,7 +37,7 @@ import javax.media.opengl.GLContext; import com.jogamp.common.nio.Buffers; import com.jogamp.graph.curve.Region; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; import com.jogamp.opengl.util.PMVMatrix; @@ -45,8 +45,8 @@ public class VBORegionSPES2 implements Region{ private int numVertices = 0; private IntBuffer vboIds; - private ArrayList> triangles = new ArrayList>(); - private ArrayList vertices = new ArrayList(); + private ArrayList> triangles = new ArrayList>(); + private ArrayList vertices = new ArrayList(); private GLContext context; @@ -63,8 +63,8 @@ public class VBORegionSPES2 implements Region{ GL2ES2 gl = context.getGL().getGL2ES2(); ShortBuffer indicies = Buffers.newDirectShortBuffer(triangles.size() * 3); - for(Triangle t:triangles){ - final PointTex[] t_vertices = t.getVertices(); + for(Triangle t:triangles){ + final Vertex[] t_vertices = t.getVertices(); if(t_vertices[0].getId() == Integer.MAX_VALUE){ t_vertices[0].setId(numVertices++); @@ -80,9 +80,9 @@ public class VBORegionSPES2 implements Region{ indicies.put((short) t.getVertices()[2].getId()); } else{ - PointTex v1 = t_vertices[0]; - PointTex v2 = t_vertices[1]; - PointTex v3 = t_vertices[2]; + Vertex v1 = t_vertices[0]; + Vertex v2 = t_vertices[1]; + Vertex v3 = t_vertices[2]; indicies.put((short) v1.getId()); indicies.put((short) v2.getId()); @@ -92,7 +92,7 @@ public class VBORegionSPES2 implements Region{ indicies.rewind(); FloatBuffer verticesBuffer = Buffers.newDirectFloatBuffer(vertices.size() * 3); - for(PointTex v:vertices){ + for(Vertex v:vertices){ verticesBuffer.put(v.getX()); if(flipped){ verticesBuffer.put(-1*v.getY()); @@ -105,7 +105,7 @@ public class VBORegionSPES2 implements Region{ verticesBuffer.rewind(); FloatBuffer texCoordBuffer = Buffers.newDirectFloatBuffer(vertices.size() * 2); - for(PointTex v:vertices){ + for(Vertex v:vertices){ float[] tex = v.getTexCoord(); texCoordBuffer.put(tex[0]); texCoordBuffer.put(tex[1]); @@ -151,7 +151,7 @@ public class VBORegionSPES2 implements Region{ render(); } - public void addTriangles(ArrayList> tris) { + public void addTriangles(ArrayList> tris) { triangles.addAll(tris); dirty = true; } @@ -160,7 +160,7 @@ public class VBORegionSPES2 implements Region{ return numVertices; } - public void addVertices(ArrayList verts){ + public void addVertices(ArrayList verts){ vertices.addAll(verts); numVertices = vertices.size(); dirty = true; diff --git a/src/jogamp/graph/curve/tess/GraphOutline.java b/src/jogamp/graph/curve/tess/GraphOutline.java index cf73ab379..bb262ce5b 100644 --- a/src/jogamp/graph/curve/tess/GraphOutline.java +++ b/src/jogamp/graph/curve/tess/GraphOutline.java @@ -30,11 +30,11 @@ package jogamp.graph.curve.tess; import java.util.ArrayList; import com.jogamp.graph.geom.Outline; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; -public class GraphOutline { +public class GraphOutline { final private Outline outline; - final private ArrayList> controlpoints = new ArrayList>(3); + final private ArrayList> controlpoints = new ArrayList>(3); public GraphOutline(){ this.outline = new Outline(); @@ -48,7 +48,7 @@ public class GraphOutline { this.outline = ol; ArrayList vertices = this.outline.getVertices(); for(T v:vertices){ - this.controlpoints.add(new GraphPoint(v)); + this.controlpoints.add(new GraphVertex(v)); } } @@ -61,7 +61,7 @@ public class GraphOutline { }*/ - public ArrayList> getGraphPoint() { + public ArrayList> getGraphPoint() { return controlpoints; } @@ -73,7 +73,7 @@ public class GraphOutline { this.controlpoints = controlpoints; }*/ - public void addVertex(GraphPoint v) { + public void addVertex(GraphVertex v) { controlpoints.add(v); outline.addVertex(v.getPoint()); } diff --git a/src/jogamp/graph/curve/tess/GraphPoint.java b/src/jogamp/graph/curve/tess/GraphPoint.java deleted file mode 100644 index 87d0b9929..000000000 --- a/src/jogamp/graph/curve/tess/GraphPoint.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.graph.curve.tess; - -import java.util.ArrayList; - -import com.jogamp.graph.geom.PointTex; - -public class GraphPoint { - private T point; - private ArrayList> edges = null; - private boolean boundaryContained = false; - - public GraphPoint(T point) { - this.point = point; - } - - public T getPoint() { - return point; - } - - public float getX(){ - return point.getX(); - } - - public float getY(){ - return point.getY(); - } - - public float getZ(){ - return point.getZ(); - } - public float[] getCoord() { - return point.getCoord(); - } - - public void setPoint(T point) { - this.point = point; - } - - public ArrayList> getEdges() { - return edges; - } - - public void setEdges(ArrayList> edges) { - this.edges = edges; - } - - public void addEdge(HEdge edge){ - if(edges == null){ - edges = new ArrayList>(); - } - edges.add(edge); - } - public void removeEdge(HEdge edge){ - if(edges == null) - return; - edges.remove(edge); - if(edges.size() == 0){ - edges = null; - } - } - public HEdge findNextEdge(GraphPoint nextVert){ - for(HEdge e:edges){ - if(e.getNext().getGraphPoint() == nextVert){ - return e; - } - } - return null; - } - public HEdge findBoundEdge(){ - for(HEdge e:edges){ - if((e.getType() == HEdge.BOUNDARY) || (e.getType() == HEdge.HOLE)){ - return e; - } - } - return null; - } - public HEdge findPrevEdge(GraphPoint prevVert){ - for(HEdge e:edges){ - if(e.getPrev().getGraphPoint() == prevVert){ - return e; - } - } - return null; - } - - public boolean isBoundaryContained() { - return boundaryContained; - } - - public void setBoundaryContained(boolean boundaryContained) { - this.boundaryContained = boundaryContained; - } -} diff --git a/src/jogamp/graph/curve/tess/GraphVertex.java b/src/jogamp/graph/curve/tess/GraphVertex.java new file mode 100644 index 000000000..a474a002e --- /dev/null +++ b/src/jogamp/graph/curve/tess/GraphVertex.java @@ -0,0 +1,120 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.graph.curve.tess; + +import java.util.ArrayList; + +import com.jogamp.graph.geom.Vertex; + +public class GraphVertex { + private T point; + private ArrayList> edges = null; + private boolean boundaryContained = false; + + public GraphVertex(T point) { + this.point = point; + } + + public T getPoint() { + return point; + } + + public float getX(){ + return point.getX(); + } + + public float getY(){ + return point.getY(); + } + + public float getZ(){ + return point.getZ(); + } + public float[] getCoord() { + return point.getCoord(); + } + + public void setPoint(T point) { + this.point = point; + } + + public ArrayList> getEdges() { + return edges; + } + + public void setEdges(ArrayList> edges) { + this.edges = edges; + } + + public void addEdge(HEdge edge){ + if(edges == null){ + edges = new ArrayList>(); + } + edges.add(edge); + } + public void removeEdge(HEdge edge){ + if(edges == null) + return; + edges.remove(edge); + if(edges.size() == 0){ + edges = null; + } + } + public HEdge findNextEdge(GraphVertex nextVert){ + for(HEdge e:edges){ + if(e.getNext().getGraphPoint() == nextVert){ + return e; + } + } + return null; + } + public HEdge findBoundEdge(){ + for(HEdge e:edges){ + if((e.getType() == HEdge.BOUNDARY) || (e.getType() == HEdge.HOLE)){ + return e; + } + } + return null; + } + public HEdge findPrevEdge(GraphVertex prevVert){ + for(HEdge e:edges){ + if(e.getPrev().getGraphPoint() == prevVert){ + return e; + } + } + return null; + } + + public boolean isBoundaryContained() { + return boundaryContained; + } + + public void setBoundaryContained(boolean boundaryContained) { + this.boundaryContained = boundaryContained; + } +} diff --git a/src/jogamp/graph/curve/tess/HEdge.java b/src/jogamp/graph/curve/tess/HEdge.java index acb32cb4d..5635e2c31 100644 --- a/src/jogamp/graph/curve/tess/HEdge.java +++ b/src/jogamp/graph/curve/tess/HEdge.java @@ -27,28 +27,28 @@ */ package jogamp.graph.curve.tess; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; -public class HEdge { +public class HEdge { public static int BOUNDARY = 3; public static int INNER = 1; public static int HOLE = 2; - private GraphPoint vert; + private GraphVertex vert; private HEdge prev = null; private HEdge next = null; private HEdge sibling = null; private int type = BOUNDARY; private Triangle triangle = null; - public HEdge(GraphPoint vert, int type) { + public HEdge(GraphVertex vert, int type) { this.vert = vert; this.type = type; } - public HEdge(GraphPoint vert, HEdge prev, HEdge next, HEdge 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,7 +56,7 @@ public class HEdge { this.type = type; } - public HEdge(GraphPoint vert, HEdge prev, HEdge next, HEdge sibling, int type, + public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type, Triangle triangle) { this.vert = vert; this.prev = prev; @@ -66,11 +66,11 @@ public class HEdge { this.triangle = triangle; } - public GraphPoint getGraphPoint() { + public GraphVertex getGraphPoint() { return vert; } - public void setVert(GraphPoint vert) { + public void setVert(GraphVertex vert) { this.vert = vert; } @@ -114,12 +114,12 @@ public class HEdge { this.triangle = triangle; } - public static void connect(HEdge first, HEdge next){ + public static void connect(HEdge first, HEdge next){ first.setNext(next); next.setPrev(first); } - public static void makeSiblings(HEdge first, HEdge second){ + public static 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 caebd64e4..e4553968b 100644 --- a/src/jogamp/graph/curve/tess/Loop.java +++ b/src/jogamp/graph/curve/tess/Loop.java @@ -32,10 +32,10 @@ import java.util.ArrayList; import jogamp.graph.math.VectorFloatUtil; import com.jogamp.graph.geom.AABBox; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; -public class Loop { +public class Loop { private HEdge root = null; private AABBox box = new AABBox(); private GraphOutline initialOutline = null; @@ -66,9 +66,9 @@ public class Loop { return null; } - GraphPoint v1 = root.getGraphPoint(); - GraphPoint v2 = next1.getGraphPoint(); - GraphPoint v3 = next2.getGraphPoint(); + GraphVertex v1 = root.getGraphPoint(); + GraphVertex v2 = next1.getGraphPoint(); + GraphVertex v3 = next2.getGraphPoint(); HEdge v3Edge = new HEdge(v3, HEdge.INNER); @@ -98,7 +98,7 @@ public class Loop { * @param direction requested winding of edges (CCW or CW) */ private HEdge initFromPolyline(GraphOutline outline, int direction){ - ArrayList> vertices = outline.getGraphPoint(); + ArrayList> vertices = outline.getGraphPoint(); if(vertices.size()<3) { throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size()); @@ -120,7 +120,7 @@ public class Loop { } while(index != max){ - GraphPoint v1 = vertices.get(index); + GraphVertex v1 = vertices.get(index); box.resize(v1.getX(), v1.getY(), v1.getZ()); HEdge edge = new HEdge(v1, edgeType); @@ -162,7 +162,7 @@ public class Loop { /**needed to generate vertex references.*/ initFromPolyline(polyline, VectorFloatUtil.CW); - GraphPoint v3 = locateClosestVertex(polyline); + GraphVertex v3 = locateClosestVertex(polyline); HEdge v3Edge = v3.findBoundEdge(); HEdge v3EdgeP = v3Edge.getPrev(); HEdge crossEdge = new HEdge(root.getGraphPoint(), HEdge.INNER); @@ -186,22 +186,22 @@ public class Loop { * to search for closestvertices * @return the vertex that is closest to the newly set root Hedge. */ - private GraphPoint locateClosestVertex(GraphOutline polyline) { + private GraphVertex locateClosestVertex(GraphOutline polyline) { HEdge closestE = null; - GraphPoint closestV = null; + GraphVertex closestV = null; float minDistance = Float.MAX_VALUE; boolean inValid = false; - ArrayList> initVertices = initialOutline.getGraphPoint(); - ArrayList> vertices = polyline.getGraphPoint(); + ArrayList> initVertices = initialOutline.getGraphPoint(); + ArrayList> vertices = polyline.getGraphPoint(); for(int i=0; i< initVertices.size()-1; i++){ - GraphPoint v = initVertices.get(i); - GraphPoint nextV = initVertices.get(i+1); - for(GraphPoint cand:vertices){ + GraphVertex v = initVertices.get(i); + GraphVertex nextV = initVertices.get(i+1); + for(GraphVertex cand:vertices){ float distance = VectorFloatUtil.computeLength(v.getCoord(), cand.getCoord()); if(distance < minDistance){ - for (GraphPoint vert:vertices){ + for (GraphVertex vert:vertices){ if(vert == v || vert == nextV || vert == cand) continue; inValid = VectorFloatUtil.inCircle(v.getPoint(), nextV.getPoint(), diff --git a/src/jogamp/graph/curve/text/GlyphShape.java b/src/jogamp/graph/curve/text/GlyphShape.java index 8e16de1a4..78ae7396c 100644 --- a/src/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogamp/graph/curve/text/GlyphShape.java @@ -32,8 +32,7 @@ import java.util.ArrayList; import jogamp.graph.geom.plane.PathIterator; import com.jogamp.graph.geom.Line; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.curve.OutlineShape; @@ -48,7 +47,7 @@ public class GlyphShape { /** Create a new Glyph shape * based on Parametric curve control polyline */ - public GlyphShape(Point.Factory factory){ + public GlyphShape(Vertex.Factory factory){ shape = new OutlineShape(factory); } @@ -57,7 +56,7 @@ public class GlyphShape { * * @see PathIterator */ - public GlyphShape(Point.Factory factory, PathIterator pathIterator){ + public GlyphShape(Vertex.Factory factory, PathIterator pathIterator){ this(factory); if(null != pathIterator){ @@ -72,9 +71,9 @@ public class GlyphShape { shape.transformOutlines(OutlineShape.QUADRATIC_NURBS); } - public final Point.Factory pointFactory() { return shape.pointFactory(); } + public final Vertex.Factory pointFactory() { return shape.pointFactory(); } - private void addVertexToLastOutline(PointTex vertex){ + private void addVertexToLastOutline(Vertex vertex){ shape.addVertex(vertex); } @@ -83,40 +82,40 @@ public class GlyphShape { if(!shape.getLastOutline().isEmpty()){ shape.addEmptyOutline(); } - PointTex vert = pointFactory().create(coords[0],coords[1]); + Vertex vert = pointFactory().create(coords[0],coords[1]); vert.setOnCurve(true); addVertexToLastOutline(vert); numVertices++; } else if(segmentType == PathIterator.SEG_LINETO){ - PointTex vert1 = pointFactory().create(coords[0],coords[1]); + Vertex vert1 = pointFactory().create(coords[0],coords[1]); vert1.setOnCurve(true); addVertexToLastOutline(vert1); numVertices++; } else if(segmentType == PathIterator.SEG_QUADTO){ - PointTex vert1 = pointFactory().create(coords[0],coords[1]); + Vertex vert1 = pointFactory().create(coords[0],coords[1]); vert1.setOnCurve(false); addVertexToLastOutline(vert1); - PointTex vert2 = pointFactory().create(coords[2],coords[3]); + Vertex vert2 = pointFactory().create(coords[2],coords[3]); vert2.setOnCurve(true); addVertexToLastOutline(vert2); numVertices+=2; } else if(segmentType == PathIterator.SEG_CUBICTO){ - PointTex vert1 = pointFactory().create(coords[0],coords[1]); + Vertex vert1 = pointFactory().create(coords[0],coords[1]); vert1.setOnCurve(false); addVertexToLastOutline(vert1); - PointTex vert2 = pointFactory().create(coords[2],coords[3]); + Vertex vert2 = pointFactory().create(coords[2],coords[3]); vert2.setOnCurve(false); addVertexToLastOutline(vert2); - PointTex vert3 = pointFactory().create(coords[4],coords[5]); + Vertex vert3 = pointFactory().create(coords[4],coords[5]); vert3.setOnCurve(true); addVertexToLastOutline(vert3); @@ -150,21 +149,21 @@ public class GlyphShape { * @param sharpness sharpness of the curved regions default = 0.5 * @return ArrayList of triangles which define this shape */ - public ArrayList> triangulate(float sharpness){ + public ArrayList> triangulate(float sharpness){ return shape.triangulate(sharpness); } /** Get the list of Vertices of this Object * @return arrayList of Vertices */ - public ArrayList getVertices(){ + public ArrayList getVertices(){ return shape.getVertices(); } /** Get the list of AA lines defined by this object * @return arraylist of lines */ - public ArrayList> getLines(){ + public ArrayList> getLines(){ return shape.getLines(); } } diff --git a/src/jogamp/graph/curve/text/GlyphString.java b/src/jogamp/graph/curve/text/GlyphString.java index 75d7e4402..a7418c6de 100644 --- a/src/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogamp/graph/curve/text/GlyphString.java @@ -29,10 +29,9 @@ package jogamp.graph.curve.text; import java.util.ArrayList; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.geom.opengl.Vertex; +import com.jogamp.graph.geom.opengl.SVertex; import javax.media.opengl.GLContext; @@ -47,26 +46,26 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderState; public class GlyphString { - private final Point.Factory pointFactory; + private final Vertex.Factory pointFactory; private ArrayList glyphs = new ArrayList(); private String str = ""; private String fontname = ""; private Region region; - private Vertex origin = new Vertex(); + private SVertex origin = new SVertex(); /** Create a new GlyphString object * @param fontname the name of the font that this String is * associated with * @param str the string object */ - public GlyphString(Point.Factory factory, String fontname, String str){ + public GlyphString(Vertex.Factory factory, String fontname, String str){ pointFactory = factory; this.fontname = fontname; this.str = str; } - public final Point.Factory pointFactory() { return pointFactory; } + public final Vertex.Factory pointFactory() { return pointFactory; } public void addGlyphShape(GlyphShape glyph){ glyphs.add(glyph); @@ -95,10 +94,10 @@ public class GlyphString { } } - private ArrayList> initializeTriangles(float sharpness){ - ArrayList> triangles = new ArrayList>(); + private ArrayList> initializeTriangles(float sharpness){ + ArrayList> triangles = new ArrayList>(); for(GlyphShape glyph:glyphs){ - ArrayList> tris = glyph.triangulate(sharpness); + ArrayList> tris = glyph.triangulate(sharpness); triangles.addAll(tris); } return triangles; @@ -113,13 +112,13 @@ public class GlyphString { region = RegionFactory.create(context, st, type); region.setFlipped(true); - ArrayList> tris = initializeTriangles(shaprness); + ArrayList> tris = initializeTriangles(shaprness); region.addTriangles(tris); int numVertices = region.getNumVertices(); for(GlyphShape glyph:glyphs){ - ArrayList gVertices = glyph.getVertices(); - for(PointTex vert:gVertices){ + ArrayList gVertices = glyph.getVertices(); + for(Vertex vert:gVertices){ vert.setId(numVertices++); } region.addVertices(gVertices); @@ -152,7 +151,7 @@ public class GlyphString { /** Get the Origion of this GlyphString * @return */ - public PointTex getOrigin() { + public Vertex getOrigin() { return origin; } diff --git a/src/jogamp/graph/font/typecast/TypecastFont.java b/src/jogamp/graph/font/typecast/TypecastFont.java index d054635e4..b44a7d86b 100644 --- a/src/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogamp/graph/font/typecast/TypecastFont.java @@ -44,13 +44,13 @@ import net.java.dev.typecast.ot.table.ID; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.AABBox; -import com.jogamp.graph.geom.PointTex; -import com.jogamp.graph.geom.Point; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex; class TypecastFont implements FontInt { static final boolean DEBUG = false; - final Point.Factory pointFactory; + final Vertex.Factory pointFactory; final OTFontCollection fontset; final OTFont font; final int size; @@ -60,7 +60,7 @@ class TypecastFont implements FontInt { // final IntIntHashMap char2Code; IntObjectHashMap char2Glyph; - public static TypecastFont create(Point.Factory factory, String name, int size) { + public static TypecastFont create(Vertex.Factory factory, String name, int size) { String path = JavaFontLoader.getByName(name); OTFontCollection fontset; try { @@ -72,7 +72,7 @@ class TypecastFont implements FontInt { return null; } - public TypecastFont(Point.Factory factory, OTFontCollection fontset, int size) { + public TypecastFont(Vertex.Factory factory, OTFontCollection fontset, int size) { this.pointFactory = factory; this.fontset = fontset; this.font = fontset.getFont(0); diff --git a/src/jogamp/graph/font/typecast/TypecastFontFactory.java b/src/jogamp/graph/font/typecast/TypecastFontFactory.java index f66772029..6179986fe 100644 --- a/src/jogamp/graph/font/typecast/TypecastFontFactory.java +++ b/src/jogamp/graph/font/typecast/TypecastFontFactory.java @@ -32,15 +32,15 @@ import java.util.Map; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.geom.Point.Factory; -import com.jogamp.graph.geom.PointTex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.geom.Vertex; public class TypecastFontFactory implements FontFactory { Map fonts = new HashMap(); - public Font createFont(Factory factory, String name, int size) { + public Font createFont(Factory factory, String name, int size) { Font result = fonts.get(name + ":"+size); if (result == null) { result = TypecastFont.create(factory, name, size); @@ -52,7 +52,7 @@ public class TypecastFontFactory implements FontFactory { } - public Font createFont(Factory factory, + public Font createFont(Factory factory, String[] families, String style, String variant, diff --git a/src/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogamp/graph/font/typecast/TypecastRenderer.java index 3813eb474..74e5cd604 100644 --- a/src/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogamp/graph/font/typecast/TypecastRenderer.java @@ -31,8 +31,8 @@ import jogamp.graph.geom.plane.AffineTransform; import jogamp.graph.geom.plane.Path2D; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.PointTex; -import com.jogamp.graph.geom.Point.Factory; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; import net.java.dev.typecast.ot.Point; import net.java.dev.typecast.ot.OTGlyph; @@ -43,7 +43,7 @@ import net.java.dev.typecast.ot.OTGlyph; */ public class TypecastRenderer { - public static void getOutline(Factory factory, TypecastFont font, + public static void getOutline(Factory factory, TypecastFont font, String string, AffineTransform transform, Path2D[] p) { if (string == null) { diff --git a/src/jogamp/graph/geom/plane/AffineTransform.java b/src/jogamp/graph/geom/plane/AffineTransform.java index 02fb9993d..de13ff9de 100644 --- a/src/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogamp/graph/geom/plane/AffineTransform.java @@ -25,8 +25,8 @@ import java.io.Serializable; import jogamp.graph.math.MathFloat; import org.apache.harmony.misc.HashCode; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.Point.Factory; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; public class AffineTransform implements Cloneable, Serializable { @@ -55,7 +55,7 @@ public class AffineTransform implements Cloneable, Serializable { */ static final float ZERO = (float) 1E-10; - private final Point.Factory pointFactory; + private final Vertex.Factory pointFactory; /** * The values of transformation matrix @@ -72,7 +72,7 @@ public class AffineTransform implements Cloneable, Serializable { */ transient int type; - public AffineTransform(Factory factory) { + public AffineTransform(Factory factory) { pointFactory = factory; type = TYPE_IDENTITY; m00 = m11 = 1.0f; @@ -90,7 +90,7 @@ public class AffineTransform implements Cloneable, Serializable { this.m12 = t.m12; } - public AffineTransform(Point.Factory factory, float m00, float m10, float m01, float m11, float m02, float m12) { + public AffineTransform(Vertex.Factory factory, float m00, float m10, float m01, float m11, float m02, float m12) { pointFactory = factory; this.type = TYPE_UNKNOWN; this.m00 = m00; @@ -101,7 +101,7 @@ public class AffineTransform implements Cloneable, Serializable { this.m12 = m12; } - public AffineTransform(Point.Factory factory, float[] matrix) { + public AffineTransform(Vertex.Factory factory, float[] matrix) { pointFactory = factory; this.type = TYPE_UNKNOWN; m00 = matrix[0]; @@ -302,31 +302,31 @@ public class AffineTransform implements Cloneable, Serializable { type = TYPE_UNKNOWN; } - public static AffineTransform getTranslateInstance(Point.Factory factory, float mx, float my) { + public static AffineTransform getTranslateInstance(Vertex.Factory factory, float mx, float my) { AffineTransform t = new AffineTransform(factory); t.setToTranslation(mx, my); return t; } - public static AffineTransform getScaleInstance(Point.Factory factory, float scx, float scY) { + public static AffineTransform getScaleInstance(Vertex.Factory factory, float scx, float scY) { AffineTransform t = new AffineTransform(factory); t.setToScale(scx, scY); return t; } - public static AffineTransform getShearInstance(Point.Factory factory, float shx, float shy) { + public static AffineTransform getShearInstance(Vertex.Factory factory, float shx, float shy) { AffineTransform t = new AffineTransform(factory); t.setToShear(shx, shy); return t; } - public static AffineTransform getRotateInstance(Point.Factory factory, float angle) { + public static AffineTransform getRotateInstance(Vertex.Factory factory, float angle) { AffineTransform t = new AffineTransform(factory); t.setToRotation(angle); return t; } - public static AffineTransform getRotateInstance(Point.Factory factory, float angle, float x, float y) { + public static AffineTransform getRotateInstance(Vertex.Factory factory, float angle, float x, float y) { AffineTransform t = new AffineTransform(factory); t.setToRotation(angle, x, y); return t; @@ -354,7 +354,7 @@ public class AffineTransform implements Cloneable, Serializable { /** * Multiply matrix of two AffineTransform objects. - * The first argument's {@link Point.Factory} is being used. + * The first argument's {@link Vertex.Factory} is being used. * * @param t1 - the AffineTransform object is a multiplicand * @param t2 - the AffineTransform object is a multiplier @@ -394,7 +394,7 @@ public class AffineTransform implements Cloneable, Serializable { ); } - public Point transform(Point src, Point dst) { + public Vertex transform(Vertex src, Vertex dst) { if (dst == null) { dst = pointFactory.create(); } @@ -406,12 +406,12 @@ public class AffineTransform implements Cloneable, Serializable { return dst; } - public void transform(Point[] src, int srcOff, Point[] dst, int dstOff, int length) { + public void transform(Vertex[] src, int srcOff, Vertex[] dst, int dstOff, int length) { while (--length >= 0) { - Point srcPoint = src[srcOff++]; + Vertex srcPoint = src[srcOff++]; float x = srcPoint.getX(); float y = srcPoint.getY(); - Point dstPoint = dst[dstOff]; + Vertex dstPoint = dst[dstOff]; if (dstPoint == null) { throw new IllegalArgumentException("dst["+dstOff+"] is null"); } @@ -437,7 +437,7 @@ public class AffineTransform implements Cloneable, Serializable { } } - public Point deltaTransform(Point src, Point dst) { + public Vertex deltaTransform(Vertex src, Vertex dst) { if (dst == null) { dst = pointFactory.create(); } @@ -458,7 +458,7 @@ public class AffineTransform implements Cloneable, Serializable { } } - public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransformException { + public Vertex inverseTransform(Vertex src, Vertex dst) throws NoninvertibleTransformException { float det = getDeterminant(); if (MathFloat.abs(det) < ZERO) { throw new NoninvertibleTransformException(determinantIsZero); diff --git a/src/jogamp/graph/geom/plane/Path2D.java b/src/jogamp/graph/geom/plane/Path2D.java index cfb966ac4..e25ae0e84 100644 --- a/src/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogamp/graph/geom/plane/Path2D.java @@ -22,8 +22,8 @@ package jogamp.graph.geom.plane; import java.util.NoSuchElementException; import com.jogamp.graph.geom.AABBox; -import com.jogamp.graph.geom.Point; -import com.jogamp.graph.geom.opengl.Vertex; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.opengl.SVertex; import jogamp.graph.math.plane.Crossing; @@ -300,7 +300,7 @@ public final class Path2D implements Cloneable { } } - public Vertex getCurrentPoint() { + public SVertex getCurrentPoint() { if (typeSize == 0) { return null; } @@ -315,7 +315,7 @@ public final class Path2D implements Cloneable { j -= pointShift[type]; } } - return new Vertex(points[j], points[j + 1]); + return new SVertex(points[j], points[j + 1]); } public void reset() { @@ -391,7 +391,7 @@ public final class Path2D implements Cloneable { return cross == Crossing.CROSSING || isInside(cross); } - public boolean contains(Point p) { + public boolean contains(Vertex p) { return contains(p.getX(), p.getY()); } diff --git a/src/jogamp/graph/math/VectorFloatUtil.java b/src/jogamp/graph/math/VectorFloatUtil.java index 172cacd09..b2b9a8ee8 100755 --- a/src/jogamp/graph/math/VectorFloatUtil.java +++ b/src/jogamp/graph/math/VectorFloatUtil.java @@ -29,7 +29,7 @@ package jogamp.graph.math; import java.util.ArrayList; -import com.jogamp.graph.geom.Point; +import com.jogamp.graph.geom.Vertex; public class VectorFloatUtil { @@ -247,7 +247,7 @@ public class VectorFloatUtil { * @return true if the vertex d is inside the circle defined by the * vertices a, b, c. from paper by Guibas and Stolfi (1985). */ - public static boolean inCircle(Point a, Point b, Point c, Point d){ + public static boolean inCircle(Vertex a, Vertex b, Vertex c, Vertex d){ return (a.getX() * a.getX() + a.getY() * a.getY()) * triArea(b, c, d) - (b.getX() * b.getX() + b.getY() * b.getY()) * triArea(a, c, d) + (c.getX() * c.getX() + c.getY() * c.getY()) * triArea(a, b, d) - @@ -261,7 +261,7 @@ public class VectorFloatUtil { * @return compute twice the area of the oriented triangle (a,b,c), the area * is positive if the triangle is oriented counterclockwise. */ - public static float triArea(Point a, Point b, Point c){ + public static float triArea(Vertex a, Vertex b, Vertex c){ return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX()); } @@ -271,7 +271,7 @@ public class VectorFloatUtil { * @param c third vertex * @return true if the points a,b,c are in a ccw order */ - public static boolean ccw(Point a, Point b, Point c){ + public static boolean ccw(Vertex a, Vertex b, Vertex c){ return triArea(a,b,c) > 0; } @@ -279,7 +279,7 @@ public class VectorFloatUtil { * @param vertices * @return positve area if ccw else negative area value */ - public static float area(ArrayList vertices) { + public static float area(ArrayList vertices) { int n = vertices.size(); float area = 0.0f; for (int p = n - 1, q = 0; q < n; p = q++) -- cgit v1.2.3