CDT  2.1.0
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/tuple/tuple_comparison.hpp>
101#include <boost/unordered_map.hpp>
102#include <boost/unordered_set.hpp>
103namespace CDT
104{
105using boost::array;
106using boost::get;
107using boost::make_tuple;
108using boost::tie;
109using boost::tuple;
110using boost::unordered_map;
111using boost::unordered_set;
112
113template <typename T>
114std::string to_string(const T& value)
115{
116 return boost::lexical_cast<std::string>(value);
117}
118} // namespace CDT
119#endif
120
123#ifdef _MSC_VER
124#define CDT_ENSURE_PRECISE_MATH \
125 __pragma(float_control(push)) __pragma(float_control(precise, on)) \
126 __pragma(fp_contract(off))
127#elif defined(__clang__)
128#define CDT_ENSURE_PRECISE_MATH \
129 _Pragma("float_control(push)") _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") _Pragma("GCC optimize(\"no-fast-math\")") \
134 _Pragma("GCC optimize(\"fp-contract=off\")")
135#else
136#define CDT_ENSURE_PRECISE_MATH _Pragma("STDC FP_CONTRACT OFF")
137#endif
138
140#if defined(_MSC_VER)
141#define CDT_RESTORE_MATH_SETTINGS __pragma(float_control(pop))
142#elif defined(__clang__)
143#define CDT_RESTORE_MATH_SETTINGS _Pragma("float_control(pop)")
144#elif defined(__GNUC__)
145#define CDT_RESTORE_MATH_SETTINGS _Pragma("GCC pop_options")
146#else
147#define CDT_RESTORE_MATH_SETTINGS _Pragma("STDC FP_CONTRACT DEFAULT")
148#endif
149
151#ifdef CDT_ENSURE_PRECISE_MATH_IN_CONSTRUCTIONS
152#define CDT_ENSURE_PRECISE_MATH_FOR_CONSTRUCTIONS CDT_ENSURE_PRECISE_MATH
153#define CDT_RESTORE_MATH_SETTINGS_FOR_CONSTRUCTIONS CDT_RESTORE_MATH_SETTINGS
154#else
155#define CDT_ENSURE_PRECISE_MATH_FOR_CONSTRUCTIONS
156#define CDT_RESTORE_MATH_SETTINGS_FOR_CONSTRUCTIONS
157#endif
158
159namespace CDT
160{
161
162template <typename T>
163void handleException(const T& error)
164{
165#ifdef CDT_DISABLE_EXCEPTIONS
166 std::terminate();
167#else
168 throw error;
169#endif
170}
171
173template <typename T>
174array<T, 3> arr3(const T& v0, const T& v1, const T& v2)
175{
176 const array<T, 3> out = {v0, v1, v2};
177 return out;
178}
179
181template <typename T>
182array<T, 3> arr3(const T& v)
183{
184 const array<T, 3> out = {v, v, v};
185 return out;
186}
187
189template <typename T>
190struct CDT_EXPORT V2d
191{
192 T x;
193 T y;
194
197 : x(T(0))
198 , y(T(0))
199 {}
200
202 V2d(const T x, const T y)
203 : x(x)
204 , y(y)
205 {}
206};
207
209template <typename T>
210const T& getX_V2d(const V2d<T>& v)
211{
212 return v.x;
213}
214
216template <typename T>
217const T& getY_V2d(const V2d<T>& v)
218{
219 return v.y;
220}
221
223template <typename T>
224bool operator==(const CDT::V2d<T>& lhs, const CDT::V2d<T>& rhs)
225{
226 return lhs.x == rhs.x && lhs.y == rhs.y;
227}
228
230template <typename T>
231bool operator!=(const CDT::V2d<T>& lhs, const CDT::V2d<T>& rhs)
232{
233 return !(lhs == rhs);
234}
235
236#ifdef CDT_USE_64_BIT_INDEX_TYPE
237typedef unsigned long long IndexSizeType;
238#else
239typedef unsigned int IndexSizeType;
240#endif
241
242#ifdef CDT_USE_STRONG_TYPING
248BOOST_STRONG_TYPEDEF(IndexSizeType, TriInd);
249#else
251typedef unsigned char Index;
253typedef IndexSizeType VertInd;
255typedef IndexSizeType TriInd;
256#endif
257
259const static Index invalidIndex(std::numeric_limits<Index>::max());
261const static IndexSizeType
262 invalidIndexSizeType(std::numeric_limits<IndexSizeType>::max());
265const static IndexSizeType nSuperTriVerts(3);
267const static TriInd noNeighbor(invalidIndexSizeType);
269const static VertInd noVertex(invalidIndexSizeType);
270
271typedef std::vector<TriInd> TriIndVec;
272typedef array<VertInd, 3> VerticesArr3;
273typedef array<TriInd, 3> NeighborsArr3;
274
276template <typename T>
277struct CDT_EXPORT Box2d
278{
281
284 : min(std::numeric_limits<T>::max(), std::numeric_limits<T>::max())
285 , max(-std::numeric_limits<T>::max(), -std::numeric_limits<T>::max())
286 {}
287
290 {
291 return envelopPoint(p.x, p.y);
292 }
293
295 Box2d<T>& envelopPoint(const T x, const T y)
296 {
297 min.x = std::min(x, min.x);
298 max.x = std::max(x, max.x);
299 min.y = std::min(y, min.y);
300 max.y = std::max(y, max.y);
301 return *this;
302 }
303
305 template <
306 typename TVertexIter,
307 typename TGetVertexCoordX,
308 typename TGetVertexCoordY>
310 TVertexIter first,
311 TVertexIter last,
312 TGetVertexCoordX getX,
313 TGetVertexCoordY getY)
314 {
315 for(; first != last; ++first)
316 {
317 envelopPoint(getX(*first), getY(*first));
318 }
319 return *this;
320 }
321
323 Box2d<T>& envelopPoints(const std::vector<V2d<T> >& vertices)
324 {
325 return envelopPoints(
326 vertices.begin(), vertices.end(), getX_V2d<T>, getY_V2d<T>);
327 }
328};
329
332struct CDT_EXPORT Edge
333{
335 Edge(const VertInd iV1, const VertInd iV2)
336 : m_vertices(
337 iV1 < iV2 ? std::make_pair(iV1, iV2) : std::make_pair(iV2, iV1))
338 {}
339
341 bool operator==(const Edge& other) const
342 {
343 return m_vertices == other.m_vertices;
344 }
345
347 bool operator!=(const Edge& other) const
348 {
349 return !(this->operator==(other));
350 }
351
354 bool operator<(const Edge& other) const
355 {
356 return m_vertices < other.m_vertices;
357 }
358
360 VertInd v1() const
361 {
362 return m_vertices.first;
363 }
364
366 VertInd v2() const
367 {
368 return m_vertices.second;
369 }
370
372 const std::pair<VertInd, VertInd>& verts() const
373 {
374 return m_vertices;
375 }
376
377private:
378 std::pair<VertInd, VertInd> m_vertices;
379};
380
382inline VertInd edge_get_v1(const Edge& e)
383{
384 return e.v1();
385}
386
388inline VertInd edge_get_v2(const Edge& e)
389{
390 return e.v2();
391}
392
395{
396 return Edge(iV1, iV2);
397}
398
399typedef std::vector<Edge> EdgeVec;
400typedef std::queue<Edge> EdgeQueue;
401typedef std::queue<TriInd> TriIndQueue;
402typedef unordered_set<Edge> EdgeUSet;
403typedef unordered_set<TriInd> TriIndUSet;
404typedef unordered_map<TriInd, TriInd> TriIndUMap;
405
407/*
408 * v3
409 * /\
410 * n3/ \n2
411 * /____\
412 * v1 n1 v2
413 */
414struct CDT_EXPORT Triangle
415{
418
421 : vertices(arr3(noVertex))
422 , neighbors(arr3(noNeighbor))
423 {}
424
430
433 std::pair<TriInd, VertInd> next(const VertInd i) const
434 {
435 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
436 if(vertices[0] == i)
437 {
438 return std::make_pair(neighbors[0], vertices[1]);
439 }
440 if(vertices[1] == i)
441 {
442 return std::make_pair(neighbors[1], vertices[2]);
443 }
444 return std::make_pair(neighbors[2], vertices[0]);
445 }
446
449 std::pair<TriInd, VertInd> prev(const VertInd i) const
450 {
451 assert(vertices[0] == i || vertices[1] == i || vertices[2] == i);
452 if(vertices[0] == i)
453 return std::make_pair(neighbors[2], vertices[2]);
454 if(vertices[1] == i)
455 return std::make_pair(neighbors[0], vertices[0]);
456 return std::make_pair(neighbors[1], vertices[1]);
457 }
458
460 bool containsVertex(const VertInd i) const
461 {
462 return std::find(vertices.begin(), vertices.end(), i) != vertices.end();
463 }
464};
465
466typedef std::vector<Triangle> TriangleVec;
467
469CDT_EXPORT Index ccw(Index i);
470
472CDT_EXPORT Index cw(Index i);
473
475struct CDT_EXPORT PtTriLocation
476{
478 enum Enum
479 {
480 Inside,
481 Outside,
482 OnEdge1,
483 OnEdge2,
484 OnEdge3,
485 OnVertex,
486 };
487};
488
490CDT_EXPORT bool isOnEdge(PtTriLocation::Enum location);
491
494CDT_EXPORT Index edgeNeighbor(PtTriLocation::Enum location);
495
497struct CDT_EXPORT PtLineLocation
498{
500 enum Enum
501 {
502 Left,
503 Right,
504 OnLine,
505 };
506};
507
509template <typename T>
510CDT_EXPORT T orient2D(const V2d<T>& p, const V2d<T>& v1, const V2d<T>& v2);
511
513template <typename T>
515 const V2d<T>& p,
516 const V2d<T>& v1,
517 const V2d<T>& v2,
518 T orientationTolerance = T(0));
519
521template <typename T>
522CDT_EXPORT PtLineLocation::Enum
523classifyOrientation(T orientation, T orientationTolerance = T(0));
524
526template <typename T>
528 const V2d<T>& p,
529 const V2d<T>& v1,
530 const V2d<T>& v2,
531 const V2d<T>& v3);
532
534CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoNbr(Index vertIndex);
535
537CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index opoVrt(Index neighborIndex);
538
540CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
541opposedTriangleInd(const VerticesArr3& vv, VertInd iVert);
542
544CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
545edgeNeighborInd(const VerticesArr3& vv, VertInd iVedge1, VertInd iVedge2);
546
548CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
549opposedVertexInd(const NeighborsArr3& nn, TriInd iTopo);
550
552CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY Index
553vertexInd(const VerticesArr3& vv, VertInd iV);
554
556CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd
557opposedTriangle(const Triangle& tri, VertInd iVert);
558
560CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY TriInd
561edgeNeighbor(const Triangle& tri, VertInd iVedge1, VertInd iVedge2);
562
564CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY VertInd
565opposedVertex(const Triangle& tri, TriInd iTopo);
566
568template <typename T>
569CDT_EXPORT bool isInCircumcircle(
570 const V2d<T>& p,
571 const V2d<T>& v1,
572 const V2d<T>& v2,
573 const V2d<T>& v3);
574
576CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool
577verticesShareEdge(const TriIndVec& aTris, const TriIndVec& bTris);
578
580template <typename T>
581CDT_EXPORT T distance(const V2d<T>& a, const V2d<T>& b);
582
584template <typename T>
585CDT_EXPORT T distanceSquared(const V2d<T>& a, const V2d<T>& b);
586
588CDT_EXPORT CDT_INLINE_IF_HEADER_ONLY bool
589touchesSuperTriangle(const Triangle& t);
590
591namespace detail
592{
593
595template <typename T>
596bool isEncroachingOnEdge(
597 const V2d<T>& v,
598 const V2d<T>& edgeStart,
599 const V2d<T>& edgeEnd);
600
602template <typename T>
603T doubledArea(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
604
606template <typename T>
607T sineOfSmallestAngle(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
608
609} // namespace detail
610
612template <typename T>
613CDT_EXPORT T area(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
614
616template <typename T>
617CDT_EXPORT V2d<T> circumcenter(V2d<T> a, V2d<T> b, V2d<T> c);
618
620template <typename T>
621CDT_EXPORT T smallestAngle(const V2d<T>& a, const V2d<T>& b, const V2d<T>& c);
622
624template <typename T>
625CDT_EXPORT T degToRad(T degrees);
626
627} // namespace CDT
628
629#ifndef CDT_USE_AS_COMPILED_LIBRARY
630#include "CDTUtils.hpp"
631#endif
632
633//*****************************************************************************
634// Specialize hash functions
635//*****************************************************************************
636#ifdef CDT_CXX11_IS_SUPPORTED
637namespace std
638#else
639namespace boost
640#endif
641{
642
643#ifdef CDT_USE_STRONG_TYPING
644
646template <>
647struct hash<CDT::VertInd>
648{
650 std::size_t operator()(const CDT::VertInd& vi) const
651 {
652 return std::hash<std::size_t>()(vi.t);
653 }
654};
655
657template <>
658struct hash<CDT::TriInd>
659{
661 std::size_t operator()(const CDT::TriInd& vi) const
662 {
663 return std::hash<std::size_t>()(vi.t);
664 }
665};
666
667#endif // CDT_USE_STRONG_TYPING
668
670template <>
671struct hash<CDT::Edge>
672{
674 std::size_t operator()(const CDT::Edge& e) const
675 {
676 return hashEdge(e);
677 }
678
679private:
680 static void hashCombine(std::size_t& seed, const CDT::VertInd& key)
681 {
682#ifdef CDT_CXX11_IS_SUPPORTED
683 typedef std::hash<CDT::VertInd> Hasher;
684#else
685 typedef boost::hash<CDT::VertInd> Hasher;
686#endif
687 seed ^= Hasher()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
688 }
689
690 static std::size_t hashEdge(const CDT::Edge& e)
691 {
692 std::size_t seed(0);
693 hashCombine(seed, e.v1());
694 hashCombine(seed, e.v2());
695 return seed;
696 }
697};
698
699} // namespace std/boost
700
701#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:399
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:402
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:401
VertInd edge_get_v2(const Edge &e)
Get edge second vertex.
Definition CDTUtils.h:388
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:271
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:382
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:273
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:253
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:272
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:174
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:403
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:394
bool operator!=(const CDT::V2d< T > &lhs, const CDT::V2d< T > &rhs)
If two 2D vectors are not exactly equal.
Definition CDTUtils.h:231
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:404
const T & getX_V2d(const V2d< T > &v)
X- coordinate getter for V2d.
Definition CDTUtils.h:210
bool operator==(const CDT::V2d< T > &lhs, const CDT::V2d< T > &rhs)
If two 2D vectors are exactly equal.
Definition CDTUtils.h:224
unsigned char Index
Index in triangle.
Definition CDTUtils.h:251
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:255
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:466
BOOST_STRONG_TYPEDEF(unsigned char, Index)
Index in triangle.
std::queue< Edge > EdgeQueue
Queue of edges.
Definition CDTUtils.h:400
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:217
Box2d< T > & envelopPoint(const T x, const T y)
Envelop box around a point with given coordinates.
Definition CDTUtils.h:295
Box2d()
Box that doesn't contain any point.
Definition CDTUtils.h:283
V2d< T > max
max box corner
Definition CDTUtils.h:280
Box2d< T > & envelopPoint(const V2d< T > &p)
Envelop box around a point.
Definition CDTUtils.h:289
Box2d< T > & envelopPoints(TVertexIter first, TVertexIter last, TGetVertexCoordX getX, TGetVertexCoordY getY)
Envelop box around a collection of custom points.
Definition CDTUtils.h:309
V2d< T > min
min box corner
Definition CDTUtils.h:279
Box2d< T > & envelopPoints(const std::vector< V2d< T > > &vertices)
Envelop box around a collection of points.
Definition CDTUtils.h:323
Edge connecting two vertices: vertex with smaller index is always first.
Definition CDTUtils.h:333
const std::pair< VertInd, VertInd > & verts() const
Edges' vertices.
Definition CDTUtils.h:372
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:354
bool operator==(const Edge &other) const
Equals operator.
Definition CDTUtils.h:341
VertInd v1() const
V1 getter.
Definition CDTUtils.h:360
bool operator!=(const Edge &other) const
Not-equals operator.
Definition CDTUtils.h:347
Edge(const VertInd iV1, const VertInd iV2)
Constructor.
Definition CDTUtils.h:335
VertInd v2() const
V2 getter.
Definition CDTUtils.h:366
Relative location of point to a line.
Definition CDTUtils.h:498
Location of point on a triangle.
Definition CDTUtils.h:476
VerticesArr3 vertices
triangle's three vertices
Definition CDTUtils.h:416
std::pair< TriInd, VertInd > prev(const VertInd i) const
Previous triangle adjacent to a vertex (counter-clockwise)
Definition CDTUtils.h:449
NeighborsArr3 neighbors
triangle's three neighbors
Definition CDTUtils.h:417
bool containsVertex(const VertInd i) const
Check if triangle contains a vertex.
Definition CDTUtils.h:460
Triangle(const VerticesArr3 &vertices, const NeighborsArr3 &neighbors)
Triangle with given vertices and neighbors.
Definition CDTUtils.h:426
Triangle()
Triangle with no vertices and no neighbors.
Definition CDTUtils.h:420
std::pair< TriInd, VertInd > next(const VertInd i) const
Next triangle adjacent to a vertex (clockwise)
Definition CDTUtils.h:433
2D vector
Definition CDTUtils.h:191
V2d(const T x, const T y)
Vertex with given coordinates.
Definition CDTUtils.h:202
V2d()
Vertex with zero coordinates.
Definition CDTUtils.h:196
std::size_t operator()(const CDT::Edge &e) const
Hash operator.
Definition CDTUtils.h:674
std::size_t operator()(const CDT::TriInd &vi) const
Hash operator.
Definition CDTUtils.h:661
std::size_t operator()(const CDT::VertInd &vi) const
Hash operator.
Definition CDTUtils.h:650