org.jdelaunay.delaunay
Class ConstrainedMesh

java.lang.Object
  extended by org.jdelaunay.delaunay.ConstrainedMesh
All Implemented Interfaces:
Serializable

public class ConstrainedMesh
extends Object
implements Serializable

This class is used to compute the constrained delaunay triangulation on a set of points and constraint edges. The constraints can be validated before the triangulation.

After the processing of the mesh with processDelaunay, the ConstrainedMesh can be identified with three set of data, plus its input constraint edges. The three sets are :

* The points of the mesh.
* The edges of the mesh.
* The triangles of the mesh.

When processing elevation data, you can use the removeFlatTriangles method to be sure that none of the triangles are horizontal. This can be useful when the triangulation is supposed to be used for hydrology.

Author:
Alexis Guéganno
See Also:
Serialized Form

Field Summary
static int MAXITER
           
static int MIN_POINTS_NUMBER
           
static int REFINEMENT_MAX_AREA
           
static int REFINEMENT_MIN_ANGLE
           
static int REFINEMENT_OBTUSE_ANGLE
           
static int REFINEMENT_SOFT_INTERPOLATE
           
 
Constructor Summary
ConstrainedMesh()
          Build a new, empty, ConstrainedMesh.
 
Method Summary
 void addConstraintEdge(DEdge e)
          Add an edge to the list of constraint edges.
 void addEdge(DEdge e)
          Add an edge to the list of edges.
 void addPoint(DPoint point)
          Add a new point in the list that will be used to perform the triangulation.
 void addTriangle(DTriangle triangle)
          Add a triangle to the current constrained mesh
 boolean containsTriangle(DTriangle tri)
          Return true if tri is one of the triangles of this mesh.
 void dataQualification(double epsilon)
          Ensure points are at least at epsilon from other points NB : points are supposed to be already sorted
 void displayObject(Graphics g)
          Draw Mesh in the JPanel : triangles and edges.
 void forceConstraintIntegrity()
          This method will force the integrity of the constraints used to compute the delaunay triangulation.
 com.vividsolutions.jts.geom.Envelope getBoundingBox()
          Get the bounding box of this mesh.
 List<DEdge> getConstraintEdges()
          Get the list of edges that are used as constraints during the triangulation
 List<DEdge> getConstraintFromLPVertical(DPoint left)
          Get the list of constraint edges whose left point is left, vertically sorted.
 List<DEdge> getConstraintsFromLeftPoint(DPoint left)
          Get the list of constraint edges whose left point is left.
 List<DEdge> getEdges()
          Get the list of edges
 List<DPoint> getExtensionPoints()
          Get the extension points that would be added to the mesh while computing DT or CDT with the current set of points.
 DPoint getPoint(double x, double y, double z)
          Try to retrieve the point (x,y,z) in the points' structure.
 List<DPoint> getPoints()
          Get the points contained in this mesh
 double getPrecision()
          Get the precision
 double getTolerance()
          Get the value used to compute the minimum distance between two points
 List<DTriangle> getTriangleList()
          Get the list of triangles already computed and added in this mesh
 Map<Integer,Integer> getWeights()
          Get the table that currently contains the weights used to attribute the Z value when processing the intersection.
 int insertEdgeVerticalList(DEdge edge, List<DEdge> edgeList, double abs)
          This method will insert a new DEdge in a vertically sorted list, as described in sortEdgesVertically.
 DEdge insertIfNotEncroached(DPoint pt, DTriangle container, double minLength)
          Insert pt in container only if it does not create a new encroached edge in the mesh.
 void insertPointInTriangle(DPoint pt, DTriangle container, double minLength)
          Insert the point pt in the triangle container.
 DEdge insertTriangleCircumCenter(DTriangle tri, boolean revertible, double minLength)
          Insert the circumcenter of the given triangle in the mesh.
 boolean intersectsExistingEdges(DEdge edge)
          Checks that edge does not intersect the existing edges of the mesh.
 boolean isMeshComputed()
          Can be used to know if the mesh has been computed or not
 boolean isVerbose()
          Says if the verbose mode is activated or not
 int listContainsPoint(DPoint p)
          This methods will search the point p in the list.
 void processDelaunay()
          Generate the Delaunay's triangularization with a flip-flap algorithm.
 void refineMesh(double minLength, InsertionEvaluator ev)
          Refine the mesh, using the Ruppert's algorithm.
 void refineTriangles(double minLength, InsertionEvaluator ev)
          Refine the mesh, using a derivate of the Ruppert algorithm.
 void removeEdge(DEdge e)
          Remove an DEdge from the list of edges.
 void removeFlatTriangles()
          This operation remove the flat triangles by inserting new points in the mesh, that come from the skeleton of the already computed mesh.
 void removeTriangle(DTriangle tri)
          Remove a triangle from the list of triangles
 int searchEdge(DEdge edge)
          Search an edge in the list of edges.
 void setConstraintEdges(ArrayList<DEdge> constraint)
          Set the list of edges that are used as constraints during triangulation
 void setEdges(List<DEdge> inEdges)
          Set the list of edges
 void setPoints(List<DPoint> pts)
          Set the list of points to be used during the triangulation If using this method.
 void setPrecision(double precision)
          Set the precision
 void setTolerance(double tolerance)
          Set the value used to compute the minimum distance between two points
 void setVerbose(boolean verb)
          Set the verbosity level
 void setWeights(Map<Integer,Integer> weights)
          Set the table of weights that are used when processing the intersection between edges, during the call to forceConstraintsIntegrity().
 List<DEdge> sortEdgesLeft(List<DEdge> inputList)
          This method will sort the edges using the coordinates of the left point of the edges.
 void sortEdgesVertically(List<DEdge> edgeList, double abs)
          This method will sort the edges contained in the ArrayList list by considering their intersection point with the line of equation x=abs, where a is given in parameter.
 void sortEdgesVertically(List<DEdge> edgeList, DPoint p)
          This method will vertically sort the edges in edgeList, using the absciss of the point p given in parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_POINTS_NUMBER

