From ea0059f01866bd6257d4a06164db1b6c906a2949 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 28 Feb 2014 12:12:58 +0100 Subject: Bug 801: Outline.setClosed(boolean [closed->closeTail]): Always close, but allow to either close-tail or head; OutlineShape/Triangulator: Pass 'sharpness' (very little effect though) --- .../com/jogamp/graph/curve/OutlineShape.java | 37 ++++++++++++++++++---- .../com/jogamp/graph/curve/tess/Triangulator.java | 3 +- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve') diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index f4cdffd5e..44a8e7384 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -133,6 +133,8 @@ public class OutlineShape implements Comparable { /** dirty bits DIRTY_BOUNDS */ private int dirtyBits; + private float sharpness; + /** Create a new Outline based Shape */ public OutlineShape(Vertex.Factory factory) { @@ -144,6 +146,16 @@ public class OutlineShape implements Comparable { this.triangles = new ArrayList(); this.vertices = new ArrayList(); this.dirtyBits = 0; + this.sharpness = 0.5f; + } + + public float getSharpness() { return sharpness; } + + public void setSharpness(final float s) { + if( this.sharpness != s ) { + clearCache(); + sharpness=s; + } } /** Clears all data and reset all states as if this instance was newly created */ @@ -157,6 +169,13 @@ public class OutlineShape implements Comparable { dirtyBits = 0; } + /** Clears cached triangulated data, i.e. {@link #getTriangles(VerticesState)} and {@link #getVertices()}. */ + public void clearCache() { + vertices.clear(); + triangles.clear(); + dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES; + } + /** * Returns the associated vertex factory of this outline shape * @return Vertex.Factory object @@ -236,7 +255,7 @@ public class OutlineShape implements Comparable { /** * Insert the {@link OutlineShape} elements of type {@link Outline}, .. at the end of this shape, * using {@link #addOutline(Outline)} for each element. - *

Closes the current last outline via {@link #closeLastOutline()} before adding the new ones.

+ *

Closes the current last outline via {@link #closeLastOutline(boolean)} before adding the new ones.

* @param outlineShape OutlineShape elements to be added. * @throws NullPointerException if the {@link OutlineShape} is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber()) @@ -245,7 +264,7 @@ public class OutlineShape implements Comparable { if (null == outlineShape) { throw new NullPointerException("OutlineShape is null"); } - closeLastOutline(); + closeLastOutline(true); for(int i=0; i { /** * Closes the last outline in the shape. - *

If last vertex is not equal to first vertex. - * A new temp vertex is added at the end which - * is equal to the first.

+ *

+ * Checks whether the last vertex equals to the first of the last outline. + * If not equal, it either appends a clone of the first vertex + * or prepends a clone of the last vertex, depending on closeTail. + *

+ * @param closeTail if true, a clone of the first vertex will be appended, + * otherwise a clone of the last vertex will be prepended. */ - public final void closeLastOutline() { + public final void closeLastOutline(boolean closeTail) { if( getLastOutline().setClosed(true) ) { dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES; } @@ -588,7 +611,7 @@ public class OutlineShape implements Comparable { triangles.clear(); final Triangulator triangulator2d = Triangulation.create(); for(int index = 0; index sink, Outline outline); + public void addCurve(List sink, Outline outline, float sharpness); /** Generate the triangulation of the provided * List of {@link Outline}s -- cgit v1.2.3