public class QuadEdgeSubdivision extends Object
QuadEdges representing a planar subdivision that models a triangulation. The subdivision is constructed using the quadedge algebra defined in the classs
QuadEdge. All metric calculations are done in the
Vertex class. In addition to a triangulation, subdivisions support extraction of Voronoi diagrams. This is easily accomplished, since the Voronoi diagram is the dual of the Delaunay triangulation.
Subdivisions can be provided with a tolerance value. Inserted vertices which are closer than this value to vertices already in the subdivision will be ignored. Using a suitable tolerance value can prevent robustness failures from happening during Delaunay triangulation.
Subdivisions maintain a frame triangle around the client-created edges. The frame is used to provide a bounded "container" for all edges within a TIN. Normally the frame edges, frame connecting edges, and frame triangles are not included in client processing.
| Constructor and Description |
|---|
QuadEdgeSubdivision(Envelope
Creates a new instance of a quad-edge subdivision based on a frame triangle that encloses a supplied bounding box.
|
| Modifier and Type | Method and Description |
|---|---|
QuadEdge |
connect(QuadEdge
Creates a new QuadEdge connecting the destination of a to the origin of b, in such a way that all three have the same left face after the connection is complete.
|
void |
delete(QuadEdge
Deletes a quadedge from the subdivision.
|
Collection |
getEdges()
Gets the collection of base
QuadEdges (one for every pair of vertices which is connected).
|
Geometry |
getEdges(GeometryFactory
Gets the geometry for the edges in the subdivision as a
MultiLineString containing 2-point lines.
|
Envelope |
getEnvelope()
Gets the envelope of the Subdivision (including the frame).
|
List |
getPrimaryEdges(boolean includeFrame)
Gets all primary quadedges in the subdivision.
|
double |
getTolerance()
Gets the vertex-equality tolerance value used in this subdivision
|
List |
getTriangleCoordinates(boolean includeFrame)
Gets the coordinates for each triangle in the subdivision as an array.
|
List |
getTriangleEdges(boolean includeFrame)
Gets a list of the triangles in the subdivision, specified as an array of the primary quadedges around the triangle.
|
static void |
getTriangleEdges(QuadEdge
Gets the edges for the triangle to the left of the given
QuadEdge.
|
Geometry |
getTriangles(GeometryFactory
Gets the geometry for the triangles in a triangulated subdivision as a
GeometryCollection of triangular
Polygons.
|
List |
getTriangleVertices(boolean includeFrame)
Gets a list of the triangles in the subdivision, specified as an array of the triangle
Vertexes.
|
List |
getVertexUniqueEdges(boolean includeFrame)
Gets a collection of
QuadEdges whose origin vertices are a unique set which includes all vertices in the subdivision.
|
Collection |
getVertices(boolean includeFrame)
Gets the unique
Vertexes in the subdivision, including the frame vertices if desired.
|
Polygon |
getVoronoiCellPolygon(QuadEdge
Gets the Voronoi cell around a site specified by the origin of a QuadEdge.
|
List |
getVoronoiCellPolygons(GeometryFactory
Gets a List of
Polygons for the Voronoi cells of this triangulation.
|
Geometry |
getVoronoiDiagram(GeometryFactory
Gets the cells in the Voronoi diagram for this triangulation.
|
QuadEdge |
insertSite(Vertex
Inserts a new site into the Subdivision, connecting it to the vertices of the containing triangle (or quadrilateral, if the split point falls on an existing edge).
|
boolean |
isFrameBorderEdge(QuadEdge
Tests whether a QuadEdge is an edge on the border of the frame facets and the internal facets.
|
boolean |
isFrameEdge(QuadEdge
Tests whether a QuadEdge is an edge incident on a frame triangle vertex.
|
boolean |
isFrameVertex(Vertex
Tests whether a vertex is a vertex of the outer triangle.
|
boolean |
isOnEdge(QuadEdge
Tests whether a
Coordinate lies on a
QuadEdge, up to a tolerance determined by the subdivision tolerance.
|
boolean |
isVertexOfEdge(QuadEdge
|
QuadEdge |
locate(Coordinate
Finds a quadedge of a triangle containing a location specified by a
Coordinate, if one exists.
|
QuadEdge |
locate(Coordinate
Locates the edge between the given vertices, if it exists in the subdivision.
|
QuadEdge |
locate(Vertex
Finds a quadedge of a triangle containing a location specified by a
Vertex, if one exists.
|
QuadEdge |
locateFromEdge(Vertex
Locates an edge of a triangle which contains a location specified by a Vertex v.
|
QuadEdge |
makeEdge(Vertex
Creates a new quadedge, recording it in the edges list.
|
void |
setLocator(QuadEdgeLocator
Sets the
QuadEdgeLocator to use for locating containing triangles in this subdivision.
|
void |
visitTriangles(TriangleVisitor
Visitors
|
public QuadEdgeSubdivision(Envelopeenv, double tolerance)
env - the bouding box to surround
tolerance - the tolerance value for determining if two sites are equal
public static void getTriangleEdges(QuadEdgestartQE, QuadEdge [] triEdge)
QuadEdge.
startQE -
triEdge -
IllegalArgumentException - if the edges do not form a triangle
public double getTolerance()
public EnvelopegetEnvelope()
public CollectiongetEdges()
QuadEdges (one for every pair of vertices which is connected).
public void setLocator(QuadEdgeLocatorlocator)
QuadEdgeLocator to use for locating containing triangles in this subdivision.
locator - a QuadEdgeLocator
public QuadEdgemakeEdge(Vertex o, Vertex d)
o -
d -
public QuadEdgeconnect(QuadEdge a, QuadEdge b)
a -
b -
public void delete(QuadEdgee)
e - the quadedge to delete
public QuadEdgelocateFromEdge(Vertex v, QuadEdge startEdge)
This locate algorithm relies on the subdivision being Delaunay. For non-Delaunay subdivisions, this may loop for ever.
v - the location to search for
startEdge - an edge of the subdivision to start searching at
LocateFailureException - if the location algorithm fails to converge in a reasonable number of iterations
public QuadEdgelocate(Vertex v)
Vertex, if one exists.
v - the vertex to locate
public QuadEdgelocate(Coordinate p)
Coordinate, if one exists.
p - the Coordinate to locate
public QuadEdgelocate(Coordinate p0, Coordinate p1)
p0 - a coordinate
p1 - another coordinate
public QuadEdgeinsertSite(Vertex v)
This method does NOT maintain the Delaunay condition. If desired, this must be checked and enforced by the caller.
This method does NOT check if the inserted vertex falls on an edge. This must be checked by the caller, since this situation may cause erroneous triangulation
v - the vertex to insert
public boolean isFrameEdge(QuadEdgee)
e - the edge to test
public boolean isFrameBorderEdge(QuadEdgee)
e - the edge to test
public boolean isFrameVertex(Vertexv)
v - the vertex to test
public boolean isOnEdge(QuadEdgee, Coordinate p)
Coordinate lies on a
QuadEdge, up to a tolerance determined by the subdivision tolerance.
e - a QuadEdge
p - a point
public boolean isVertexOfEdge(QuadEdgee, Vertex v)
Vertex is the start or end vertex of a
QuadEdge, up to the subdivision tolerance distance.
e -
v -
public CollectiongetVertices(boolean includeFrame)
Vertexes in the subdivision, including the frame vertices if desired.
includeFrame - true if the frame vertices should be included
getVertexUniqueEdges(boolean)
public ListgetVertexUniqueEdges(boolean includeFrame)
QuadEdges whose origin vertices are a unique set which includes all vertices in the subdivision. The frame vertices can be included if required.
This is useful for algorithms which require traversing the subdivision starting at all vertices. Returning a quadedge for each vertex is more efficient than the alternative of finding the actual vertices using getVertices(boolean) and then locating quadedges attached to them.
includeFrame - true if the frame vertices should be included
public ListgetPrimaryEdges(boolean includeFrame)
QuadEdge which occupies the 0'th position in its array of associated quadedges. These provide the unique geometric edges of the triangulation.
includeFrame - true if the frame edges are to be included
public void visitTriangles(TriangleVisitortriVisitor, boolean includeFrame)
public ListgetTriangleEdges(boolean includeFrame)
includeFrame - true if the frame triangles should be included
public ListgetTriangleVertices(boolean includeFrame)
Vertexes.
includeFrame - true if the frame triangles should be included
public ListgetTriangleCoordinates(boolean includeFrame)
includeFrame - true if the frame triangles should be included
public GeometrygetEdges(GeometryFactory geomFact)
MultiLineString containing 2-point lines.
geomFact - the GeometryFactory to use
public GeometrygetTriangles(GeometryFactory geomFact)
GeometryCollection of triangular
Polygons.
geomFact - the GeometryFactory to use
public GeometrygetVoronoiDiagram(GeometryFactory geomFact)
GeometryCollection of
Polygons
The userData of each polygon is set to be the Coordinate of the cell site. This allows easily associating external data associated with the sites to the cells.
geomFact - a geometry factory
public ListgetVoronoiCellPolygons(GeometryFactory geomFact)
Polygons for the Voronoi cells of this triangulation.
The userData of each polygon is set to be the Coordinate of the cell site. This allows easily associating external data associated with the sites to the cells.
geomFact - a geometry factory
public PolygongetVoronoiCellPolygon(QuadEdge qe, GeometryFactory geomFact)
The userData of the polygon is set to be the Coordinate of the site. This allows attaching external data associated with the site to this cell polygon.
qe - a quadedge originating at the cell site
geomFact - a factory for building the polygon