9#ifndef CDT_zWlHcbQZQyBBqPgxvFDT
10#define CDT_zWlHcbQZQyBBqPgxvFDT
14#include "predicates.h"
23 return Index((i + 1) % 3);
28 return Index((i + 2) % 3);
33 return location == PtTriLocation::OnEdge1 ||
34 location == PtTriLocation::OnEdge2 ||
35 location == PtTriLocation::OnEdge3;
41 return static_cast<Index>(location - PtTriLocation::OnEdge1);
47 return predicates::adaptive::orient2d(v1.
x, v1.
y, v2.
x, v2.
y, p.
x, p.
y);
55 const T orientationTolerance)
64 if(orientation < -orientationTolerance)
65 return PtLineLocation::Right;
66 if(orientation > orientationTolerance)
67 return PtLineLocation::Left;
68 return PtLineLocation::OnLine;
78 using namespace predicates::adaptive;
81 if(edgeCheck == PtLineLocation::Right)
82 return PtTriLocation::Outside;
83 if(edgeCheck == PtLineLocation::OnLine)
84 result = PtTriLocation::OnEdge1;
86 if(edgeCheck == PtLineLocation::Right)
87 return PtTriLocation::Outside;
88 if(edgeCheck == PtLineLocation::OnLine)
90 result = (result == PtTriLocation::Inside) ? PtTriLocation::OnEdge2
91 : PtTriLocation::OnVertex;
94 if(edgeCheck == PtLineLocation::Right)
95 return PtTriLocation::Outside;
96 if(edgeCheck == PtLineLocation::OnLine)
98 result = (result == PtTriLocation::Inside) ? PtTriLocation::OnEdge3
99 : PtTriLocation::OnVertex;
106 if(vertIndex ==
Index(0))
108 if(vertIndex ==
Index(1))
110 if(vertIndex ==
Index(2))
112 assert(
false &&
"Invalid vertex index");
113 handleException(std::runtime_error(
"Invalid vertex index"));
119 if(neighborIndex ==
Index(0))
121 if(neighborIndex ==
Index(1))
123 if(neighborIndex ==
Index(2))
125 assert(
false &&
"Invalid neighbor index");
126 handleException(std::runtime_error(
"Invalid neighbor index"));
130CDT_INLINE_IF_HEADER_ONLY
Index
133 assert(vv[0] == iVert || vv[1] == iVert || vv[2] == iVert);
146 assert(vv[0] == iVedge1 || vv[1] == iVedge1 || vv[2] == iVedge1);
147 assert(vv[0] == iVedge2 || vv[1] == iVedge2 || vv[2] == iVedge2);
149 (vv[0] != iVedge1 && vv[0] != iVedge2) ||
150 (vv[1] != iVedge1 && vv[1] != iVedge2) ||
151 (vv[2] != iVedge1 && vv[2] != iVedge2));
174CDT_INLINE_IF_HEADER_ONLY
Index
177 assert(nn[0] == iTopo || nn[1] == iTopo || nn[2] == iTopo);
185CDT_INLINE_IF_HEADER_ONLY
Index
188 assert(vv[0] == iV || vv[1] == iV || vv[2] == iV);
196CDT_INLINE_IF_HEADER_ONLY
TriInd
202CDT_INLINE_IF_HEADER_ONLY
VertInd
209CDT_INLINE_IF_HEADER_ONLY
TriInd
222 using namespace predicates::adaptive;
223 return incircle(v1.
x, v1.
y, v2.
x, v2.
y, v3.
x, v3.
y, p.
x, p.
y) > T(0);
226CDT_INLINE_IF_HEADER_ONLY
229 for(TriIndVec::const_iterator it = aTris.begin(); it != aTris.end(); ++it)
230 if(std::find(bTris.begin(), bTris.end(), *it) != bTris.end())
238 const T dx = bx - ax;
239 const T dy = by - ay;
240 return dx * dx + dy * dy;
244T
distance(
const T ax,
const T ay,
const T bx,
const T by)
Namespace containing triangulation functionality.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY VertInd opposedVertex(const Triangle &tri, TriInd iTopo)
Given two triangles, return vertex of first triangle opposed to the second.
std::vector< TriInd > TriIndVec
Vector of triangle indices.
CDT_INLINE_IF_HEADER_ONLY Index edgeNeighborInd(const VerticesArr3 &vv, VertInd iVedge1, VertInd iVedge2)
Index of triangle's neighbor opposed to an edge.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opposedTriangleInd(const VerticesArr3 &vv, VertInd iVert)
Index of triangle's neighbor opposed to a vertex.
CDT_EXPORT PtLineLocation::Enum classifyOrientation(T orientation, T orientationTolerance=T(0))
Classify value of orient2d predicate.
array< TriInd, 3 > NeighborsArr3
array of three neighbors
CDT_EXPORT T distance(const V2d< T > &a, const V2d< T > &b)
Distance between two 2D points.
IndexSizeType VertInd
Vertex index.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool verticesShareEdge(const TriIndVec &aTris, const TriIndVec &bTris)
Test if two vertices share at least one common triangle.
CDT_EXPORT Index cw(Index i)
Advance vertex or neighbor index clockwise.
array< VertInd, 3 > VerticesArr3
array of three vertex indices
CDT_INLINE_IF_HEADER_ONLY bool touchesSuperTriangle(const Triangle &t)
Check if any of triangle's vertices belongs to a super-triangle.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoVrt(Index neighborIndex)
Opposed vertex index from neighbor index.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoNbr(Index vertIndex)
Opposed neighbor index from vertex index.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index vertexInd(const VerticesArr3 &vv, VertInd iV)
If triangle has a given vertex return vertex-index.
CDT_EXPORT T orient2D(const V2d< T > &p, const V2d< T > &v1, const V2d< T > &v2)
Orient p against line v1-v2 2D: robust geometric predicate.
CDT_EXPORT PtLineLocation::Enum locatePointLine(const V2d< T > &p, const V2d< T > &v1, const V2d< T > &v2, T orientationTolerance=T(0))
Check if point lies to the left of, to the right of, or on a line.
CDT_EXPORT T distanceSquared(const V2d< T > &a, const V2d< T > &b)
Squared distance between two 2D points.
CDT_EXPORT Index ccw(Index i)
Advance vertex or neighbor index counter-clockwise.
CDT_EXPORT Index edgeNeighbor(PtTriLocation::Enum location)
Neighbor index from a on-edge location.
unsigned char Index
Index in triangle.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd opposedTriangle(const Triangle &tri, VertInd iVert)
Given triangle and a vertex find opposed triangle.
CDT_EXPORT bool isInCircumcircle(const V2d< T > &p, const V2d< T > &v1, const V2d< T > &v2, const V2d< T > &v3)
Test if point lies in a circumscribed circle of a triangle.
CDT_EXPORT bool isOnEdge(PtTriLocation::Enum location)
Check if location is classified as on any of three edges.
IndexSizeType TriInd
Triangle index.
CDT_EXPORT PtTriLocation::Enum locatePointTriangle(const V2d< T > &p, const V2d< T > &v1, const V2d< T > &v2, const V2d< T > &v3)
Check if point a lies inside of, outside of, or on an edge of a triangle.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opposedVertexInd(const NeighborsArr3 &nn, TriInd iTopo)
Index of triangle's vertex opposed to a triangle.
Triangulation triangle (counter-clockwise winding)
VerticesArr3 vertices
triangle's three vertices
NeighborsArr3 neighbors
triangle's three neighbors