Class QuadEdgeTriangle

Hierarchy: Object , QuadEdgeTriangle
public class QuadEdgeTriangle
Models a triangle formed from QuadEdges in a QuadEdgeSubdivision which forms a triangulation. The class provides methods to access the topological and geometric properties of the triangle and its neighbours in the triangulation. Triangle vertices are ordered in CCW orientation in the structure.

QuadEdgeTriangles support having an external data attribute attached to them. Alternatively, this class can be subclassed and attributes can be defined in the subclass. Subclasses will need to define their own BuilderVisitor class and createOn method.

Authors:
Martin Davis

Other

  • version: 1.0
public QuadEdgeTriangle(QuadEdge[] edge)
Creates a new triangle from the given edges.
Parameters:
edge - edge an array of the edges of the triangle in CCW order
public static List createOn(QuadEdgeSubdivision subdiv)
Creates QuadEdgeTriangles for all facets of a QuadEdgeSubdivision representing a triangulation. The data attributes of the QuadEdges in the subdivision will be set to point to the triangle which contains that edge. This allows tracing the neighbour triangles of any given triangle.
Parameters:
subdiv - subdiv the QuadEdgeSubdivision to create the triangles on.
Returns:
a List of the created QuadEdgeTriangles
public static boolean contains(Vertex[] tri, Coordinate pt)
Tests whether the point pt is contained in the triangle defined by 3 Vertexes.
Parameters:
tri - tri an array containing at least 3 Vertexes
pt - pt the point to test
Returns:
true if the point is contained in the triangle
public static boolean contains(QuadEdge[] tri, Coordinate pt)
Tests whether the point pt is contained in the triangle defined by 3 QuadEdgees.
Parameters:
tri - tri an array containing at least 3 QuadEdges
pt - pt the point to test
Returns:
true if the point is contained in the triangle
public static Geometry toPolygon(Vertex[] v)
public static Geometry toPolygon(QuadEdge[] e)
public static int nextIndex(int index)
Finds the next index around the triangle. Index may be an edge or vertex index.
Parameters:
index - index
Returns:
the next index
public void setData(Object data)
Sets the external data value for this triangle.
Parameters:
data - data an object containing external data
public Object getData()
Gets the external data value for this triangle.
Returns:
the data object
public void kill()
public boolean isLive()
public QuadEdge[] getEdges()
public QuadEdge getEdge(int i)
public Vertex getVertex(int i)
public Vertex[] getVertices()
Gets the vertices for this triangle.
Returns:
a new array containing the triangle vertices
public Coordinate getCoordinate(int i)
public int getEdgeIndex(QuadEdge e)
Gets the index for the given edge of this triangle
Parameters:
e - e a QuadEdge
Returns:
the index of the edge in this triangle or -1 if the edge is not an edge of this triangle
public int getEdgeIndex(Vertex v)
Gets the index for the edge that starts at vertex v.
Parameters:
v - v the vertex to find the edge for
Returns:
the index of the edge starting at the vertex or -1 if the vertex is not in the triangle
public void getEdgeSegment(int i, LineSegment seg)
public Coordinate[] getCoordinates()
public boolean contains(Coordinate pt)
public Polygon getGeometry(GeometryFactory fact)
public String toString()
public boolean isBorder()
Tests whether this triangle is adjacent to the outside of the subdivision.
Returns:
true if the triangle is adjacent to the subdivision exterior
public boolean isBorder(int i)
public QuadEdgeTriangle getAdjacentTriangleAcrossEdge(int edgeIndex)
public int getAdjacentTriangleEdgeIndex(int i)
public List getTrianglesAdjacentToVertex(int vertexIndex)
Gets the triangles which are adjacent (include) to a given vertex of this triangle.
Parameters:
vertexIndex - vertexIndex the vertex to query
Returns:
a list of the vertex-adjacent triangles
public QuadEdgeTriangle[] getNeighbours()
Gets the neighbours of this triangle. If there is no neighbour triangle, the array element is null
Returns:
an array containing the 3 neighbours of this triangle