public static final int MIN_POINTS_NUMBER
See Also:
Constant Field Values

MAXITER

public static final int MAXITER
See Also:
Constant Field Values

REFINEMENT_MAX_AREA

public static final int REFINEMENT_MAX_AREA
See Also:
Constant Field Values

REFINEMENT_MIN_ANGLE

public static final int REFINEMENT_MIN_ANGLE
See Also:
Constant Field Values

REFINEMENT_SOFT_INTERPOLATE

public static final int REFINEMENT_SOFT_INTERPOLATE
See Also:
Constant Field Values

REFINEMENT_OBTUSE_ANGLE

public static final int REFINEMENT_OBTUSE_ANGLE
See Also:
Constant Field Values
Constructor Detail

ConstrainedMesh

public ConstrainedMesh()
Build a new, empty, ConstrainedMesh. It does not contain any information that could be used to build a triangulation. You must fill it with the points and edges you need before launching a processDelaunay() operation.

Method Detail

getConstraintEdges

public final List<DEdge> getConstraintEdges()
Get the list of edges that are used as constraints during the triangulation

Returns:
The constraint edges, in a List.

setConstraintEdges

public final void setConstraintEdges(ArrayList<DEdge> constraint)
                              throws DelaunayError
Set the list of edges that are used as constraints during triangulation

Parameters:
constraint -
Throws:
DelaunayError

addConstraintEdge

public final void addConstraintEdge(DEdge e)
                             throws DelaunayError
Add an edge to the list of constraint edges.

Parameters:
e - the edge we want to add
Throws:
DelaunayError

getEdges

public final List<DEdge> getEdges()
Get the list of edges

Returns:
The edges of the mesh in a List.

setEdges

public final void setEdges(List<DEdge> inEdges)
                    throws DelaunayError
Set the list of edges

Parameters:
inEdges -
Throws:
DelaunayError

addEdge

public final void addEdge(DEdge e)
Add an edge to the list of edges.

Parameters:
e - the edge we want to add

removeEdge

public final void removeEdge(DEdge e)
Remove an DEdge from the list of edges.

Parameters:
e -

sortEdgesLeft

public final List<DEdge> sortEdgesLeft(List<DEdge> inputList)
This method will sort the edges using the coordinates of the left point of the edges.

Returns:
A let sorted list.

searchEdge

public final int searchEdge(DEdge edge)
Search an edge in the list of edges.

Parameters:
edge -
Returns:
The index of the edge in the list of edges, or (-1-index) if edge is not in the list, and where index would be the index of the edge if it was in the list

getPrecision

public final double getPrecision()
Get the precision

Returns:
precision

setPrecision

public final void setPrecision(double precision)
Set the precision

Parameters:
precision -

getTolerance

public final double getTolerance()
Get the value used to compute the minimum distance between two points

Returns:
tolerance.

setTolerance

public final void setTolerance(double tolerance)
Set the value used to compute the minimum distance between two points

Parameters:
tolerance -

getTriangleList

public final List<DTriangle> getTriangleList()
Get the list of triangles already computed and added in this mesh

Returns:
The triancle packaged in a List.

addTriangle

public final void addTriangle(DTriangle triangle)
Add a triangle to the current constrained mesh

Parameters:
triangle -

containsTriangle

public final boolean containsTriangle(DTriangle tri)
Return true if tri is one of the triangles of this mesh.

