MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/MRMeshFwd.h
Go to the documentation of this file.
1#pragma once
2
3#include "config.h"
4
6
7// Not-zero _ITERATOR_DEBUG_LEVEL in Microsoft STL greatly reduces the performance of STL containers.
8//
9// Pre-build binaries from MeshLib distribution are prepared with _ITERATOR_DEBUG_LEVEL=0,
10// and if you build MeshLib by yourself then _ITERATOR_DEBUG_LEVEL=0 is also selected see
11// 1) vcpkg/triplets/x64-windows-meshlib.cmake and
12// 2) MeshLib/source/common.props
13// Please note that all other modules (.exe, .dll, .lib) with MS STL calls in your application also need
14// to define exactly the same value of _ITERATOR_DEBUG_LEVEL to be operational after linking.
15//
16// If you deliberately would like to work with not zero _ITERATOR_DEBUG_LEVEL, then please define
17// additionally MR_ITERATOR_DEBUG_LEVEL with the same value to indicate that it is done intentionally
18// (and you are ok with up to 100x slowdown).
19//
20#if defined _MSC_VER
21 #if !defined _ITERATOR_DEBUG_LEVEL
22 #define _ITERATOR_DEBUG_LEVEL 0
23 #endif
24 #if !defined MR_ITERATOR_DEBUG_LEVEL
25 #define MR_ITERATOR_DEBUG_LEVEL 0
26 #endif
27 #if _ITERATOR_DEBUG_LEVEL != MR_ITERATOR_DEBUG_LEVEL
28 #error _ITERATOR_DEBUG_LEVEL is inconsistent with MeshLib
29 #endif
30#endif
31
32// Check C++ version.
33#ifdef _MSC_VER
34#define MR_CPP_STANDARD_DATE _MSVC_LANG
35#else
36#define MR_CPP_STANDARD_DATE __cplusplus
37#endif
38// Note `201709`. C++20 usually sets `202002`, while C++17 sets `201703`.
39// This `201709` is what GCC 10 sets on `-std=c++20` (presumably to indicate incomplete implementation?).
40// Other compilers we use don't have this issue.
41// Also note `__CUDACC__` - currently our Cuda code is compiled as C++17 (compiler doesn't support C++20?),
42// and we carefully avoid headers incomaptible with C++17.
43#if MR_CPP_STANDARD_DATE < 201709 && !defined(__CUDACC__)
44#error Must enable C++20 or newer!
45#endif
46// -- Curently we have no macros that don't work with the old preprocessor. Leaving the check here to possibly be enabled later.
47// Reject old MSVC preprocessor.
48// Note that we exclude Cuda here. Not 100% sure if it has a good preprocessor, or we just avoid including the headers sensitive to it in Cuda.
49// #if defined(_MSC_VER) && !defined(__clang__) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL == 1) && !defined(__CUDACC__)
50// #error MSVC users must enable the new standard-conformant preprocessor using `/Zc:preprocessor`!
51// #endif
52
53
54#if defined(__GNUC__) && __GNUC__ == 13
55 #pragma GCC diagnostic push
56 #pragma GCC diagnostic ignored "-Warray-bounds"
57 #pragma GCC diagnostic ignored "-Wstringop-overflow"
58#endif
59
60#include <array>
61
62#if defined(__GNUC__) && __GNUC__ == 13
63 #pragma GCC diagnostic pop
64#endif
65
66#include <vector>
67#include <string>
68#include <parallel_hashmap/phmap_fwd_decl.h>
69#include <functional>
70
71#ifdef _WIN32
72# ifdef MRMesh_EXPORTS
73# define MRMESH_API __declspec(dllexport)
74# else
75# define MRMESH_API __declspec(dllimport)
76# endif
77# define MRMESH_CLASS
78#else
79# define MRMESH_API __attribute__((visibility("default")))
80// to fix undefined reference to `typeinfo/vtable`
81// Also it's important to use this on any type for which `typeid` is used in multiple shared libraries, and then passed across library boundaries.
82// Otherwise on Mac the resulting typeids will incorrectly compare not equal.
83# define MRMESH_CLASS __attribute__((visibility("default")))
84#endif
85
86namespace MR
87{
88
89struct NoInit {};
90inline constexpr NoInit noInit;
91template <typename T> struct MRMESH_CLASS NoDefInit;
92
105
106MR_CANONICAL_TYPEDEFS( (template <typename T> class MRMESH_CLASS), Id,
107 ( EdgeId, Id<EdgeTag> )
108 ( UndirectedEdgeId, Id<UndirectedEdgeTag> )
109 ( FaceId, Id<FaceTag> )
110 ( VertId, Id<VertTag> )
111 ( PixelId, Id<PixelTag> )
112 ( VoxelId, Id<VoxelTag> )
113 ( RegionId, Id<RegionTag> )
114 ( NodeId, Id<NodeTag> )
115 ( ObjId, Id<ObjTag> )
116 ( TextureId, Id<TextureTag> )
117 ( GraphVertId, Id<GraphVertTag> )
118 ( GraphEdgeId, Id<GraphEdgeTag> )
119)
120
121template <typename T, typename I = size_t> class MRMESH_CLASS Buffer;
122struct PackMapping;
123
124class ViewportId;
125class ViewportMask;
126
127struct UnorientedTriangle;
130
131using EdgePath = std::vector<EdgeId>;
132using EdgeLoop = std::vector<EdgeId>;
133using EdgeLoops = std::vector<EdgeLoop>;
134
136
137MR_CANONICAL_TYPEDEFS( (template <typename T> class MRMESH_CLASS), TaggedBitSet,
138 ( FaceBitSet, TaggedBitSet<FaceTag> )
139 ( VertBitSet, TaggedBitSet<VertTag> )
140 ( EdgeBitSet, TaggedBitSet<EdgeTag> )
141 ( UndirectedEdgeBitSet, TaggedBitSet<UndirectedEdgeTag> )
142 ( PixelBitSet, TaggedBitSet<PixelTag> )
143 ( VoxelBitSet, TaggedBitSet<VoxelTag> )
144 ( RegionBitSet, TaggedBitSet<RegionTag> )
145 ( NodeBitSet, TaggedBitSet<NodeTag> )
146 ( ObjBitSet, TaggedBitSet<ObjTag> )
147 ( TextureBitSet, TaggedBitSet<TextureTag> )
148 ( GraphVertBitSet, TaggedBitSet<GraphVertTag> )
149 ( GraphEdgeBitSet, TaggedBitSet<GraphEdgeTag> )
150)
151
152MR_CANONICAL_TYPEDEFS( (template <typename T> class MRMESH_CLASS), SetBitIteratorT,
154 ( FaceSetBitIterator, SetBitIteratorT<FaceBitSet> )
155 ( VertSetBitIterator, SetBitIteratorT<VertBitSet> )
156 ( EdgeSetBitIterator, SetBitIteratorT<EdgeBitSet> )
157 ( UndirectedEdgeSetBitIterator, SetBitIteratorT<UndirectedEdgeBitSet> )
158)
159
160struct Color;
161
162MR_CANONICAL_TYPEDEFS( (template <typename T> struct), MRMESH_CLASS Vector2,
163 ( Vector2b, Vector2<bool> )
164 ( Vector2i, Vector2<int> )
165 ( Vector2ll, Vector2<long long> )
166 ( Vector2f, Vector2<float> )
167 ( Vector2d, Vector2<double> )
168)
169
170MR_CANONICAL_TYPEDEFS( (template <typename T> struct), MRMESH_CLASS Vector3,
171 ( Vector3b, Vector3<bool> )
172 ( Vector3i, Vector3<int> )
173 ( Vector3ll, Vector3<long long> )
174 ( Vector3f, Vector3<float> )
175 ( Vector3d, Vector3<double> )
176)
177
178MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Vector4,
179 ( Vector4b, Vector4<bool> )
180 ( Vector4i, Vector4<int> )
181 ( Vector4ll, Vector4<long long> )
182 ( Vector4f, Vector4<float> )
183 ( Vector4d, Vector4<double> )
184)
185
186MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix2,
187 ( Matrix2b, Matrix2<bool> )
188 ( Matrix2i, Matrix2<int> )
189 ( Matrix2ll, Matrix2<long long> )
190 ( Matrix2f, Matrix2<float> )
191 ( Matrix2d, Matrix2<double> )
192)
193
194MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix3,
195 ( Matrix3b, Matrix3<bool> )
196 ( Matrix3i, Matrix3<int> )
197 ( Matrix3ll, Matrix3<long long> )
198 ( Matrix3f, Matrix3<float> )
199 ( Matrix3d, Matrix3<double> )
200)
201
202MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix4,
203 ( Matrix4b, Matrix4<bool> )
204 ( Matrix4i, Matrix4<int> )
205 ( Matrix4ll, Matrix4<long long> )
206 ( Matrix4f, Matrix4<float> )
207 ( Matrix4d, Matrix4<double> )
208)
209
210MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix2,
211 ( SymMatrix2b, SymMatrix2<bool> )
212 ( SymMatrix2i, SymMatrix2<int> )
213 ( SymMatrix2ll, SymMatrix2<long long> )
214 ( SymMatrix2f, SymMatrix2<float> )
215 ( SymMatrix2d, SymMatrix2<double> )
216)
217
218MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix3,
220 ( SymMatrix3i, SymMatrix3<int> )
221 ( SymMatrix3ll, SymMatrix3<long long> )
222 ( SymMatrix3f, SymMatrix3<float> )
223 ( SymMatrix3d, SymMatrix3<double> )
224)
225
226MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix4,
227 ( SymMatrix4b, SymMatrix4<bool> )
228 ( SymMatrix4i, SymMatrix4<int> )
229 ( SymMatrix4ll, SymMatrix4<long long> )
230 ( SymMatrix4f, SymMatrix4<float> )
231 ( SymMatrix4d, SymMatrix4<double> )
232)
233
234MR_CANONICAL_TYPEDEFS( (template <typename V> struct), AffineXf,
236 ( AffineXf2d, AffineXf<Vector2<double>> )
237 ( AffineXf3f, AffineXf<Vector3<float>> )
238 ( AffineXf3d, AffineXf<Vector3<double>> )
239)
240template <typename T> using AffineXf2 = AffineXf<Vector2<T>>;
241template <typename T> using AffineXf3 = AffineXf<Vector3<T>>;
242
243MR_CANONICAL_TYPEDEFS( (template <typename T> struct), RigidXf3,
244 ( RigidXf3f, RigidXf3<float> )
245 ( RigidXf3d, RigidXf3<double> )
246)
247
248MR_CANONICAL_TYPEDEFS( (template <typename T> struct), RigidScaleXf3,
250 ( RigidScaleXf3d, RigidScaleXf3<double> )
251)
252
255
256MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Sphere,
257 ( Sphere2f, Sphere<Vector2<float>> )
258 ( Sphere2d, Sphere<Vector2<double>> )
259 ( Sphere3f, Sphere<Vector3<float>> )
260 ( Sphere3d, Sphere<Vector3<double>> )
261)
262template <typename T> using Sphere2 = Sphere<Vector2<T>>;
263template <typename T> using Sphere3 = Sphere<Vector3<T>>;
264
265MR_CANONICAL_TYPEDEFS( (template <typename V> struct), Line,
266 ( Line2f, Line<Vector2<float>> )
267 ( Line2d, Line<Vector2<double>> )
268 ( Line3f, Line<Vector3<float>> )
269 ( Line3d, Line<Vector3<double>> )
270)
271template <typename T> using Line2 = Line<Vector2<T>>;
272template <typename T> using Line3 = Line<Vector3<T>>;
273
274MR_CANONICAL_TYPEDEFS( (template <typename V> struct), LineSegm,
275 ( LineSegm2f, LineSegm<Vector2<float>> )
276 ( LineSegm2d, LineSegm<Vector2<double>> )
277 ( LineSegm3f, LineSegm<Vector3<float>> )
278 ( LineSegm3d, LineSegm<Vector3<double>> )
279)
280template <typename T> using LineSegm2 = LineSegm<Vector2<T>>;
281template <typename T> using LineSegm3 = LineSegm<Vector3<T>>;
282
283MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Parabola,
284 ( Parabolaf, Parabola<float> )
285 ( Parabolad, Parabola<double> )
286)
287
288MR_CANONICAL_TYPEDEFS( (template <typename T> class), BestFitParabola,
290 ( BestFitParabolad, BestFitParabola<double> )
291)
292
293MR_CANONICAL_TYPEDEFS( (template <typename T> class), Cylinder3,
295 ( Cylinder3d, Cylinder3<double> )
296)
297
298MR_CANONICAL_TYPEDEFS( (template <typename T> class), Cone3,
299 ( Cone3f, Cone3<float> )
300 ( Cone3d, Cone3<double> )
301)
302
303// No canonical typedefs here, because those ultimately boil to `std::vector`, which isn't under our control.
304template <typename V> using Contour = std::vector<V>;
305template <typename T> using Contour2 = Contour<Vector2<T>>;
306template <typename T> using Contour3 = Contour<Vector3<T>>;
307using Contour2d = Contour2<double>;
308using Contour2f = Contour2<float>;
309using Contour3d = Contour3<double>;
310using Contour3f = Contour3<float>;
311
312template <typename V> using Contours = std::vector<Contour<V>>;
313template <typename T> using Contours2 = Contours<Vector2<T>>;
314template <typename T> using Contours3 = Contours<Vector3<T>>;
315using Contours2d = Contours2<double>;
316using Contours2f = Contours2<float>;
317using Contours3d = Contours3<double>;
318using Contours3f = Contours3<float>;
319
320template <typename T> using Contour3 = Contour<Vector3<T>>;
321using Contour3d = Contour3<double>;
322using Contours3d = std::vector<Contour3d>;
323using Contour3f = Contour3<float>;
324using Contours3f = std::vector<Contour3f>;
325
326MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Plane3,
327 ( Plane3f, Plane3<float> )
328 ( Plane3d, Plane3<double> )
329)
330
331MR_CANONICAL_TYPEDEFS( (template <typename V> struct MRMESH_CLASS), Box,
332 ( Box1i, Box<int> )
333 ( Box1ll, Box<long long> )
334 ( Box1f, Box<float> )
335 ( Box1d, Box<double> )
336 ( Box2i, Box<Vector2<int>> )
337 ( Box2ll, Box<Vector2<long long>> )
338 ( Box2f, Box<Vector2<float>> )
339 ( Box2d, Box<Vector2<double>> )
340 ( Box3i, Box<Vector3<int>> )
341 ( Box3ll, Box<Vector3<long long>> )
342 ( Box3f, Box<Vector3<float>> )
343 ( Box3d, Box<Vector3<double>> )
344)
345template <typename T> using MinMax = Box<T>;
346using MinMaxf = MinMax<float>;
347using MinMaxd = MinMax<double>;
348
349template <typename T> using Box1 = Box<T>;
350template <typename T> using Box2 = Box<Vector2<T>>;
351template <typename T> using Box3 = Box<Vector3<T>>;
352
353MR_CANONICAL_TYPEDEFS( (template <typename V> struct MRMESH_CLASS), Ball,
354 ( Ball1f, Ball<float> )
355 ( Ball1d, Ball<double> )
356 ( Ball2f, Ball<Vector2<float>> )
357 ( Ball2d, Ball<Vector2<double>> )
358 ( Ball3f, Ball<Vector3<float>> )
359 ( Ball3d, Ball<Vector3<double>> )
360)
361template <typename T> using Ball1 = Ball<T>;
362template <typename T> using Ball2 = Ball<Vector2<T>>;
363template <typename T> using Ball3 = Ball<Vector3<T>>;
364
365MR_CANONICAL_TYPEDEFS( (template <typename V> struct), QuadraticForm,
366 ( QuadraticForm2f, QuadraticForm<Vector2<float>> )
367 ( QuadraticForm2d, QuadraticForm<Vector2<double>> )
368 ( QuadraticForm3f, QuadraticForm<Vector3<float>> )
369 ( QuadraticForm3d, QuadraticForm<Vector3<double>> )
370)
371template <typename T> using QuadraticForm2 = QuadraticForm<Vector2<T>>;
372template <typename T> using QuadraticForm3 = QuadraticForm<Vector3<T>>;
373
374MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Quaternion,
375 ( Quaternionf, Quaternion<float> )
376 ( Quaterniond, Quaternion<double> )
377)
378
379// No canonical typedefs because `std::array` is not under our control.
380template <typename T> using Triangle3 = std::array<Vector3<T>, 3>;
381using Triangle3i = Triangle3<int>;
382using Triangle3f = Triangle3<float>;
383using Triangle3d = Triangle3<double>;
384
385class PointAccumulator;
386
387MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SegmPoint,
388 ( SegmPointf, SegmPoint<float> )
389 ( SegmPointd, SegmPoint<double> )
390)
391
392struct EdgePoint;
393struct EdgeSegment;
395using SurfacePath = std::vector<MeshEdgePoint>;
396using SurfacePaths = std::vector<SurfacePath>;
401struct EdgePointPair;
402class Laplacian;
403
404using VertPair = std::pair<VertId, VertId>;
405using FacePair = std::pair<FaceId, FaceId>;
406using EdgePair = std::pair<EdgeId, EdgeId>;
407using UndirectedEdgePair = std::pair<UndirectedEdgeId, UndirectedEdgeId>;
408
409MR_CANONICAL_TYPEDEFS( (template <typename T> struct), TriPoint,
410 ( TriPointf, TriPoint<float> )
411 ( TriPointd, TriPoint<double> )
412)
413
414struct PointOnFace;
415struct PointOnObject;
416struct MeshTriPoint;
419template <typename T> struct IntersectionPrecomputes;
420
421template <typename I> struct IteratorRange;
422
425using UVCoord = Vector2f;
426
428using ThreeVertIds = std::array<VertId, 3>;
429
431
432MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> class MRMESH_CLASS), Vector,
434 ( Triangulation, Vector<ThreeVertIds, FaceId> )
435
436 ( Dipoles, Vector<Dipole, NodeId> )
437
438 ( FaceMap, Vector<FaceId, FaceId> )
439 ( VertMap, Vector<VertId, VertId> )
440 ( EdgeMap, Vector<EdgeId, EdgeId> )
441 ( UndirectedEdgeMap, Vector<UndirectedEdgeId, UndirectedEdgeId> )
442 ( ObjMap, Vector<ObjId, ObjId> )
443
445 ( WholeEdgeMap, Vector<EdgeId, UndirectedEdgeId> )
446 ( UndirectedEdge2RegionMap, Vector<RegionId, UndirectedEdgeId> )
447 ( Face2RegionMap, Vector<RegionId, FaceId> )
448 ( Vert2RegionMap, Vector<RegionId, VertId> )
449
450 ( VertCoords, Vector<Vector3f, VertId> )
451 ( VertNormals, Vector<Vector3f, VertId> )
452 ( VertUVCoords, Vector<UVCoord, VertId> )
453 ( FaceNormals, Vector<Vector3f, FaceId> )
454
455 ( TexturePerFace, Vector<TextureId, FaceId> )
456 ( VertColors, Vector<Color, VertId> )
457 ( FaceColors, Vector<Color, FaceId> )
458 ( EdgeColors, Vector<Color, EdgeId> )
459 ( UndirectedEdgeColors, Vector<Color, UndirectedEdgeId> )
460
461 ( VertScalars, Vector<float, VertId> )
462 ( FaceScalars, Vector<float, FaceId> )
463 ( EdgeScalars, Vector<float, EdgeId> )
464 ( UndirectedEdgeScalars, Vector<float, UndirectedEdgeId> )
465)
466
467using VertPredicate = std::function<bool( VertId )>;
468using FacePredicate = std::function<bool( FaceId )>;
469using EdgePredicate = std::function<bool( EdgeId )>;
470using UndirectedEdgePredicate = std::function<bool( UndirectedEdgeId )>;
471
472using PreCollapseCallback = std::function<bool( EdgeId edgeToCollapse, const Vector3f& newEdgeOrgPos )>;
473using OnEdgeSplit = std::function<void( EdgeId e1, EdgeId e )>;
474
475template <typename T>
476[[nodiscard]] inline bool contains( const std::function<bool( Id<T> )> & pred, Id<T> id )
477{
478 return id.valid() && ( !pred || pred( id ) );
479}
480
481using VertMetric = std::function<float( VertId )>;
482using FaceMetric = std::function<float( FaceId )>;
483using EdgeMetric = std::function<float( EdgeId )>;
484using UndirectedEdgeMetric = std::function<float( UndirectedEdgeId )>;
485
486MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> struct MRMESH_CLASS), BMap,
487 ( FaceBMap, BMap<FaceId, FaceId> )
488 ( VertBMap, BMap<VertId, VertId> )
489 ( EdgeBMap, BMap<EdgeId, EdgeId> )
490 ( UndirectedEdgeBMap, BMap<UndirectedEdgeId, UndirectedEdgeId> )
491 ( WholeEdgeBMap, BMap<EdgeId, UndirectedEdgeId> )
492)
493
494template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
495using HashSet = phmap::flat_hash_set<T, Hash, Eq>;
496template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
497using ParallelHashSet = phmap::parallel_flat_hash_set<T, Hash, Eq>;
498
499// No canonical typedefs because `phmap::...` is not under our control.
500using FaceHashSet = HashSet<FaceId>;
501using VertHashSet = HashSet<VertId>;
502using EdgeHashSet = HashSet<EdgeId>;
503
504template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
505using HashMap = phmap::flat_hash_map<K, V, Hash, Eq>;
506template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
507using ParallelHashMap = phmap::parallel_flat_hash_map<K, V, Hash, Eq>;
508
509using FaceHashMap = HashMap<FaceId, FaceId>;
510using VertHashMap = HashMap<VertId, VertId>;
511using EdgeHashMap = HashMap<EdgeId, EdgeId>;
512using UndirectedEdgeHashMap = HashMap<UndirectedEdgeId, UndirectedEdgeId>;
514using WholeEdgeHashMap = HashMap<UndirectedEdgeId, EdgeId>;
515
516template <typename I> class UnionFind;
517template <typename T, typename I, typename P> class Heap;
518
528struct MeshOrPointsXf;
529struct MeshTexture;
530struct GridSettings;
531struct TriMesh;
532
533MR_CANONICAL_TYPEDEFS( ( template <typename T> struct ), MRMESH_CLASS MeshRegion,
534 ( MeshPart, MeshRegion<FaceTag> )
535 ( MeshVertPart, MeshRegion<VertTag> )
536)
537
538template<typename T> class UniqueThreadSafeOwner;
539template<typename T> class SharedThreadSafeOwner;
540
541class PolylineTopology;
542
543MR_CANONICAL_TYPEDEFS( (template<typename V> struct), Polyline,
544 ( Polyline2, Polyline<Vector2f> )
545 ( Polyline3, Polyline<Vector3f> )
546)
547
550 ( AABBTreePolyline3, AABBTreePolyline<Vector3f> )
551)
552
553template<typename T> struct IntersectionPrecomputes;
554template<typename T> struct IntersectionPrecomputes2;
555
556MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionResult,
557 ( PolylineProjectionResult2, PolylineProjectionResult<Vector2f> )
558 ( PolylineProjectionResult3, PolylineProjectionResult<Vector3f> )
559)
560
561MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionWithOffsetResult,
563 ( PolylineProjectionWithOffsetResult3, PolylineProjectionWithOffsetResult<Vector3f> )
564)
565
566class DistanceMap;
569
570using GcodeSource = std::vector<std::string>;
571
572class Object;
573class SceneRootObject;
574class VisualObject;
575class ObjectMeshHolder;
576class ObjectMesh;
578class ObjectPoints;
580class ObjectLines;
582class ObjectLabel;
583class ObjectGcode;
584class PointObject;
585class LineObject;
586class CircleObject;
587class PlaneObject;
588class SphereObject;
589class CylinderObject;
590class ConeObject;
591
592struct LoadedObjects;
593
594struct Image;
596
597class HistoryAction;
604class ChangeMeshAction;
607class ChangeXfAction;
609class SwapRootAction;
610
611MR_CANONICAL_TYPEDEFS( (template <typename Tag> class MRMESH_CLASS), ColorMapAggregator,
612 ( VertColorMapAggregator, ColorMapAggregator<VertTag> )
613 ( UndirEdgeColorMapAggregator, ColorMapAggregator<UndirectedEdgeTag> )
614 ( FaceColorMapAggregator, ColorMapAggregator<FaceTag> )
615)
616
617template<typename T>
618class FewSmallest;
619
620class Graph;
621class WatershedGraph;
622
626typedef std::function<bool( float )> ProgressCallback;
627
628enum class FilterType : char
629{
630 Linear,
632};
633
634enum class WrapType : char
635{
636 Repeat,
637 Mirror,
638 Clamp
639};
640
642enum class Reorder : char
643{
644 None,
646 AABBTree
647};
648
649template <typename T>
650constexpr inline T sqr( T x ) noexcept { return x * x; }
651
652template <typename T>
653constexpr inline int sgn( T x ) noexcept { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
654
655template <typename T>
656constexpr inline T distance( T x, T y ) noexcept { return x >= y ? x - y : y - x; }
657
658template <typename T>
659constexpr inline T distanceSq( T x, T y ) noexcept { return sqr( x - y ); }
660
661template<typename...>
662inline constexpr bool dependent_false = false;
663
664template<class... Ts>
665struct overloaded : Ts... { using Ts::operator()...; };
666
667// explicit deduction guide (not needed as of C++20, but still needed in Clang)
668template<class... Ts>
669overloaded(Ts...) -> overloaded<Ts...>;
670
673
674namespace MeshBuilder
675{
676
677struct BuildSettings;
678struct Triangle;
679struct VertDuplication;
680
681} //namespace MeshBuilder
682
683} //namespace MR
684
685#ifdef __cpp_lib_unreachable
686# define MR_UNREACHABLE std::unreachable();
687# define MR_UNREACHABLE_NO_RETURN std::unreachable();
688#else
689# ifdef __GNUC__
690# define MR_UNREACHABLE __builtin_unreachable();
691# define MR_UNREACHABLE_NO_RETURN __builtin_unreachable();
692# else
693# include <cassert>
694# define MR_UNREACHABLE { assert( false ); return {}; }
695# define MR_UNREACHABLE_NO_RETURN assert( false );
696# endif
697#endif
#define MR_CANONICAL_TYPEDEFS(type_, name_, aliases_)
Definition MRCanonicalTypedefs.h:23
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:83
Contour
Definition MRObjectLabel.h:16
Definition MRAABBTreeObjects.h:19
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
bounding volume hierarchy for line segments
Definition MRAABBTreePolyline.h:30
Definition MRAABBTree.h:16
Definition MRVisualObject.h:57
accumulates a number of (x,y) points to find the best-least-squares parabola approximating them
Definition MRBestFitParabola.h:12
container of bits
Definition MRMesh/MRBitSet.h:27
std::vector<V>-like container that is 1) resized without initialization of its elements,...
Definition MRBuffer.h:54
Undo action for ObjectMesh mesh change.
Definition MRChangeMeshAction.h:16
Undo action for ObjectMesh creases.
Definition MRChangeSelectionAction.h:122
Undo action for ObjectMesh edge selection.
Definition MRChangeSelectionAction.h:68
Undo action for ObjectMesh face selection.
Definition MRChangeSelectionAction.h:14
Undo action for ObjectMesh points only (not topology) change.
Definition MRChangeMeshAction.h:190
Undo action for ObjectMesh topology only (not points) change.
Definition MRChangeMeshAction.h:254
Definition MRChangeObjectAction.h:14
Undo action for ObjectPoints point selection.
Definition MRChangeSelectionAction.h:176
Definition MRChangeSceneAction.h:13
Definition MRChangeXfAction.h:13
Definition MRCircleObject.h:17
Class for aggregate several color map in one Color maps are aggregated according order.
Definition MRColorMapAggregator.h:17
Definition MRCombinedHistoryAction.h:12
Definition MRCone3.h:11
Definition MRConeObject.h:19
Definition MRCylinder3.h:12
Definition MRCylinderObject.h:18
Definition MRDistanceMap.h:24
the class stores some number of smallest elements from a larger number of candidates
Definition MRFewSmallest.h:14
mathematical graph consisting from vertices and undirected edges
Definition MRGraph.h:14
stores map from element id in[0, size) to T;
Definition MRMesh/MRMeshFwd.h:517
Definition MRHistoryAction.h:12
Abstract class for fast approximate computation of generalized winding number for a mesh (using its A...
Definition MRFastWindingNumber.h:12
Abstract class, computes the closest point on mesh to each of given points. Pure virtual functions mu...
Definition MRPointsToMeshProjector.h:13
Definition MRMesh/MRId.h:13
Definition MRMesh/MRLaplacian.h:32
Definition MRLineObject.h:12
Definition MRMesh/MRMeshOrPoints.h:17
Definition MRMesh/MRMeshTopology.h:18
Definition MRObjectDistanceMap.h:13
Definition MRObjectGcode.h:14
Definition MRObjectLabel.h:25
Definition MRObjectLinesHolder.h:19
Definition MRObjectLines.h:11
Definition MRObjectMeshHolder.h:30
Definition MRObjectMesh.h:11
Definition MRObjectPointsHolder.h:18
Definition MRObjectPoints.h:11
named object in the data model
Definition MRObject.h:60
Definition MRPlaneObject.h:12
Class to accumulate points and make best line / plane approximation.
Definition MRBestFit.h:19
Definition MRPointObject.h:13
Definition MRPointToPlaneAligningTransform.h:20
Definition MRPointToPointAligningTransform.h:16
Definition MRPolylineTopology.h:15
Object that is parent of all scene.
Definition MRSceneRoot.h:11
iterator to enumerate all indices with set bits in BitSet class or its derivatives
Definition MRMesh/MRBitSet.h:249
Definition MRSharedThreadSafeOwner.h:21
Definition MRSphereObject.h:15
Definition MRSwapRootAction.h:13
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:127
Simple union find data structure.
Definition MRUnionFind.h:16
Definition MRUniqueThreadSafeOwner.h:20
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Visual Object.
Definition MRVisualObject.h:121
graphs representing rain basins on the mesh
Definition MRWatershedGraph.h:12
bool contains(const TaggedBitSet< T > *bitset, Id< T > id)
Definition MRMesh/MRBitSet.h:235
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
std::optional< T > distanceSq(const Plane3< T > &plane1, const Plane3< T > &plane2, T errorLimit=std::numeric_limits< T >::epsilon() *T(20))
Definition MRIntersection.h:90
std::optional< T > distance(const Plane3< T > &plane1, const Plane3< T > &plane2, T errorLimit=std::numeric_limits< T >::epsilon() *T(20))
Definition MRIntersection.h:104
@ None
special value not to limit path in one slice
Definition MRVoxelPath.h:33
std::function< float(VertId)> VertMetric
Definition MRMesh/MRMeshFwd.h:481
phmap::parallel_flat_hash_map< K, V, Hash, Eq > ParallelHashMap
Definition MRMesh/MRMeshFwd.h:507
std::vector< EdgeId > EdgeLoop
Definition MRMesh/MRMeshFwd.h:132
std::vector< std::string > GcodeSource
Definition MRMesh/MRMeshFwd.h:570
WrapType
Definition MRMesh/MRMeshFwd.h:635
std::vector< SurfacePath > SurfacePaths
Definition MRMesh/MRMeshFwd.h:396
std::vector< EdgeLoop > EdgeLoops
Definition MRMesh/MRMeshFwd.h:133
class MRMESH_CLASS UndirectedEdgeTag
Definition MRMesh/MRMeshFwd.h:94
constexpr T sqr(T x) noexcept
Definition MRMesh/MRMeshFwd.h:650
Cylinder3f
Definition MRMesh/MRMeshFwd.h:294
AABBTreePolyline2
Definition MRMesh/MRMeshFwd.h:549
Contour3< double > Contour3d
Definition MRMesh/MRMeshFwd.h:309
class MRMESH_CLASS ObjTag
Definition MRMesh/MRMeshFwd.h:101
Eq
Definition MRMesh/MRMeshFwd.h:494
std::function< bool(FaceId)> FacePredicate
Definition MRMesh/MRMeshFwd.h:468
MinMax< float > MinMaxf
Definition MRMesh/MRMeshFwd.h:346
Contour2< double > Contour2d
Definition MRMesh/MRMeshFwd.h:307
class MRMESH_CLASS NodeTag
Definition MRMesh/MRMeshFwd.h:100
HashSet< VertId > VertHashSet
Definition MRMesh/MRMeshFwd.h:501
std::function< bool(EdgeId)> EdgePredicate
Definition MRMesh/MRMeshFwd.h:469
Hash
Definition MRMesh/MRMeshFwd.h:494
Contour2< float > Contour2f
Definition MRMesh/MRMeshFwd.h:308
Contours2< double > Contours2d
Definition MRMesh/MRMeshFwd.h:315
std::function< bool(UndirectedEdgeId)> UndirectedEdgePredicate
Definition MRMesh/MRMeshFwd.h:470
SurfacePaths PlaneSections
Definition MRMesh/MRMeshFwd.h:400
HashMap< VertId, VertId > VertHashMap
Definition MRMesh/MRMeshFwd.h:510
class MRMESH_CLASS VoxelTag
Definition MRMesh/MRMeshFwd.h:98
FilterType
Definition MRMesh/MRMeshFwd.h:629
SurfacePath IsoLine
Definition MRMesh/MRMeshFwd.h:397
Vector2f UVCoord
Definition MRMesh/MRMeshFwd.h:425
Triangle3< int > Triangle3i
Definition MRMesh/MRMeshFwd.h:381
MRMESH_CLASS Vector3b
Definition MRMesh/MRMeshFwd.h:171
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:395
HashMap< UndirectedEdgeId, EdgeId > WholeEdgeHashMap
mapping of whole edges: map[e]->f, map[e.sym()]->f.sym(), where only map[e] for even edges is stored
Definition MRMesh/MRMeshFwd.h:514
class MRMESH_CLASS FaceTag
Definition MRMesh/MRMeshFwd.h:95
class MRMESH_CLASS TextureTag
Definition MRMesh/MRMeshFwd.h:102
class MRMESH_CLASS PixelTag
Definition MRMesh/MRMeshFwd.h:97
Contours< Vector2< T > > Contours2
Definition MRMesh/MRMeshFwd.h:313
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4< double > SymMatrix3< double > AffineXf2f
Definition MRMesh/MRMeshFwd.h:235
SetBitIterator
Definition MRMesh/MRMeshFwd.h:153
overloaded(Ts...) -> overloaded< Ts... >
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4b
Definition MRMesh/MRMeshFwd.h:203
constexpr int sgn(T x) noexcept
Definition MRMesh/MRMeshFwd.h:653
Contours2< float > Contours2f
Definition MRMesh/MRMeshFwd.h:316
RigidScaleXf3f
Definition MRMesh/MRMeshFwd.h:249
std::function< float(EdgeId)> EdgeMetric
Definition MRMesh/MRMeshFwd.h:483
MinMax< double > MinMaxd
Definition MRMesh/MRMeshFwd.h:347
std::function< bool(EdgeId edgeToCollapse, const Vector3f &newEdgeOrgPos)> PreCollapseCallback
Definition MRMesh/MRMeshFwd.h:472
Contour< Vector2< T > > Contour2
Definition MRMesh/MRMeshFwd.h:305
SurfacePath PlaneSection
Definition MRMesh/MRMeshFwd.h:399
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:509
std::function< float(FaceId)> FaceMetric
Definition MRMesh/MRMeshFwd.h:482
Triangle3< double > Triangle3d
Definition MRMesh/MRMeshFwd.h:383
Box1i
Definition MRMesh/MRMeshFwd.h:332
Contour< Vector3< T > > Contour3
Definition MRMesh/MRMeshFwd.h:306
HashSet< FaceId > FaceHashSet
Definition MRMesh/MRMeshFwd.h:500
std::vector< EdgeId > EdgePath
Definition MRMesh/MRMeshFwd.h:131
std::array< VertId, 3 > ThreeVertIds
three vertex ids describing a triangle topology
Definition MRMesh/MRMeshFwd.h:428
class MRMESH_CLASS VertTag
Definition MRMesh/MRMeshFwd.h:96
std::pair< FaceId, FaceId > FacePair
Definition MRMesh/MRMeshFwd.h:405
constexpr NoInit noInit
Definition MRMesh/MRMeshFwd.h:90
HashSet< EdgeId > EdgeHashSet
Definition MRMesh/MRMeshFwd.h:502
std::pair< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgePair
Definition MRMesh/MRMeshFwd.h:407
Cone3f
Definition MRMesh/MRMeshFwd.h:299
BestFitParabolaf
Definition MRMesh/MRMeshFwd.h:289
I
Definition MRMesh/MRMeshFwd.h:121
std::pair< EdgeId, EdgeId > EdgePair
Definition MRMesh/MRMeshFwd.h:406
std::function< void(EdgeId e1, EdgeId e)> OnEdgeSplit
Definition MRMesh/MRMeshFwd.h:473
std::function< float(UndirectedEdgeId)> UndirectedEdgeMetric
Definition MRMesh/MRMeshFwd.h:484
constexpr bool dependent_false
Definition MRMesh/MRMeshFwd.h:662
Triangle3< float > Triangle3f
Definition MRMesh/MRMeshFwd.h:382
SurfacePaths IsoLines
Definition MRMesh/MRMeshFwd.h:398
class MRMESH_CLASS EdgeTag
Definition MRMesh/MRMeshFwd.h:93
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:318
std::vector< Contour< V > > Contours
Definition MRMesh/MRMeshFwd.h:312
Polyline2ProjectionWithOffsetResult
Definition MRMesh/MRMeshFwd.h:562
HashMap< EdgeId, EdgeId > EdgeHashMap
Definition MRMesh/MRMeshFwd.h:511
phmap::parallel_flat_hash_set< T, Hash, Eq > ParallelHashSet
Definition MRMesh/MRMeshFwd.h:497
MRMESH_CLASS Vector3< double > Matrix2b
Definition MRMesh/MRMeshFwd.h:187
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:404
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:310
HashMap< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgeHashMap
Definition MRMesh/MRMeshFwd.h:512
Contours< Vector3< T > > Contours3
Definition MRMesh/MRMeshFwd.h:314
Contours3< double > Contours3d
Definition MRMesh/MRMeshFwd.h:317
class MRMESH_CLASS RegionTag
Definition MRMesh/MRMeshFwd.h:99
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4< double > SymMatrix3b
Definition MRMesh/MRMeshFwd.h:219
class MRMESH_CLASS GraphVertTag
Definition MRMesh/MRMeshFwd.h:103
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:505
class MRMESH_CLASS GraphEdgeTag
Definition MRMesh/MRMeshFwd.h:104
Reorder
determines how points to be ordered
Definition MRMesh/MRMeshFwd.h:643
@ Lexicographically
the order is determined by lexicographical sorting by coordinates (optimal for uniform sampling)
Definition MRMesh/MRAffineXf.h:14
triangulations for all points, with easy access by VertId
Definition MRLocalTriangulations.h:48
flat map: I -> T
Definition MRBuffer.h:143
a ball = points surrounded by a sphere in arbitrary space with vector type V
Definition MRBall.h:12
Box given by its min- and max- corners.
Definition MRMesh/MRBox.h:25
Definition MRCloudPartMapping.h:10
Definition MRMesh/MRColor.h:9
Definition MRDipole.h:11
options determining computation of distance from a point to a mesh
Definition MRDistanceToMeshOptions.h:11
two edge-points (e.g. representing collision point of two edges)
Definition MREdgePoint.h:50
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:11
Represents a segment on one edge.
Definition MREdgePoint.h:61
settings defining regular grid, where each quadrangular cell is split on two triangles in one of two ...
Definition MRGridSettings.h:11
Definition MRImage.h:15
Definition MRMesh/MRMeshFwd.h:554
Definition MRMesh/MRMeshFwd.h:419
Definition MRMesh/MRMeshFwd.h:421
Definition MRLineSegm.h:11
Definition MRLine.h:12
result of loading (e.g. from a file) as a number of objects
Definition MRLoadedObjects.h:28
Definition MRMatrix2.h:13
Definition MRMesh/MRMatrix3.h:13
Definition MRMatrix4.h:14
Definition MRMeshIntersect.h:17
an object and its transformation to global space with other objects
Definition MRMesh/MRMeshOrPoints.h:97
Definition MRMesh/MRMeshProject.h:18
Definition MRMesh/MRMeshPart.h:12
Definition MRMeshTexture.h:13
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MRNoDefInit.h:11
Definition MRMesh/MRMeshFwd.h:89
Definition MRBuffer.h:151
Represents quadratic function f(x) = a*x*x + b*x + c.
Definition MRParabola.h:11
Definition MRPartMapping.h:10
Definition MRPlane3.h:12
Definition MRMesh/MRPointCloud.h:16
Definition MRMesh/MRPointOnFace.h:11
Definition MRPointOnObject.h:16
Definition MRPolylineProject.h:15
Definition MRPolylineProject.h:53
Definition MRPolyline.h:18
Definition MRQuadraticForm.h:13
Definition MRQuaternion.h:13
Definition MRRigidScaleXf3.h:12
Definition MRRigidXf3.h:13
encodes a point inside a line segment using relative distance in [0,1]
Definition MRSegmPoint.h:14
options determining computation of signed distance from a point to a mesh
Definition MRDistanceToMeshOptions.h:37
describes a number of local triangulations of some points (e.g. assigned to a thread)
Definition MRLocalTriangulations.h:40
Definition MRSphere.h:9
Definition MRSymMatrix2.h:14
Definition MRSymMatrix3.h:15
Definition MRSymMatrix4.h:13
Definition MRTriMesh.h:13
encodes a point inside a triangle using barycentric coordinates
Definition MRMesh/MRTriPoint.h:14
Definition MRUnorientedTriangle.h:13
Definition MRVector2.h:18
Definition MRMesh/MRVector3.h:19
Definition MRVector4.h:13
Definition MRMesh/MRMeshFwd.h:665