Class QuadEdgeTriangle
java.lang.Object
org.locationtech.jts.triangulate.quadedge.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.
- Version:
- 1.0
- Author:
- Martin Davis
-
Constructor Summary
ConstructorsConstructorDescriptionQuadEdgeTriangle(QuadEdge[] edge) Creates a new triangle from the given edges. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(Coordinate pt) static booleancontains(QuadEdge[] tri, Coordinate pt) Tests whether the point pt is contained in the triangle defined by 3QuadEdgees.static booleancontains(Vertex[] tri, Coordinate pt) Tests whether the point pt is contained in the triangle defined by 3Vertexes.static ListcreateOn(QuadEdgeSubdivision subdiv) CreatesQuadEdgeTriangles for all facets of aQuadEdgeSubdivisionrepresenting a triangulation.getAdjacentTriangleAcrossEdge(int edgeIndex) intgetAdjacentTriangleEdgeIndex(int i) getCoordinate(int i) getData()Gets the external data value for this triangle.getEdge(int i) intGets the index for the given edge of this triangleintGets the index for the edge that starts at vertex v.QuadEdge[]getEdges()voidgetEdgeSegment(int i, LineSegment seg) getGeometry(GeometryFactory fact) Gets the neighbours of this triangle.getTrianglesAdjacentToVertex(int vertexIndex) Gets the triangles which are adjacent (include) to a given vertex of this triangle.getVertex(int i) Vertex[]Gets the vertices for this triangle.booleanisBorder()Tests whether this triangle is adjacent to the outside of the subdivision.booleanisBorder(int i) booleanisLive()voidkill()static intnextIndex(int index) Finds the next index around the triangle.voidSets the external data value for this triangle.static Geometrystatic GeometrytoString()
-
Constructor Details
-
QuadEdgeTriangle
Creates a new triangle from the given edges.- Parameters:
edge- an array of the edges of the triangle in CCW order
-
-
Method Details
-
createOn
CreatesQuadEdgeTriangles for all facets of aQuadEdgeSubdivisionrepresenting a triangulation. The data attributes of theQuadEdges 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- the QuadEdgeSubdivision to create the triangles on.- Returns:
- a List of the created QuadEdgeTriangles
-
contains
Tests whether the point pt is contained in the triangle defined by 3Vertexes.- Parameters:
tri- an array containing at least 3 Vertexespt- the point to test- Returns:
- true if the point is contained in the triangle
-
contains
Tests whether the point pt is contained in the triangle defined by 3QuadEdgees.- Parameters:
tri- an array containing at least 3 QuadEdgespt- the point to test- Returns:
- true if the point is contained in the triangle
-
toPolygon
-
toPolygon
-
nextIndex
public static int nextIndex(int index) Finds the next index around the triangle. Index may be an edge or vertex index.- Parameters:
index-- Returns:
- the next index
-
setData
Sets the external data value for this triangle.- Parameters:
data- an object containing external data
-
getData
-
kill
public void kill() -
isLive
public boolean isLive() -
getEdges
-
getEdge
-
getVertex
-
getVertices
Gets the vertices for this triangle.- Returns:
- a new array containing the triangle vertices
-
getCoordinate
-
getEdgeIndex
Gets the index for the given edge of this triangle- Parameters:
e- a QuadEdge- Returns:
- the index of the edge in this triangle or -1 if the edge is not an edge of this triangle
-
getEdgeIndex
Gets the index for the edge that starts at vertex v.- Parameters:
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
-
getEdgeSegment
-
getCoordinates
-
contains
-
getGeometry
-
toString
-
isBorder
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
-
isBorder
public boolean isBorder(int i) -
getAdjacentTriangleAcrossEdge
-
getAdjacentTriangleEdgeIndex
public int getAdjacentTriangleEdgeIndex(int i) -
getTrianglesAdjacentToVertex
Gets the triangles which are adjacent (include) to a given vertex of this triangle.- Parameters:
vertexIndex- the vertex to query- Returns:
- a list of the vertex-adjacent triangles
-
getNeighbours
Gets the neighbours of this triangle. If there is no neighbour triangle, the array element isnull- Returns:
- an array containing the 3 neighbours of this triangle
-