BE EXTREMELY CAREFUL ! : this method will be completely inefficient, as the triangle's data structure is not kept sorted. To obtain a data structure that can be queried efficiently, sort the triangle's data structure (as triangle are sortable, cf DTriangle), or put them in an external spatial index (RTree/R+Tree)

Parameters:
tri -
Returns:
true if the mesh contains the triangle tri.

removeTriangle

public final void removeTriangle(DTriangle tri)
Remove a triangle from the list of triangles

Parameters:
tri -

getPoints

public final List<DPoint> getPoints()
Get the points contained in this mesh

Returns:
The points of the mesh packaged in a List.

getPoint

public final DPoint getPoint(double x,
                             double y,
                             double z)
                      throws DelaunayError
Try to retrieve the point (x,y,z) in the points' structure.

Parameters:
x -
y -
z -
Returns:
The corresponding DPoint instance, if it exists in the mesh, null otherwise.
Throws:
DelaunayError

isMeshComputed

public final boolean isMeshComputed()
Can be used to know if the mesh has been computed or not

Returns:
true if the mesh has already been computed.

getBoundingBox

public final com.vividsolutions.jts.geom.Envelope getBoundingBox()
Get the bounding box of this mesh.

Returns:
The bounding box, as a JTS Envelope instance.

isVerbose

public final boolean isVerbose()
Says if the verbose mode is activated or not

Returns:
true if the verbosity has been activated.

setVerbose

public final void setVerbose(boolean verb)
Set the verbosity level

Parameters:
verb -

setPoints

public final void setPoints(List<DPoint> pts)
                     throws DelaunayError
Set the list of points to be used during the triangulation If using this method. All the exisiting points are removed, and replaced by the pts list. The input list is sorted, and the duplicates are removed silently.

Parameters:
pts -
Throws:
DelaunayError

addPoint

public final void addPoint(DPoint point)
                    throws DelaunayError
Add a new point in the list that will be used to perform the triangulation. The list of points is supposed to be sorted.

Parameters:
point -
Throws:
DelaunayError

getExtensionPoints

public final List<DPoint> getExtensionPoints()
                                      throws DelaunayError
Get the extension points that would be added to the mesh while computing DT or CDT with the current set of points.

Returns:
A set of two points. They will share the same x-coordinate, that is the max x-coordinate of the mesh minus 1. The first one will have the max y-coordinate (ie the max y-coordinate of the mesh plus 1), the second will have the min y-coordinate (ie the min y-coordinate minus 1).
Throws:
DelaunayError

listContainsPoint

public final int listContainsPoint(DPoint p)
This methods will search the point p in the list.

Parameters:
p -
Returns:
the index of p, -1 if it's not in the list

getWeights

public final Map<Integer,Integer> getWeights()
Get the table that currently contains the weights used to attribute the Z value when processing the intersection.

Returns:
The weights currently used in the mesh.

setWeights

public final void setWeights(Map<Integer,Integer> weights)
Set the table of weights that are used when processing the intersection between edges, during the call to forceConstraintsIntegrity(). Keys of the map match the property of each edge. Note that we are working on bits, and than the expected wlues will certainly be power of 2 (ie 1, 2, 4, 8...). Check the Element javadoc for more information about property

Parameters:
weights -

forceConstraintIntegrity

public final void forceConstraintIntegrity()
                                    throws DelaunayError
This method will force the integrity of the constraints used to compute the delaunay triangulation. After execution : * duplicates are removed * intersection points are added to the mesh points * secant edges are split This methos is supposed to be used just before a call to processDelaunay(). If you use it after, you will break the unicity of edges GID.

Throws:
DelaunayError

sortEdgesVertically

public final void sortEdgesVertically(List<DEdge> edgeList,
                                      DPoint p)
                               throws DelaunayError
This method will vertically sort the edges in edgeList, using the absciss of the point p given in parameter.

Parameters:
edgeList -
p -
Throws:
DelaunayError

sortEdgesVertically

public final void sortEdgesVertically(List<DEdge> edgeList,
                                      double abs)
                               throws DelaunayError
This method will sort the edges contained in the ArrayList list by considering their intersection point with the line of equation x=abs, where a is given in parameter.

Parameters:
edgeList -
abs -
Throws:
DelaunayError

insertEdgeVerticalList

public final int insertEdgeVerticalList(DEdge edge,
                                        List<DEdge> edgeList,
                                        double abs)
                                 throws DelaunayError
This method will insert a new DEdge in a vertically sorted list, as described in sortEdgesVertically. Be careful when using this method. In fact, you must use the same absciss here that the one which has been used when sorting the list.

Parameters:
edge -
edgeList -
Throws:
DelaunayError

intersectsExistingEdges

