10#ifndef CDT_obwOaxOTdAWcLNTlNnaq
11#define CDT_obwOaxOTdAWcLNTlNnaq
13#ifdef CDT_DONT_USE_BOOST_RTREE
15typedef char CDT_DONT_USE_BOOST_RTREE__was__replaced__with__CDT_USE_BOOST[-1];
21#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
22#define CDT_CXX11_IS_SUPPORTED
23#elif !defined(__cplusplus) && !defined(_MSC_VER)
30#ifdef CDT_USE_AS_COMPILED_LIBRARY
31#define CDT_INLINE_IF_HEADER_ONLY
32#include "cdt_export.h"
38#define CDT_INLINE_IF_HEADER_ONLY inline
49#ifdef CDT_USE_STRONG_TYPING
50#include <boost/serialization/strong_typedef.hpp>
54#ifdef CDT_CXX11_IS_SUPPORTED
59#include <unordered_map>
60#include <unordered_set>
68using std::unordered_map;
69using std::unordered_set;
73#include <boost/array.hpp>
74#include <boost/functional/hash.hpp>
75#include <boost/tuple/tuple.hpp>
76#include <boost/unordered_map.hpp>
77#include <boost/unordered_set.hpp>
82using boost::make_tuple;
85using boost::unordered_map;
86using boost::unordered_set;
101 static V2d make(T x, T y);
122 return lhs.
x == rhs.
x && lhs.
y == rhs.
y;
125#ifdef CDT_USE_64_BIT_INDEX_TYPE
126typedef unsigned long long IndexSizeType;
128typedef unsigned int IndexSizeType;
131#ifdef CDT_USE_STRONG_TYPING
133BOOST_STRONG_TYPEDEF(
unsigned char,
Index);
135BOOST_STRONG_TYPEDEF(IndexSizeType,
VertInd);
137BOOST_STRONG_TYPEDEF(IndexSizeType,
TriInd);
148const static IndexSizeType
149 invalidIndex(std::numeric_limits<IndexSizeType>::max());
151const static TriInd noNeighbor(invalidIndex);
153const static VertInd noVertex(invalidIndex);
169 envelopPoint(p.
x, p.
y);
174 min.
x = std::min(x, min.
x);
175 max.
x = std::max(x, max.
x);
176 min.
y = std::min(y, min.
y);
177 max.
y = std::max(y, max.
y);
184 typename TVertexIter,
185 typename TGetVertexCoordX,
186 typename TGetVertexCoordY>
190 TGetVertexCoordX getX,
191 TGetVertexCoordY getY)
193 const T max = std::numeric_limits<T>::max();
194 Box2d<T> box = {{max, max}, {-max, -max}};
195 for(; first != last; ++first)
215 bool operator!=(
const Edge& other)
const;
221 const std::pair<VertInd, VertInd>& verts()
const;
224 std::pair<VertInd, VertInd> m_vertices;
242 return Edge(iV1, iV2);
269 make(
const array<VertInd, 3>& vertices,
const array<TriInd, 3>& neighbors)
279 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
282 return std::make_pair(neighbors[0], vertices[1]);
286 return std::make_pair(neighbors[1], vertices[2]);
288 return std::make_pair(neighbors[2], vertices[0]);
294 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
296 return std::make_pair(neighbors[2], vertices[2]);
298 return std::make_pair(neighbors[0], vertices[0]);
299 return std::make_pair(neighbors[1], vertices[1]);
302 bool containsVertex(
const VertInd i)
const
304 return std::find(vertices.begin(), vertices.end(), i) != vertices.end();
360 T orientationTolerance = T(0));
434#ifndef CDT_USE_AS_COMPILED_LIBRARY
441#ifdef CDT_CXX11_IS_SUPPORTED
448#ifdef CDT_USE_STRONG_TYPING
457 return std::hash<std::size_t>()(vi.t);
466 std::size_t operator()(
const CDT::TriInd& vi)
const
468 return std::hash<std::size_t>()(vi.t);
485 static void hashCombine(std::size_t& seed,
const CDT::VertInd& key)
487#ifdef CDT_CXX11_IS_SUPPORTED
488 typedef std::hash<CDT::VertInd> Hasher;
490 typedef boost::hash<CDT::VertInd> Hasher;
492 seed ^= Hasher()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
494 static std::size_t hashEdge(
const CDT::Edge& e)
496 const std::pair<CDT::VertInd, CDT::VertInd>& vv = e.
verts();
497 std::size_t seed1(0);
498 hashCombine(seed1, vv.first);
499 hashCombine(seed1, vv.second);
500 std::size_t seed2(0);
501 hashCombine(seed2, vv.second);
502 hashCombine(seed2, vv.first);
503 return std::min(seed1, seed2);
#define CDT_EXPORT
Export not needed in header-only mode.
char couldnt_parse_cxx_standard[-1]
Error: couldn't parse standard.
#define CDT_INLINE_IF_HEADER_ONLY
Macro for inlining non-template functions when in header-only mode to avoid multiple declaration erro...
Utilities and helpers - implementation.
Namespace containing triangulation functionality.
std::vector< Edge > EdgeVec
Vector of edges.
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.
unordered_set< Edge > EdgeUSet
Hash table of edges.
VertInd edge_get_v2(const Edge &e)
Get edge second vertex.
std::vector< TriInd > TriIndVec
Vector of triangle indices.
Box2d< T > envelopBox(TVertexIter first, TVertexIter last, TGetVertexCoordX getX, TGetVertexCoordY getY)
Bounding box of a collection of custom 2D points given coordinate getters.
CDT_INLINE_IF_HEADER_ONLY Index edgeNeighborInd(const VerticesArr3 &vv, VertInd iVedge1, VertInd iVedge2)
Index of triangle's neighbor opposed to an edge.
VertInd edge_get_v1(const Edge &e)
Get edge first vertex.
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.
unordered_set< TriInd > TriIndUSet
Hash table of triangles.
CDT_EXPORT Index ccw(Index i)
Advance vertex or neighbor index counter-clockwise.
Edge edge_make(VertInd iV1, VertInd iV2)
Get edge second vertex.
CDT_EXPORT Index edgeNeighbor(PtTriLocation::Enum location)
Neighbor index from a on-edge location.
unordered_map< TriInd, TriInd > TriIndUMap
Triangle hash map.
const T & getX_V2d(const V2d< T > &v)
X- coordinate getter for V2d.
bool operator==(const CDT::V2d< T > &lhs, const CDT::V2d< T > &rhs)
If two 2D vectors are exactly equal.
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.
std::vector< Triangle > TriangleVec
Vector of triangles.
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opposedVertexInd(const NeighborsArr3 &nn, TriInd iTopo)
Index of triangle's vertex opposed to a triangle.
const T & getY_V2d(const V2d< T > &v)
Y-coordinate getter for V2d.
void envelopPoint(const T x, const T y)
Envelop box around a point with given coordinates.
V2d< T > max
max box corner
V2d< T > min
min box corner
void envelopPoint(const V2d< T > &p)
Envelop box around a point.
Edge connecting two vertices: vertex with smaller index is always first.
const std::pair< VertInd, VertInd > & verts() const
Edges' vertices.
VertInd v2() const
V2 getter.
VertInd v1() const
V1 getter.
Relative location of point to a line.
Location of point on a triangle.
Triangulation triangle (counter-clockwise winding)
VerticesArr3 vertices
triangle's three vertices
std::pair< TriInd, VertInd > prev(const VertInd i) const
Previous triangle adjacent to a vertex (counter-clockwise)
static Triangle make(const array< VertInd, 3 > &vertices, const array< TriInd, 3 > &neighbors)
Factory method.
NeighborsArr3 neighbors
triangle's three neighbors
std::pair< TriInd, VertInd > next(const VertInd i) const
Next triangle adjacent to a vertex (clockwise)
std::size_t operator()(const CDT::Edge &e) const
Hash operator.