CDT  2.0.1
C++ library for constrained Delaunay triangulation
Loading...
Searching...
No Matches
CDTUtils.h
Go to the documentation of this file.
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
9
10#ifndef CDT_obwOaxOTdAWcLNTlNnaq
11#define CDT_obwOaxOTdAWcLNTlNnaq
12
13#ifdef CDT_DONT_USE_BOOST_RTREE
14// CDT_DONT_USE_BOOST_RTREE was replaced with CDT_USE_BOOST
15typedef char CDT_DONT_USE_BOOST_RTREE__was__replaced__with__CDT_USE_BOOST[-1];
16#endif
17
18// #define CDT_USE_STRONG_TYPING // strong type checks on indices
19
20// check if c++11 is supported
21#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
22#define CDT_CXX11_IS_SUPPORTED
23#elif !defined(__cplusplus) && !defined(_MSC_VER)
25#endif
26
27// 'noexcept' is only available since c++11 and its c++98 spelling 'throw()'
28// is in turn removed in c++20
29#ifdef CDT_CXX11_IS_SUPPORTED
31#define CDT_NOEXCEPT noexcept
32#else
33#define CDT_NOEXCEPT throw()
34#endif
35
36// Functions defined outside the class need to be 'inline'
37// if CDT is configured to be used as header-only library:
38// single-definition rule is violated otherwise
39#ifdef CDT_USE_AS_COMPILED_LIBRARY
40#define CDT_INLINE_IF_HEADER_ONLY
41#include "cdt_export.h" // automatically generated by CMake
42#else
47#define CDT_INLINE_IF_HEADER_ONLY inline
49#define CDT_EXPORT
50#endif
51
52#include <algorithm>
53#include <cassert>
54#include <cmath>
55#include <limits>
56#include <queue>
57#include <vector>
58
59#ifdef M_PI
60#define CDT_M_PI M_PI
61#else
62#define CDT_M_PI 3.14159265358979323846
63#endif
64
65#ifdef CDT_USE_STRONG_TYPING
66#include <boost/serialization/strong_typedef.hpp>
67#endif
68
69// use fall-backs for c++11 features
70#ifdef CDT_CXX11_IS_SUPPORTED
71
72#include <array>
73#include <functional>
74#include <string>
75#include <tuple>
76#include <unordered_map>
77#include <unordered_set>
78
79#ifdef CDT_DISABLE_EXCEPTIONS
80#include <exception>
81#endif
82
83namespace CDT
84{
85using std::array;
86using std::get;
87using std::make_tuple;
88using std::tie;
89using std::to_string;
90using std::tuple;
91using std::unordered_map;
92using std::unordered_set;
93} // namespace CDT
94
95#else
96#include <boost/array.hpp>
97#include <boost/functional/hash.hpp>
98#include <boost/lexical_cast.hpp>
99#include <boost/tuple/tuple.hpp>
100#include <boost/unordered_map.hpp>
101#include <boost/unordered_set.hpp>
102namespace CDT
103{
104using boost::array;
105using boost::get;
106using boost::make_tuple;
107using boost::tie;
108using boost::tuple;
109using boost::unordered_map;
110using boost::unordered_set;
111
112template <typename T>
113std::string to_string(const T& value)
114{
115 return boost::lexical_cast<std::string>(value);
116}
117} // namespace CDT
118#endif
119
121#ifdef _MSC_VER
122#define CDT_ENSURE_PRECISE_MATH \
123 __pragma(float_control(push)) \
124 __pragma(float_control(precise, on)) \
125 __pragma(fp_contract(off))
126#elif defined(__clang__)
127#define CDT_ENSURE_PRECISE_MATH \
128 _Pragma("float_control(push)") \
129 _Pragma("float_control(precise, on)") \
130 _Pragma("clang fp contract(off)")
131#elif defined(__GNUC__)
132#define CDT_ENSURE_PRECISE_MATH \
133 _Pragma("GCC push_options") \
134 _Pragma("GCC optimize(\"no-fast-math\")") \
135 _Pragma("GCC optimize(\"fp-contract=off\")")
136#else
137#define CDT_ENSURE_PRECISE_MATH _Pragma("STDC FP_CONTRACT OFF")
138#endif
139
141#if defined(_MSC_VER)
142#define CDT_RESTORE_MATH_SETTINGS __pragma(float_control(pop))
143#elif defined(__clang__)
144#define CDT_RESTORE_MATH_SETTINGS _Pragma("float_control(pop)")
145#elif defined(__GNUC__)
146#define CDT_RESTORE_MATH_SETTINGS _Pragma("GCC pop_options")
147#else
148#define CDT_RESTORE_MATH_SETTINGS _Pragma("STDC FP_CONTRACT DEFAULT")
149#endif
150
152#ifdef CDT_ENSURE_PRECISE_MATH_IN_CONSTRUCTIONS
153#define CDT_ENSURE_PRECISE_MATH_FOR_CONSTRUCTIONS CDT_ENSURE_PRECISE_MATH
154#define CDT_RESTORE_MATH_SETTINGS_FOR_CONSTRUCTIONS CDT_RESTORE_MATH_SETTINGS
155#else
156#define CDT_ENSURE_PRECISE_MATH_FOR_CONSTRUCTIONS
157#define CDT_RESTORE_MATH_SETTINGS_FOR_CONSTRUCTIONS
158#endif
159
160namespace CDT
161{
162
163template <typename T>
164void handleException(const T& error)
165{
166#ifdef CDT_DISABLE_EXCEPTIONS
167 std::terminate();
168#else
169 throw error;
170#endif
171}
172
174template <typename T>
175array<T, 3> arr3(const T& v0, const T& v1, const T& v2)
176{
177 const array<T, 3> out = {v0, v1, v2};
178 return out;
179}
180
182template <typename T>
183array<T, 3> arr3(const T& v)
184{
185 const array<T, 3> out = {v, v, v};
186 return out;
187}
188
190template <typename T>
191struct CDT_EXPORT V2d
192{
193 T x;
194 T y;
195
198 : x(T(0))
199 , y(T(0))
200 {}
201
203 V2d(const T x, const T y)
204 : x(x)
205 , y(y)
206 {}
207};
208
210template <typename T>
211const T& getX_V2d(const V2d<T>& v)
212{
213 return v.x;
214}
215
217template <typename T>
218const T& getY_V2d(const V2d<T>& v)
219{
220 return v.y;
221}
222
224template <typename T>
225bool operator==(const CDT::V2d<T>& lhs, const CDT::V2d<T>& rhs)
226{
227 return lhs.x == rhs.x && lhs.y == rhs.y;
228}
229
231template <typename T>
232bool operator!=(const CDT::V2d<T>& lhs, const CDT::V2d<T>& rhs)
233{
234 return !(lhs == rhs);
235}
236
237#ifdef CDT_USE_64_BIT_INDEX_TYPE
238typedef unsigned long long IndexSizeType;
239#else
240typedef unsigned int IndexSizeType;
241#endif
242
243#ifdef CDT_USE_STRONG_TYPING
249BOOST_STRONG_TYPEDEF(IndexSizeType, TriInd);
250#else
252typedef unsigned char Index;
254typedef IndexSizeType VertInd;
256typedef IndexSizeType TriInd;
257#endif
258
260const static Index invalidIndex(std::numeric_limits<Index>::max());
262const static IndexSizeType
263 invalidIndexSizeType(std::numeric_limits<IndexSizeType>::max());
266const static IndexSizeType nSuperTriVerts(3);
268const static TriInd noNeighbor(invalidIndexSizeType);
270const static VertInd noVertex(invalidIndexSizeType);
271
272typedef std::vector<TriInd> TriIndVec;
273typedef array<VertInd, 3> VerticesArr3;
274typedef array<TriInd, 3> NeighborsArr3;
275
277template <typename T>
278struct CDT_EXPORT Box2d
279{
282
285 : min(std::numeric_limits<T>::max(), std::numeric_limits<T>::max())
286 , max(-std::numeric_limits<T>::max(), -std::numeric_limits<T>::max())
287 {}
288
291 {
292 return envelopPoint(p.x, p.y);
293 }
294
296 Box2d<T>& envelopPoint(const T x, const T y)
297 {
298 min.x = std::min(x, min.x);
299 max.x = std::max(x, max.x);
300 min.y = std::min(y, min.y);
301 max.y = std::max(y, max.y);
302 return *this;
303 }
304
306 template <
307 typename TVertexIter,
308 typename TGetVertexCoordX,
309 typename TGetVertexCoordY>
311 TVertexIter first,
312 TVertexIter last,
313 TGetVertexCoordX getX,
314 TGetVertexCoordY getY)
315 {
316 for(; first != last; ++first)
317 {
318 envelopPoint(getX(*first), getY(*first));
319 }
320 return *this;
321 }
322
324 Box2d<T>& envelopPoints(const std::vector<V2d<T> >& vertices)
325 {
326 return envelopPoints(
327 vertices.begin(), vertices.end(), getX_V2d<T>, getY_V2d<T>);
328 }
329};
330
333struct CDT_EXPORT Edge
334{
336 Edge(const VertInd iV1, const VertInd iV2)
337 : m_vertices(
338 iV1 < iV2 ? std::make_pair(iV1, iV2) : std::make_pair(iV2, iV1))
339 {}
340
342 bool operator==(const Edge& other) const
343 {
344 return m_vertices == other.m_vertices;
345 }
346
348 bool operator!=(const Edge& other) const
349 {
350 return !(this->operator==(other));
351 }
352
355 bool operator<(const Edge& other) const
356 {
357 return m_vertices < other.m_vertices;
358 }
359
361 VertInd v1() const
362 {
363 return m_vertices.first;
364 }
365
367 VertInd v2() const
368 {
369 return m_vertices.second;
370 }
371
373 const std::pair<VertInd, VertInd>& verts() const
374 {
375 return m_vertices;
376 }
377
378private:
379 std::pair<VertInd, VertInd> m_vertices;
380};
381
383inline VertInd edge_get_v1(const Edge& e)
384{
385 return e.v1();
386}
387
389inline VertInd edge_get_v2(const Edge& e)
390{
391 return e.v2();
392}
393
396{
397 return Edge(iV1, iV2);
398}
399
400typedef std::vector<Edge> EdgeVec;
401typedef std::queue<Edge> EdgeQueue;
402typedef std::queue<TriInd> TriIndQueue;
403typedef unordered_set<Edge> EdgeUSet;
404typedef unordered_set<TriInd> TriIndUSet;
405typedef unordered_map<TriInd, TriInd> TriIndUMap;
406
408/*
409 * v3
410 * /\
411 * n3/ \n2
412 * /____\
413 * v1 n1 v2
414 */
415struct CDT_EXPORT Triangle
416{
419
422 : vertices(arr3(noVertex))
423 , neighbors(arr3(noNeighbor))
424 {}
425
431
434 std::pair<TriInd, VertInd> next(const VertInd i) const
435 {
436 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
437 if(vertices[0] == i)
438 {
439 return std::make_pair(neighbors[0], vertices[1]);
440 }
441 if(vertices[1] == i)
442 {
443 return std::make_pair(neighbors[1], vertices[2]);
444 }
445 return std::make_pair(neighbors[2], vertices[0]);
446 }
447
450 std::pair<TriInd, VertInd> prev(const VertInd i) const
451 {
452 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
453 if(vertices[0] == i)
454 return std::make_pair(neighbors[2], vertices[2]);
455 if(vertices[1] == i)
456 return std::make_pair(neighbors[0], vertices[0]);
457 return std::make_pair(neighbors[1], vertices[1]);
458 }
459
461 bool containsVertex(const VertInd i) const
462 {
463 return std::find(vertices.begin(), vertices.end(), i) != vertices.end();
464 }
465};
466
467typedef std::vector<Triangle> TriangleVec;
468
470CDT_EXPORT Index ccw(Index i);
471
473CDT_EXPORT Index cw(Index i);
474
476struct CDT_EXPORT PtTriLocation
477{
479 enum Enum
480 {
481 Inside,
482 Outside,
483 OnEdge1,
484 OnEdge2,
485 OnEdge3,
486 OnVertex,
487 };
488};
489
491CDT_EXPORT bool isOnEdge(PtTriLocation::Enum location);
492
495CDT_EXPORT Index edgeNeighbor(PtTriLocation::Enum location);
496
498struct CDT_EXPORT PtLineLocation
499{
501 enum Enum
502 {
503 Left,
504 Right,
505 OnLine,
506 };
507};
508
510template <typename T>
511CDT_EXPORT T orient2D(const V2d<T>& p, const V2d<T>& v1, const V2d<T>& v2);
512
514template <typename T>
516 const V2d<T>& p,
517 const V2d<T>& v1,
518 const V2d<T>& v2,
519 T orientationTolerance = T(0));
520
522template <typename T>
523CDT_EXPORT PtLineLocation::Enum
524classifyOrientation(T orientation, T orientationTolerance = T(0));
525
527template <typename T>
529 const V2d<T>& p,
530 const V2d<T>& v1,
531 const V2d<T>& v2,
532 const V2d<T>& v3);
533
535CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoNbr(Index vertIndex);
536
538CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoVrt(Index neighborIndex);
539
541CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
542opposedTriangleInd(const VerticesArr3& vv, VertInd iVert);
543
545CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
546edgeNeighborInd(const VerticesArr3& vv, VertInd iVedge1, VertInd iVedge2);
547
549CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
550opposedVertexInd(const NeighborsArr3& nn, TriInd iTopo);
551
553CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
554vertexInd(const VerticesArr3& vv, VertInd iV);
555
557CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd
558opposedTriangle(const Triangle& tri, VertInd iVert);
559
561CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd
562edgeNeighbor(const Triangle& tri, VertInd iVedge1, VertInd iVedge2);
563
565CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY VertInd
566opposedVertex(const Triangle& tri, TriInd iTopo);
567
569template <typename T>
570CDT_EXPORT bool isInCircumcircle(
571 const V2d<T>& p,
572 const V2d<T>& v1,
573 const V2d<T>& v2,
574 const V2d<T>& v3);
575
577CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool
578verticesShareEdge(const TriIndVec& aTris, const TriIndVec& bTris);
579
581template <typename T>
582CDT_EXPORT T distance(const V2d<T>& a, const V2d<T>& b);
583
585template <typename T>
586CDT_EXPORT T distanceSquared(const V2d<T>& a, const V2d<T>& b);
587
589CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool
590touchesSuperTriangle(const Triangle& t);
591
592namespace detail
593{
594
596template <typename T>
597bool isEncroachingOnEdge(
598 const V2d<T>& v,
599 const V2d<T>& edgeStart,
600 const V2d<T>& edgeEnd);
601
603template <typename T>
604T doubledArea(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
605
607template <typename T>
608T sineOfSmallestAngle(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
609
610} // namespace detail
611
613template <typename T>
614CDT_EXPORT T area(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
615
617template <typename T>
618CDT_EXPORT V2d<T> circumcenter(V2d<T> a, V2d<T> b, V2d<T> c);
619
621template <typename T>
622CDT_EXPORT T smallestAngle(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
623
625template <typename T>
626CDT_EXPORT T degToRad(T degrees);
627
628} // namespace CDT
629
630#ifndef CDT_USE_AS_COMPILED_LIBRARY
631#include "CDTUtils.hpp"
632#endif
633
634//*****************************************************************************
635// Specialize hash functions
636//*****************************************************************************
637#ifdef CDT_CXX11_IS_SUPPORTED
638namespace std
639#else
640namespace boost
641#endif
642{
643
644#ifdef CDT_USE_STRONG_TYPING
645
647template <>
648struct hash<CDT::VertInd>
649{
651 std::size_t operator()(const CDT::VertInd& vi) const
652 {
653 return std::hash<std::size_t>()(vi.t);
654 }
655};
656
658template <>
659struct hash<CDT::TriInd>
660{
662 std::size_t operator()(const CDT::TriInd& vi) const
663 {
664 return std::hash<std::size_t>()(vi.t);
665 }
666};
667
668#endif // CDT_USE_STRONG_TYPING
669
671template <>
672struct hash<CDT::Edge>
673{
675 std::size_t operator()(const CDT::Edge& e) const
676 {
677 return hashEdge(e);
678 }
679
680private:
681 static void hashCombine(std::size_t& seed, const CDT::VertInd& key)
682 {
683#ifdef CDT_CXX11_IS_SUPPORTED
684 typedef std::hash<CDT::VertInd> Hasher;
685#else
686 typedef boost::hash<CDT::VertInd> Hasher;
687#endif
688 seed ^= Hasher()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
689 }
690
691 static std::size_t hashEdge(const CDT::Edge& e)
692 {
693 std::size_t seed(0);
694 hashCombine(seed, e.v1());
695 hashCombine(seed, e.v2());
696 return seed;
697 }
698};
699
700} // namespace std/boost
701
702#endif // header guard
char couldnt_parse_cxx_standard[-1]
Error: couldn't parse standard.
Definition CDTUtils.h:24
Utilities and helpers - implementation.
Namespace containing triangulation functionality.
std::vector< Edge > EdgeVec
Vector of edges.
Definition CDTUtils.h:400
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.
Definition CDTUtils.hpp:204
unordered_set< Edge > EdgeUSet
Hash table of edges.
Definition CDTUtils.h:403
CDT_EXPORT T degToRad(T degrees)
Convert an angle from degrees to radians.
Definition CDTUtils.hpp:330
std::queue< TriInd > TriIndQueue
Queue of triangles.
Definition CDTUtils.h:402
VertInd edge_get_v2(const Edge &e)
Get edge second vertex.
Definition CDTUtils.h:389
CDT_EXPORT T area(const V2d< T > &a, const V2d< T > &b, const V2d< T > &c)
Surface area of a triangle ABC.
Definition CDTUtils.hpp:303
std::vector< TriInd > TriIndVec
Vector of triangle indices.
Definition CDTUtils.h:272
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index edgeNeighborInd(const VerticesArr3 &vv, VertInd iVedge1, VertInd iVedge2)
Index of triangle's neighbor opposed to an edge.
Definition CDTUtils.hpp:142
VertInd edge_get_v1(const Edge &e)
Get edge first vertex.
Definition CDTUtils.h:383
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opposedTriangleInd(const VerticesArr3 &vv, VertInd iVert)
Index of triangle's neighbor opposed to a vertex.
Definition CDTUtils.hpp:132
CDT_EXPORT PtLineLocation::Enum classifyOrientation(T orientation, T orientationTolerance=T(0))
Classify value of orient2d predicate.
Definition CDTUtils.hpp:64
array< TriInd, 3 > NeighborsArr3
array of three neighbors
Definition CDTUtils.h:274
CDT_EXPORT T distance(const V2d< T > &a, const V2d< T > &b)
Distance between two 2D points.
Definition CDTUtils.hpp:251
IndexSizeType VertInd
Vertex index.
Definition CDTUtils.h:254
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.
Definition CDTUtils.hpp:228
CDT_EXPORT Index cw(Index i)
Advance vertex or neighbor index clockwise.
Definition CDTUtils.hpp:28
array< VertInd, 3 > VerticesArr3
array of three vertex indices
Definition CDTUtils.h:273
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool touchesSuperTriangle(const Triangle &t)
Check if any of triangle's vertices belongs to a super-triangle.
Definition CDTUtils.hpp:262
array< T, 3 > arr3(const T &v0, const T &v1, const T &v2)
Needed for c++03 compatibility (no uniform initialization available)
Definition CDTUtils.h:175
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoVrt(Index neighborIndex)
Opposed vertex index from neighbor index.
Definition CDTUtils.hpp:118
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoNbr(Index vertIndex)
Opposed neighbor index from vertex index.
Definition CDTUtils.hpp:105
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index vertexInd(const VerticesArr3 &vv, VertInd iV)
If triangle has a given vertex return vertex-index.
Definition CDTUtils.hpp:187
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.
Definition CDTUtils.hpp:47
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.
Definition CDTUtils.hpp:53
CDT_EXPORT T distanceSquared(const V2d< T > &a, const V2d< T > &b)
Squared distance between two 2D points.
Definition CDTUtils.hpp:257
unordered_set< TriInd > TriIndUSet
Hash table of triangles.
Definition CDTUtils.h:404
CDT_EXPORT Index ccw(Index i)
Advance vertex or neighbor index counter-clockwise.
Definition CDTUtils.hpp:23
CDT_EXPORT V2d< T > circumcenter(V2d< T > a, V2d< T > b, V2d< T > c)
Position of ABC triangle circumcenter.
Definition CDTUtils.hpp:309
Edge edge_make(VertInd iV1, VertInd iV2)
Get edge second vertex.
Definition CDTUtils.h:395
bool operator!=(const CDT::V2d< T > &lhs, const CDT::V2d< T > &rhs)
If two 2D vectors are not exactly equal.
Definition CDTUtils.h:232
CDT_EXPORT Index edgeNeighbor(PtTriLocation::Enum location)
Neighbor index from a on-edge location.
Definition CDTUtils.hpp:40
unordered_map< TriInd, TriInd > TriIndUMap
Triangle hash map.
Definition CDTUtils.h:405
const T & getX_V2d(const V2d< T > &v)
X- coordinate getter for V2d.
Definition CDTUtils.h:211
bool operator==(const CDT::V2d< T > &lhs, const CDT::V2d< T > &rhs)
If two 2D vectors are exactly equal.
Definition CDTUtils.h:225
unsigned char Index
Index in triangle.
Definition CDTUtils.h:252
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd opposedTriangle(const Triangle &tri, VertInd iVert)
Given triangle and a vertex find opposed triangle.
Definition CDTUtils.hpp:198
CDT_EXPORT T smallestAngle(const V2d< T > &a, const V2d< T > &b, const V2d< T > &c)
Smallest angle of triangle ABC in radians.
Definition CDTUtils.hpp:322
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.
Definition CDTUtils.hpp:217
CDT_EXPORT bool isOnEdge(PtTriLocation::Enum location)
Check if location is classified as on any of three edges.
Definition CDTUtils.hpp:33
IndexSizeType TriInd
Triangle index.
Definition CDTUtils.h:256
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.
Definition CDTUtils.hpp:74
std::vector< Triangle > TriangleVec
Vector of triangles.
Definition CDTUtils.h:467
BOOST_STRONG_TYPEDEF(unsigned char, Index)
Index in triangle.
std::queue< Edge > EdgeQueue
Queue of edges.
Definition CDTUtils.h:401
CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opposedVertexInd(const NeighborsArr3 &nn, TriInd iTopo)
Index of triangle's vertex opposed to a triangle.
Definition CDTUtils.hpp:176
const T & getY_V2d(const V2d< T > &v)
Y-coordinate getter for V2d.
Definition CDTUtils.h:218
Box2d< T > & envelopPoint(const T x, const T y)
Envelop box around a point with given coordinates.
Definition CDTUtils.h:296
Box2d()
Box that doesn't contain any point.
Definition CDTUtils.h:284
V2d< T > max
max box corner
Definition CDTUtils.h:281
Box2d< T > & envelopPoint(const V2d< T > &p)
Envelop box around a point.
Definition CDTUtils.h:290
Box2d< T > & envelopPoints(TVertexIter first, TVertexIter last, TGetVertexCoordX getX, TGetVertexCoordY getY)
Envelop box around a collection of custom points.
Definition CDTUtils.h:310
V2d< T > min
min box corner
Definition CDTUtils.h:280
Box2d< T > & envelopPoints(const std::vector< V2d< T > > &vertices)
Envelop box around a collection of points.
Definition CDTUtils.h:324
Edge connecting two vertices: vertex with smaller index is always first.
Definition CDTUtils.h:334
const std::pair< VertInd, VertInd > & verts() const
Edges' vertices.
Definition CDTUtils.h:373
bool operator<(const Edge &other) const
Less-than operator: orders by (v1, v2); used to get a deterministic order out of hash-set iteration (...
Definition CDTUtils.h:355
bool operator==(const Edge &other) const
Equals operator.
Definition CDTUtils.h:342
VertInd v1() const
V1 getter.
Definition CDTUtils.h:361
bool operator!=(const Edge &other) const
Not-equals operator.
Definition CDTUtils.h:348
Edge(const VertInd iV1, const VertInd iV2)
Constructor.
Definition CDTUtils.h:336
VertInd v2() const
V2 getter.
Definition CDTUtils.h:367
Relative location of point to a line.
Definition CDTUtils.h:499
Location of point on a triangle.
Definition CDTUtils.h:477
VerticesArr3 vertices
triangle's three vertices
Definition CDTUtils.h:417
std::pair< TriInd, VertInd > prev(const VertInd i) const
Previous triangle adjacent to a vertex (counter-clockwise)
Definition CDTUtils.h:450
NeighborsArr3 neighbors
triangle's three neighbors
Definition CDTUtils.h:418
bool containsVertex(const VertInd i) const
Check if triangle contains a vertex.
Definition CDTUtils.h:461
Triangle(const VerticesArr3 &vertices, const NeighborsArr3 &neighbors)
Triangle with given vertices and neighbors.
Definition CDTUtils.h:427
Triangle()
Triangle with no vertices and no neighbors.
Definition CDTUtils.h:421
std::pair< TriInd, VertInd > next(const VertInd i) const
Next triangle adjacent to a vertex (clockwise)
Definition CDTUtils.h:434
2D vector
Definition CDTUtils.h:192
V2d(const T x, const T y)
Vertex with given coordinates.
Definition CDTUtils.h:203
V2d()
Vertex with zero coordinates.
Definition CDTUtils.h:197
std::size_t operator()(const CDT::Edge &e) const
Hash operator.
Definition CDTUtils.h:675
std::size_t operator()(const CDT::TriInd &vi) const
Hash operator.
Definition CDTUtils.h:662
std::size_t operator()(const CDT::VertInd &vi) const
Hash operator.
Definition CDTUtils.h:651