public final boolean intersectsExistingEdges(DEdge edge)
                                      throws DelaunayError
Checks that edge does not intersect the existing edges of the mesh.

Parameters:
edge -
Returns:
true if edge intersects an edge of the mesh.
Throws:
DelaunayError

getConstraintsFromLeftPoint

public final List<DEdge> getConstraintsFromLeftPoint(DPoint left)
Get the list of constraint edges whose left point is left.

Parameters:
left -
Returns:
Get the constraint of the mesh for which the leftmost point is left.

getConstraintFromLPVertical

public final List<DEdge> getConstraintFromLPVertical(DPoint left)
Get the list of constraint edges whose left point is left, vertically sorted.

Parameters:
left -
Returns:
All the DEdge for which left is the leftmost point. The DEdge are vertically sorted.

processDelaunay

public final void processDelaunay()
                           throws DelaunayError
Generate the Delaunay's triangularization with a flip-flap algorithm. Mesh must have been set. Triangulation can only be done once. Otherwise call reprocessDelaunay

Throws:
DelaunayError

removeFlatTriangles

public final void removeFlatTriangles()
                               throws DelaunayError
This operation remove the flat triangles by inserting new points in the mesh, that come from the skeleton of the already computed mesh. This method must be used after a previous call to processDelaunay(). This method will compute a triangulation again - the insertion is not incremental.

Throws:
DelaunayError

refineMesh

public final void refineMesh(double minLength,
                             InsertionEvaluator ev)
                      throws DelaunayError
Refine the mesh, using the Ruppert's algorithm.

Parameters:
minLength - The minimum length of an edge that could be inserted during the refinement.
Throws:
DelaunayError
IllegalArgumentException - if minLength is inferior or equal to 0

refineTriangles

public final void refineTriangles(double minLength,
                                  InsertionEvaluator ev)
                           throws DelaunayError
Refine the mesh, using a derivate of the Ruppert algorithm. We won't split any constraint edges here.

Parameters:
minLength - The minimum length of an edge that could be inserted during the refinement.
Throws:
DelaunayError
IllegalArgumentException - if minLength is inferior or equal to 0

insertTriangleCircumCenter

public final DEdge insertTriangleCircumCenter(DTriangle tri,
                                              boolean revertible,
                                              double minLength)
                                       throws DelaunayError
Insert the circumcenter of the given triangle in the mesh. This method is part of the Ruppert refinement algorithm. Consequently, it stops if it sees it will create a new encroached edge.
The circumcenter won't be inserted if it is too close from another point of the mesh. Moreover, the z-coordinate of the circumcenter is re-computed to ensure the topologic coherence of the mesh.

Parameters:
tri -
revertible - If set to true, the insertion won't be performed if it creates a new encroached edge in the mesh.
minLength - If the distance between the circumcenter and the closest point of the containing triangle is inferior to minLength, the circumcenter is not inserted.
Returns:
The encroached edge created by this insertion, if any, or null, if a constraint hides the circum center of its triangle, or if the insertion has been performed.
Throws:
DelaunayError

insertIfNotEncroached

public final DEdge insertIfNotEncroached(DPoint pt,
                                         DTriangle container,
                                         double minLength)
                                  throws DelaunayError
Insert pt in container only if it does not create a new encroached edge in the mesh.
if the insertion of the new point would cause such a creation, the point is not inserted, and all the operations associated to its insertion are reverted.

Parameters:
pt -
container -
minLength - The minimum length between the new point and the point of the triangle that is the closest to it. If this distance is less than minLength, the point is not inserted.
Returns:
The encroached edge that has caused the stop of the insertion, if any.
Throws:
DelaunayError

insertPointInTriangle

public final void insertPointInTriangle(DPoint pt,
                                        DTriangle container,
                                        double minLength)
                                 throws DelaunayError
Insert the point pt in the triangle container.
This method does not check if there are any new encroached edge in the mesh. It just goes straight ahead. Moreover, it does not reaffect the z-coordinate of the inserted point.

Parameters:
pt - The point to be inserted.
container - The triangle of the mesh that contains pt.
minLength - The minimum length between the new point and the point of the triangle that is the closest to it. If this distance is less than minLength, the point is not inserted.
Throws:
DelaunayError - if pt is not inside container. If a search is needed, it must be made before trying to insert the point.

dataQualification

public final void dataQualification(double epsilon)
                             throws DelaunayError
Ensure points are at least at epsilon from other points NB : points are supposed to be already sorted

Parameters:
epsilon -
Throws:
DelaunayError

displayObject

public final void displayObject(Graphics g)
Draw Mesh in the JPanel : triangles and edges. If duration is positive, also display it Must be used only when using package drawing

Parameters:
g -


Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.