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 MRMESH_CLASS), CubicBezierCurve,
366 ( CubicBezierCurve2f, CubicBezierCurve<Vector2<float>> )
367 ( CubicBezierCurve2d, CubicBezierCurve<Vector2<double>> )
368 ( CubicBezierCurve3f, CubicBezierCurve<Vector3<float>> )
369 ( CubicBezierCurve3d, CubicBezierCurve<Vector3<double>> )
370)
371template <typename T> using CubicBezierCurve2 = CubicBezierCurve<Vector2<T>>;
372template <typename T> using CubicBezierCurve3 = CubicBezierCurve<Vector3<T>>;
373
374MR_CANONICAL_TYPEDEFS( (template <typename V> struct), QuadraticForm,
375 ( QuadraticForm2f, QuadraticForm<Vector2<float>> )
376 ( QuadraticForm2d, QuadraticForm<Vector2<double>> )
377 ( QuadraticForm3f, QuadraticForm<Vector3<float>> )
378 ( QuadraticForm3d, QuadraticForm<Vector3<double>> )
379)
380template <typename T> using QuadraticForm2 = QuadraticForm<Vector2<T>>;
381template <typename T> using QuadraticForm3 = QuadraticForm<Vector3<T>>;
382
383MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Quaternion,
384 ( Quaternionf, Quaternion<float> )
385 ( Quaterniond, Quaternion<double> )
386)
387
388// No canonical typedefs because `std::array` is not under our control.
389template <typename T> using Triangle3 = std::array<Vector3<T>, 3>;
390using Triangle3i = Triangle3<int>;
391using Triangle3f = Triangle3<float>;
392using Triangle3d = Triangle3<double>;
393
394class PointAccumulator;
395
396MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SegmPoint,
397 ( SegmPointf, SegmPoint<float> )
398 ( SegmPointd, SegmPoint<double> )
399)
400
401struct EdgePoint;
402struct EdgeSegment;
404using SurfacePath = std::vector<MeshEdgePoint>;
405using SurfacePaths = std::vector<SurfacePath>;
410struct EdgePointPair;
411class Laplacian;
412
413using VertPair = std::pair<VertId, VertId>;
414using FacePair = std::pair<FaceId, FaceId>;
415using EdgePair = std::pair<EdgeId, EdgeId>;
416using UndirectedEdgePair = std::pair<UndirectedEdgeId, UndirectedEdgeId>;
417
418MR_CANONICAL_TYPEDEFS( (template <typename T> struct), TriPoint,
419 ( TriPointf, TriPoint<float> )
420 ( TriPointd, TriPoint<double> )
421)
422
423struct PointOnFace;
424struct PointOnObject;
425struct MeshTriPoint;
428template <typename T> struct IntersectionPrecomputes;
429
430template <typename I> struct IteratorRange;
431
434using UVCoord = Vector2f;
435
437using ThreeVertIds = std::array<VertId, 3>;
438
440
441MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> class MRMESH_CLASS), Vector,
443 ( Triangulation, Vector<ThreeVertIds, FaceId> )
444
445 ( Dipoles, Vector<Dipole, NodeId> )
446
447 ( FaceMap, Vector<FaceId, FaceId> )
448 ( VertMap, Vector<VertId, VertId> )
449 ( EdgeMap, Vector<EdgeId, EdgeId> )
450 ( UndirectedEdgeMap, Vector<UndirectedEdgeId, UndirectedEdgeId> )
451 ( ObjMap, Vector<ObjId, ObjId> )
452
454 ( WholeEdgeMap, Vector<EdgeId, UndirectedEdgeId> )
455 ( UndirectedEdge2RegionMap, Vector<RegionId, UndirectedEdgeId> )
456 ( Face2RegionMap, Vector<RegionId, FaceId> )
457 ( Vert2RegionMap, Vector<RegionId, VertId> )
458
459 ( VertCoords, Vector<Vector3f, VertId> )
460 ( VertNormals, Vector<Vector3f, VertId> )
461 ( VertUVCoords, Vector<UVCoord, VertId> )
462 ( FaceNormals, Vector<Vector3f, FaceId> )
463
464 ( TexturePerFace, Vector<TextureId, FaceId> )
465 ( VertColors, Vector<Color, VertId> )
466 ( FaceColors, Vector<Color, FaceId> )
467 ( EdgeColors, Vector<Color, EdgeId> )
468 ( UndirectedEdgeColors, Vector<Color, UndirectedEdgeId> )
469
470 ( VertScalars, Vector<float, VertId> )
471 ( FaceScalars, Vector<float, FaceId> )
472 ( EdgeScalars, Vector<float, EdgeId> )
473 ( UndirectedEdgeScalars, Vector<float, UndirectedEdgeId> )
474)
475
476using VertPredicate = std::function<bool( VertId )>;
477using FacePredicate = std::function<bool( FaceId )>;
478using EdgePredicate = std::function<bool( EdgeId )>;
479using UndirectedEdgePredicate = std::function<bool( UndirectedEdgeId )>;
480
481using PreCollapseCallback = std::function<bool( EdgeId edgeToCollapse, const Vector3f& newEdgeOrgPos )>;
482using OnEdgeSplit = std::function<void( EdgeId e1, EdgeId e )>;
483
484template <typename T>
485[[nodiscard]] inline bool contains( const std::function<bool( Id<T> )> & pred, Id<T> id )
486{
487 return id.valid() && ( !pred || pred( id ) );
488}
489
490using VertMetric = std::function<float( VertId )>;
491using FaceMetric = std::function<float( FaceId )>;
492using EdgeMetric = std::function<float( EdgeId )>;
493using UndirectedEdgeMetric = std::function<float( UndirectedEdgeId )>;
494
495MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> struct MRMESH_CLASS), BMap,
496 ( FaceBMap, BMap<FaceId, FaceId> )
497 ( VertBMap, BMap<VertId, VertId> )
498 ( EdgeBMap, BMap<EdgeId, EdgeId> )
499 ( UndirectedEdgeBMap, BMap<UndirectedEdgeId, UndirectedEdgeId> )
500 ( WholeEdgeBMap, BMap<EdgeId, UndirectedEdgeId> )
501)
502
503template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
504using HashSet = phmap::flat_hash_set<T, Hash, Eq>;
505template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
506using ParallelHashSet = phmap::parallel_flat_hash_set<T, Hash, Eq>;
507
508// No canonical typedefs because `phmap::...` is not under our control.
509using FaceHashSet = HashSet<FaceId>;
510using VertHashSet = HashSet<VertId>;
511using EdgeHashSet = HashSet<EdgeId>;
512
513template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
514using HashMap = phmap::flat_hash_map<K, V, Hash, Eq>;
515template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
516using ParallelHashMap = phmap::parallel_flat_hash_map<K, V, Hash, Eq>;
517
518using FaceHashMap = HashMap<FaceId, FaceId>;
519using VertHashMap = HashMap<VertId, VertId>;
520using EdgeHashMap = HashMap<EdgeId, EdgeId>;
521using UndirectedEdgeHashMap = HashMap<UndirectedEdgeId, UndirectedEdgeId>;
523using WholeEdgeHashMap = HashMap<UndirectedEdgeId, EdgeId>;
524
525template <typename I> class UnionFind;
526template <typename T, typename I, typename P> class Heap;
527
537struct MeshOrPointsXf;
538struct MeshTexture;
539struct GridSettings;
540struct TriMesh;
541
542MR_CANONICAL_TYPEDEFS( ( template <typename T> struct ), MRMESH_CLASS MeshRegion,
543 ( MeshPart, MeshRegion<FaceTag> )
544 ( MeshVertPart, MeshRegion<VertTag> )
545)
546
547template<typename T> class UniqueThreadSafeOwner;
548template<typename T> class SharedThreadSafeOwner;
549
550class PolylineTopology;
551
552MR_CANONICAL_TYPEDEFS( (template<typename V> struct), Polyline,
553 ( Polyline2, Polyline<Vector2f> )
554 ( Polyline3, Polyline<Vector3f> )
555)
556
559 ( AABBTreePolyline3, AABBTreePolyline<Vector3f> )
560)
561
562template<typename T> struct IntersectionPrecomputes;
563template<typename T> struct IntersectionPrecomputes2;
564
565MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionResult,
566 ( PolylineProjectionResult2, PolylineProjectionResult<Vector2f> )
567 ( PolylineProjectionResult3, PolylineProjectionResult<Vector3f> )
568)
569
570MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionWithOffsetResult,
572 ( PolylineProjectionWithOffsetResult3, PolylineProjectionWithOffsetResult<Vector3f> )
573)
574
575class DistanceMap;
578
579using GcodeSource = std::vector<std::string>;
580
581class Object;
582class SceneRootObject;
583class VisualObject;
584class ObjectMeshHolder;
585class ObjectMesh;
586struct ObjectMeshData;
588class ObjectPoints;
590class ObjectLines;
592class ObjectLabel;
593class ObjectGcode;
594class PointObject;
595class LineObject;
596class CircleObject;
597class PlaneObject;
598class SphereObject;
599class CylinderObject;
600class ConeObject;
601
602struct LoadedObjects;
603
604struct Image;
606
607class HistoryAction;
614class ChangeMeshAction;
617class ChangeXfAction;
619class SwapRootAction;
620
621MR_CANONICAL_TYPEDEFS( (template <typename Tag> class MRMESH_CLASS), ColorMapAggregator,
622 ( VertColorMapAggregator, ColorMapAggregator<VertTag> )
623 ( UndirEdgeColorMapAggregator, ColorMapAggregator<UndirectedEdgeTag> )
624 ( FaceColorMapAggregator, ColorMapAggregator<FaceTag> )
625)
626
627template<typename T>
628class FewSmallest;
629
630class Graph;
631class WatershedGraph;
632
636typedef std::function<bool( float )> ProgressCallback;
637
638enum class FilterType : char
639{
640 Linear,
642};
643
644enum class WrapType : char
645{
646 Repeat,
647 Mirror,
648 Clamp
649};
650
652enum class Reorder : char
653{
654 None,
656 AABBTree
657};
658
660template <typename T>
661constexpr inline T sqr( T x ) noexcept { return x * x; }
662
664template <typename T>
665constexpr inline int sgn( T x ) noexcept { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
666
668template <typename T>
669constexpr inline T distance( T x, T y ) noexcept { return x >= y ? x - y : y - x; }
670
672template <typename T>
673constexpr inline T distanceSq( T x, T y ) noexcept { return sqr( x - y ); }
674
676template <typename V, typename T>
677constexpr inline auto lerp( V v0, V v1, T t ) noexcept { return ( 1 - t ) * v0 + t * v1; }
678
679template<typename...>
680inline constexpr bool dependent_false = false;
681
682template<class... Ts>
683struct overloaded : Ts... { using Ts::operator()...; };
684
685// explicit deduction guide (not needed as of C++20, but still needed in Clang)
686template<class... Ts>
687overloaded(Ts...) -> overloaded<Ts...>;
688
691
692namespace MeshBuilder
693{
694
695struct BuildSettings;
696struct Triangle;
697struct VertDuplication;
698
699} //namespace MeshBuilder
700
701} //namespace MR
702
703#ifdef __cpp_lib_unreachable
704# define MR_UNREACHABLE std::unreachable();
705# define MR_UNREACHABLE_NO_RETURN std::unreachable();
706#else
707# ifdef __GNUC__
708# define MR_UNREACHABLE __builtin_unreachable();
709# define MR_UNREACHABLE_NO_RETURN __builtin_unreachable();
710# else
711# include <cassert>
712# define MR_UNREACHABLE { assert( false ); return {}; }
713# define MR_UNREACHABLE_NO_RETURN assert( false );
714# endif
715#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:526
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:31
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:636
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:490
phmap::parallel_flat_hash_map< K, V, Hash, Eq > ParallelHashMap
Definition MRMesh/MRMeshFwd.h:516
std::vector< EdgeId > EdgeLoop
Definition MRMesh/MRMeshFwd.h:132
std::vector< std::string > GcodeSource
Definition MRMesh/MRMeshFwd.h:579
WrapType
Definition MRMesh/MRMeshFwd.h:645
std::vector< SurfacePath > SurfacePaths
Definition MRMesh/MRMeshFwd.h:405
std::vector< EdgeLoop > EdgeLoops
Definition MRMesh/MRMeshFwd.h:133
class MRMESH_CLASS UndirectedEdgeTag
Definition MRMesh/MRMeshFwd.h:94
constexpr T sqr(T x) noexcept
squared value
Definition MRMesh/MRMeshFwd.h:661
Cylinder3f
Definition MRMesh/MRMeshFwd.h:294
AABBTreePolyline2
Definition MRMesh/MRMeshFwd.h:558
Contour3< double > Contour3d
Definition MRMesh/MRMeshFwd.h:309
class MRMESH_CLASS ObjTag
Definition MRMesh/MRMeshFwd.h:101
Eq
Definition MRMesh/MRMeshFwd.h:503
std::function< bool(FaceId)> FacePredicate
Definition MRMesh/MRMeshFwd.h:477
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:510
std::function< bool(EdgeId)> EdgePredicate
Definition MRMesh/MRMeshFwd.h:478
Hash
Definition MRMesh/MRMeshFwd.h:503
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:479
SurfacePaths PlaneSections
Definition MRMesh/MRMeshFwd.h:409
HashMap< VertId, VertId > VertHashMap
Definition MRMesh/MRMeshFwd.h:519
class MRMESH_CLASS VoxelTag
Definition MRMesh/MRMeshFwd.h:98
FilterType
Definition MRMesh/MRMeshFwd.h:639
SurfacePath IsoLine
Definition MRMesh/MRMeshFwd.h:406
Vector2f UVCoord
Definition MRMesh/MRMeshFwd.h:434
Triangle3< int > Triangle3i
Definition MRMesh/MRMeshFwd.h:390
MRMESH_CLASS Vector3b
Definition MRMesh/MRMeshFwd.h:171
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:404
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:523
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
sign of given value in { -1, 0, 1 }
Definition MRMesh/MRMeshFwd.h:665
Contours2< float > Contours2f
Definition MRMesh/MRMeshFwd.h:316
RigidScaleXf3f
Definition MRMesh/MRMeshFwd.h:249
std::function< float(EdgeId)> EdgeMetric
Definition MRMesh/MRMeshFwd.h:492
MinMax< double > MinMaxd
Definition MRMesh/MRMeshFwd.h:347
std::function< bool(EdgeId edgeToCollapse, const Vector3f &newEdgeOrgPos)> PreCollapseCallback
Definition MRMesh/MRMeshFwd.h:481
Contour< Vector2< T > > Contour2
Definition MRMesh/MRMeshFwd.h:305
SurfacePath PlaneSection
Definition MRMesh/MRMeshFwd.h:408
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:518
std::function< float(FaceId)> FaceMetric
Definition MRMesh/MRMeshFwd.h:491
Triangle3< double > Triangle3d
Definition MRMesh/MRMeshFwd.h:392
Box1i
Definition MRMesh/MRMeshFwd.h:332
Contour< Vector3< T > > Contour3
Definition MRMesh/MRMeshFwd.h:306
HashSet< FaceId > FaceHashSet
Definition MRMesh/MRMeshFwd.h:509
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:437
class MRMESH_CLASS VertTag
Definition MRMesh/MRMeshFwd.h:96
std::pair< FaceId, FaceId > FacePair
Definition MRMesh/MRMeshFwd.h:414
constexpr NoInit noInit
Definition MRMesh/MRMeshFwd.h:90
HashSet< EdgeId > EdgeHashSet
Definition MRMesh/MRMeshFwd.h:511
std::pair< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgePair
Definition MRMesh/MRMeshFwd.h:416
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:415
std::function< void(EdgeId e1, EdgeId e)> OnEdgeSplit
Definition MRMesh/MRMeshFwd.h:482
std::function< float(UndirectedEdgeId)> UndirectedEdgeMetric
Definition MRMesh/MRMeshFwd.h:493
constexpr auto lerp(V v0, V v1, T t) noexcept
Linear interpolation: returns v0 when t==0 and v1 when t==1.
Definition MRMesh/MRMeshFwd.h:677
constexpr bool dependent_false
Definition MRMesh/MRMeshFwd.h:680
Triangle3< float > Triangle3f
Definition MRMesh/MRMeshFwd.h:391
SurfacePaths IsoLines
Definition MRMesh/MRMeshFwd.h:407
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:571
HashMap< EdgeId, EdgeId > EdgeHashMap
Definition MRMesh/MRMeshFwd.h:520
phmap::parallel_flat_hash_set< T, Hash, Eq > ParallelHashSet
Definition MRMesh/MRMeshFwd.h:506
MRMESH_CLASS Vector3< double > Matrix2b
Definition MRMesh/MRMeshFwd.h:187
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:413
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:310
HashMap< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgeHashMap
Definition MRMesh/MRMeshFwd.h:521
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:514
class MRMESH_CLASS GraphEdgeTag
Definition MRMesh/MRMeshFwd.h:104
Reorder
determines how points to be ordered
Definition MRMesh/MRMeshFwd.h:653
@ 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
Cubic Bezier curve.
Definition MRBezier.h:13
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:563
Definition MRMesh/MRMeshFwd.h:428
Definition MRMesh/MRMeshFwd.h:430
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:19
Definition MRMesh/MRMatrix3.h:19
Definition MRMatrix4.h:20
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
mesh and its per-element attributes for ObjectMeshHolder
Definition MRObjectMeshData.h:12
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:17
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:25
Definition MRMesh/MRVector3.h:26
Definition MRVector4.h:20
Definition MRMesh/MRMeshFwd.h:683