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 && __GNUC__ <= 15)
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 && __GNUC__ <= 15)
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
121MR_CANONICAL_TYPEDEFS( (template <typename T> class MRMESH_CLASS), NoInitId,
123)
124
125template <typename T, typename I = size_t> class MRMESH_CLASS Buffer;
126struct PackMapping;
127
128class ViewportId;
129class ViewportMask;
130
131struct UnorientedTriangle;
134
135using EdgePath = std::vector<EdgeId>;
136using EdgeLoop = std::vector<EdgeId>;
137using EdgeLoops = std::vector<EdgeLoop>;
138
140
141MR_CANONICAL_TYPEDEFS( (template <typename I> class MRMESH_CLASS), TypedBitSet,
142 ( FaceBitSet, TypedBitSet<FaceId> )
143 ( VertBitSet, TypedBitSet<VertId> )
144 ( EdgeBitSet, TypedBitSet<EdgeId> )
145 ( UndirectedEdgeBitSet, TypedBitSet<UndirectedEdgeId> )
146 ( PixelBitSet, TypedBitSet<PixelId> )
147 ( VoxelBitSet, TypedBitSet<VoxelId> )
148 ( RegionBitSet, TypedBitSet<RegionId> )
149 ( NodeBitSet, TypedBitSet<NodeId> )
150 ( ObjBitSet, TypedBitSet<ObjId> )
151 ( TextureBitSet, TypedBitSet<TextureId> )
152 ( GraphVertBitSet, TypedBitSet<GraphVertId> )
153 ( GraphEdgeBitSet, TypedBitSet<GraphEdgeId> )
154)
155
156template<typename T>
157using TaggedBitSet = TypedBitSet<Id<T>>;
158
159MR_CANONICAL_TYPEDEFS( (template <typename T> class MRMESH_CLASS), SetBitIteratorT,
160 ( SetBitIterator, SetBitIteratorT<BitSet> )
161 ( FaceSetBitIterator, SetBitIteratorT<FaceBitSet> )
162 ( VertSetBitIterator, SetBitIteratorT<VertBitSet> )
163 ( EdgeSetBitIterator, SetBitIteratorT<EdgeBitSet> )
164 ( UndirectedEdgeSetBitIterator, SetBitIteratorT<UndirectedEdgeBitSet> )
165)
166
167struct Color;
168
169MR_CANONICAL_TYPEDEFS( (template <typename T> struct), MRMESH_CLASS Vector2,
170 ( Vector2b, Vector2<bool> )
171 ( Vector2i, Vector2<int> )
172 ( Vector2ll, Vector2<long long> )
173 ( Vector2f, Vector2<float> )
174 ( Vector2d, Vector2<double> )
175)
176
177MR_CANONICAL_TYPEDEFS( (template <typename T> struct), MRMESH_CLASS Vector3,
178 ( Vector3b, Vector3<bool> )
179 ( Vector3i, Vector3<int> )
180 ( Vector3ll, Vector3<long long> )
181 ( Vector3f, Vector3<float> )
182 ( Vector3d, Vector3<double> )
183)
184
185MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Vector4,
186 ( Vector4b, Vector4<bool> )
187 ( Vector4i, Vector4<int> )
188 ( Vector4ll, Vector4<long long> )
189 ( Vector4f, Vector4<float> )
190 ( Vector4d, Vector4<double> )
191)
192
193MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix2,
194 ( Matrix2b, Matrix2<bool> )
195 ( Matrix2i, Matrix2<int> )
196 ( Matrix2ll, Matrix2<long long> )
197 ( Matrix2f, Matrix2<float> )
198 ( Matrix2d, Matrix2<double> )
199)
200
201MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix3,
202 ( Matrix3b, Matrix3<bool> )
203 ( Matrix3i, Matrix3<int> )
204 ( Matrix3ll, Matrix3<long long> )
205 ( Matrix3f, Matrix3<float> )
206 ( Matrix3d, Matrix3<double> )
207)
208
209MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Matrix4,
210 ( Matrix4b, Matrix4<bool> )
211 ( Matrix4i, Matrix4<int> )
212 ( Matrix4ll, Matrix4<long long> )
213 ( Matrix4f, Matrix4<float> )
214 ( Matrix4d, Matrix4<double> )
215)
216
217MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix2,
218 ( SymMatrix2b, SymMatrix2<bool> )
219 ( SymMatrix2i, SymMatrix2<int> )
220 ( SymMatrix2ll, SymMatrix2<long long> )
221 ( SymMatrix2f, SymMatrix2<float> )
222 ( SymMatrix2d, SymMatrix2<double> )
223)
224
225MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix3,
227 ( SymMatrix3i, SymMatrix3<int> )
228 ( SymMatrix3ll, SymMatrix3<long long> )
229 ( SymMatrix3f, SymMatrix3<float> )
230 ( SymMatrix3d, SymMatrix3<double> )
231)
232
233MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SymMatrix4,
234 ( SymMatrix4b, SymMatrix4<bool> )
235 ( SymMatrix4i, SymMatrix4<int> )
236 ( SymMatrix4ll, SymMatrix4<long long> )
237 ( SymMatrix4f, SymMatrix4<float> )
238 ( SymMatrix4d, SymMatrix4<double> )
239)
240
241MR_CANONICAL_TYPEDEFS( (template <typename V> struct), AffineXf,
243 ( AffineXf2d, AffineXf<Vector2<double>> )
244 ( AffineXf3f, AffineXf<Vector3<float>> )
245 ( AffineXf3d, AffineXf<Vector3<double>> )
246)
247template <typename T> using AffineXf2 = AffineXf<Vector2<T>>;
248template <typename T> using AffineXf3 = AffineXf<Vector3<T>>;
249
250MR_CANONICAL_TYPEDEFS( (template <typename T> struct), RigidXf3,
251 ( RigidXf3f, RigidXf3<float> )
252 ( RigidXf3d, RigidXf3<double> )
253)
254
255MR_CANONICAL_TYPEDEFS( (template <typename T> struct), RigidScaleXf3,
257 ( RigidScaleXf3d, RigidScaleXf3<double> )
258)
259
262
263MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Sphere,
264 ( Sphere2f, Sphere<Vector2<float>> )
265 ( Sphere2d, Sphere<Vector2<double>> )
266 ( Sphere3f, Sphere<Vector3<float>> )
267 ( Sphere3d, Sphere<Vector3<double>> )
268)
269template <typename T> using Sphere2 = Sphere<Vector2<T>>;
270template <typename T> using Sphere3 = Sphere<Vector3<T>>;
271
272MR_CANONICAL_TYPEDEFS( (template <typename V> struct), Line,
273 ( Line2f, Line<Vector2<float>> )
274 ( Line2d, Line<Vector2<double>> )
275 ( Line3f, Line<Vector3<float>> )
276 ( Line3d, Line<Vector3<double>> )
277)
278template <typename T> using Line2 = Line<Vector2<T>>;
279template <typename T> using Line3 = Line<Vector3<T>>;
280
281MR_CANONICAL_TYPEDEFS( (template <typename V> struct), LineSegm,
282 ( LineSegm2f, LineSegm<Vector2<float>> )
283 ( LineSegm2d, LineSegm<Vector2<double>> )
284 ( LineSegm3f, LineSegm<Vector3<float>> )
285 ( LineSegm3d, LineSegm<Vector3<double>> )
286)
287template <typename T> using LineSegm2 = LineSegm<Vector2<T>>;
288template <typename T> using LineSegm3 = LineSegm<Vector3<T>>;
289
290MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Parabola,
291 ( Parabolaf, Parabola<float> )
292 ( Parabolad, Parabola<double> )
293)
294
295MR_CANONICAL_TYPEDEFS( (template <typename T> class), BestFitParabola,
297 ( BestFitParabolad, BestFitParabola<double> )
298)
299
300MR_CANONICAL_TYPEDEFS( (template <typename T> class), Cylinder3,
302 ( Cylinder3d, Cylinder3<double> )
303)
304
305MR_CANONICAL_TYPEDEFS( (template <typename T> class), Cone3,
306 ( Cone3f, Cone3<float> )
307 ( Cone3d, Cone3<double> )
308)
309
310// No canonical typedefs here, because those ultimately boil to `std::vector`, which isn't under our control.
311template <typename V> using Contour = std::vector<V>;
312template <typename T> using Contour2 = Contour<Vector2<T>>;
313template <typename T> using Contour3 = Contour<Vector3<T>>;
314using Contour2d = Contour2<double>;
315using Contour2f = Contour2<float>;
316using Contour3d = Contour3<double>;
317using Contour3f = Contour3<float>;
318
319template <typename V> using Contours = std::vector<Contour<V>>;
320template <typename T> using Contours2 = Contours<Vector2<T>>;
321template <typename T> using Contours3 = Contours<Vector3<T>>;
322using Contours2d = Contours2<double>;
323using Contours2f = Contours2<float>;
324using Contours3d = Contours3<double>;
325using Contours3f = Contours3<float>;
326
327template <typename T> using Contour3 = Contour<Vector3<T>>;
328using Contour3d = Contour3<double>;
329using Contours3d = std::vector<Contour3d>;
330using Contour3f = Contour3<float>;
331using Contours3f = std::vector<Contour3f>;
332
333MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Plane3,
334 ( Plane3f, Plane3<float> )
335 ( Plane3d, Plane3<double> )
336)
337
338MR_CANONICAL_TYPEDEFS( (template <typename V> struct MRMESH_CLASS), Box,
339 ( Box1i, Box<int> )
340 ( Box1ll, Box<long long> )
341 ( Box1f, Box<float> )
342 ( Box1d, Box<double> )
343 ( Box2i, Box<Vector2<int>> )
344 ( Box2ll, Box<Vector2<long long>> )
345 ( Box2f, Box<Vector2<float>> )
346 ( Box2d, Box<Vector2<double>> )
347 ( Box3i, Box<Vector3<int>> )
348 ( Box3ll, Box<Vector3<long long>> )
349 ( Box3f, Box<Vector3<float>> )
350 ( Box3d, Box<Vector3<double>> )
351)
352template <typename T> using MinMax = Box<T>;
353using MinMaxf = MinMax<float>;
354using MinMaxd = MinMax<double>;
355using MinMaxi = MinMax<int>;
356
357template <typename T> using Box1 = Box<T>;
358template <typename T> using Box2 = Box<Vector2<T>>;
359template <typename T> using Box3 = Box<Vector3<T>>;
360
361template<typename T, typename I> struct MinArg;
362template<typename T, typename I> struct MaxArg;
363template<typename T, typename I> struct MinMaxArg;
364
365MR_CANONICAL_TYPEDEFS( (template <typename V> struct MRMESH_CLASS), Ball,
366 ( Ball1f, Ball<float> )
367 ( Ball1d, Ball<double> )
368 ( Ball2f, Ball<Vector2<float>> )
369 ( Ball2d, Ball<Vector2<double>> )
370 ( Ball3f, Ball<Vector3<float>> )
371 ( Ball3d, Ball<Vector3<double>> )
372)
373template <typename T> using Ball1 = Ball<T>;
374template <typename T> using Ball2 = Ball<Vector2<T>>;
375template <typename T> using Ball3 = Ball<Vector3<T>>;
376
377MR_CANONICAL_TYPEDEFS( (template <typename V> struct MRMESH_CLASS), CubicBezierCurve,
378 ( CubicBezierCurve2f, CubicBezierCurve<Vector2<float>> )
379 ( CubicBezierCurve2d, CubicBezierCurve<Vector2<double>> )
380 ( CubicBezierCurve3f, CubicBezierCurve<Vector3<float>> )
381 ( CubicBezierCurve3d, CubicBezierCurve<Vector3<double>> )
382)
383template <typename T> using CubicBezierCurve2 = CubicBezierCurve<Vector2<T>>;
384template <typename T> using CubicBezierCurve3 = CubicBezierCurve<Vector3<T>>;
385
386MR_CANONICAL_TYPEDEFS( (template <typename V> struct), QuadraticForm,
387 ( QuadraticForm2f, QuadraticForm<Vector2<float>> )
388 ( QuadraticForm2d, QuadraticForm<Vector2<double>> )
389 ( QuadraticForm3f, QuadraticForm<Vector3<float>> )
390 ( QuadraticForm3d, QuadraticForm<Vector3<double>> )
391)
392template <typename T> using QuadraticForm2 = QuadraticForm<Vector2<T>>;
393template <typename T> using QuadraticForm3 = QuadraticForm<Vector3<T>>;
394
395MR_CANONICAL_TYPEDEFS( (template <typename T> struct), Quaternion,
396 ( Quaternionf, Quaternion<float> )
397 ( Quaterniond, Quaternion<double> )
398)
399
400// No canonical typedefs because `std::array` is not under our control.
401template <typename T> using Triangle3 = std::array<Vector3<T>, 3>;
402using Triangle3i = Triangle3<int>;
403using Triangle3f = Triangle3<float>;
404using Triangle3d = Triangle3<double>;
405
406class PointAccumulator;
407
408MR_CANONICAL_TYPEDEFS( (template <typename T> struct), SegmPoint,
409 ( SegmPointf, SegmPoint<float> )
410 ( SegmPointd, SegmPoint<double> )
411)
412
413struct EdgePoint;
414struct EdgeSegment;
416using SurfacePath = std::vector<MeshEdgePoint>;
417using SurfacePaths = std::vector<SurfacePath>;
422struct EdgePointPair;
423class Laplacian;
424
425using VertPair = std::pair<VertId, VertId>;
426using FacePair = std::pair<FaceId, FaceId>;
427using EdgePair = std::pair<EdgeId, EdgeId>;
428using UndirectedEdgePair = std::pair<UndirectedEdgeId, UndirectedEdgeId>;
429
430MR_CANONICAL_TYPEDEFS( (template <typename T> struct), TriPoint,
431 ( TriPointf, TriPoint<float> )
432 ( TriPointd, TriPoint<double> )
433)
434
435struct PointOnFace;
436struct PointOnObject;
437struct MeshTriPoint;
441template <typename T> struct IntersectionPrecomputes;
442
443template <typename I> struct IteratorRange;
444
447using UVCoord = Vector2f;
448
450using ThreeVertIds = std::array<VertId, 3>;
451
453
454MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> class MRMESH_CLASS), Vector,
456 ( Triangulation, Vector<ThreeVertIds, FaceId> )
457
458 ( Dipoles, Vector<Dipole, NodeId> )
459
460 ( FaceMap, Vector<FaceId, FaceId> )
461 ( VertMap, Vector<VertId, VertId> )
462 ( EdgeMap, Vector<EdgeId, EdgeId> )
463 ( UndirectedEdgeMap, Vector<UndirectedEdgeId, UndirectedEdgeId> )
464 ( ObjMap, Vector<ObjId, ObjId> )
465
467 ( WholeEdgeMap, Vector<EdgeId, UndirectedEdgeId> )
468 ( UndirectedEdge2RegionMap, Vector<RegionId, UndirectedEdgeId> )
469 ( Face2RegionMap, Vector<RegionId, FaceId> )
470 ( Vert2RegionMap, Vector<RegionId, VertId> )
471
472 ( VertCoords, Vector<Vector3f, VertId> )
473 ( VertCoords2, Vector<Vector2f, VertId> )
474 ( VertNormals, Vector<Vector3f, VertId> )
475 ( VertUVCoords, Vector<UVCoord, VertId> )
476 ( FaceNormals, Vector<Vector3f, FaceId> )
477
478 ( TexturePerFace, Vector<TextureId, FaceId> )
479 ( VertColors, Vector<Color, VertId> )
480 ( FaceColors, Vector<Color, FaceId> )
481 ( EdgeColors, Vector<Color, EdgeId> )
482 ( UndirectedEdgeColors, Vector<Color, UndirectedEdgeId> )
483
484 ( VertScalars, Vector<float, VertId> )
485 ( FaceScalars, Vector<float, FaceId> )
486 ( EdgeScalars, Vector<float, EdgeId> )
487 ( UndirectedEdgeScalars, Vector<float, UndirectedEdgeId> )
488)
489
490using VertPredicate = std::function<bool( VertId )>;
491using FacePredicate = std::function<bool( FaceId )>;
492using EdgePredicate = std::function<bool( EdgeId )>;
493using UndirectedEdgePredicate = std::function<bool( UndirectedEdgeId )>;
494
495using PreCollapseCallback = std::function<bool( EdgeId edgeToCollapse, const Vector3f& newEdgeOrgPos )>;
496using OnEdgeSplit = std::function<void( EdgeId e1, EdgeId e )>;
497
498template <typename T>
499[[nodiscard]] inline bool contains( const std::function<bool( Id<T> )> & pred, Id<T> id )
500{
501 return id.valid() && ( !pred || pred( id ) );
502}
503
504using VertMetric = std::function<float( VertId )>;
505using FaceMetric = std::function<float( FaceId )>;
506using EdgeMetric = std::function<float( EdgeId )>;
507using UndirectedEdgeMetric = std::function<float( UndirectedEdgeId )>;
508
509MR_CANONICAL_TYPEDEFS( (template <typename T, typename I> struct MRMESH_CLASS), BMap,
510 ( FaceBMap, BMap<FaceId, FaceId> )
511 ( VertBMap, BMap<VertId, VertId> )
512 ( EdgeBMap, BMap<EdgeId, EdgeId> )
513 ( UndirectedEdgeBMap, BMap<UndirectedEdgeId, UndirectedEdgeId> )
514 ( WholeEdgeBMap, BMap<EdgeId, UndirectedEdgeId> )
515)
516
517template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
518using HashSet = phmap::flat_hash_set<T, Hash, Eq>;
519template <typename T, typename Hash = phmap::priv::hash_default_hash<T>, typename Eq = phmap::priv::hash_default_eq<T>>
520using ParallelHashSet = phmap::parallel_flat_hash_set<T, Hash, Eq>;
521
522// No canonical typedefs because `phmap::...` is not under our control.
523using FaceHashSet = HashSet<FaceId>;
524using VertHashSet = HashSet<VertId>;
525using EdgeHashSet = HashSet<EdgeId>;
526
527template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
528using HashMap = phmap::flat_hash_map<K, V, Hash, Eq>;
529template <typename K, typename V, typename Hash = phmap::priv::hash_default_hash<K>, typename Eq = phmap::priv::hash_default_eq<K>>
530using ParallelHashMap = phmap::parallel_flat_hash_map<K, V, Hash, Eq>;
531
532using FaceHashMap = HashMap<FaceId, FaceId>;
533using VertHashMap = HashMap<VertId, VertId>;
534using EdgeHashMap = HashMap<EdgeId, EdgeId>;
535using UndirectedEdgeHashMap = HashMap<UndirectedEdgeId, UndirectedEdgeId>;
537using WholeEdgeHashMap = HashMap<UndirectedEdgeId, EdgeId>;
538
539template <typename K, typename V>
541
542using FaceMapOrHashMap = MapOrHashMap<FaceId, FaceId>;
543using VertMapOrHashMap = MapOrHashMap<VertId, VertId>;
544using EdgeMapOrHashMap = MapOrHashMap<EdgeId, EdgeId>;
545using UndirectedEdgeMapOrHashMap = MapOrHashMap<UndirectedEdgeId, UndirectedEdgeId>;
547using WholeEdgeMapOrHashMap = MapOrHashMap<UndirectedEdgeId, EdgeId>;
548
549template <typename I> class UnionFind;
550template <typename T, typename I, typename P> class Heap;
551
562struct MeshOrPointsXf;
563struct MeshTexture;
564struct GridSettings;
565struct TriMesh;
566
567MR_CANONICAL_TYPEDEFS( ( template <typename T> struct ), MRMESH_CLASS MeshRegion,
568 ( MeshPart, MeshRegion<FaceTag> )
569 ( MeshVertPart, MeshRegion<VertTag> )
570)
571
572template<typename T> class UniqueThreadSafeOwner;
573template<typename T> class SharedThreadSafeOwner;
574
575class PolylineTopology;
576
577MR_CANONICAL_TYPEDEFS( (template<typename V> struct), Polyline,
578 ( Polyline2, Polyline<Vector2f> )
579 ( Polyline3, Polyline<Vector3f> )
580)
581
584 ( AABBTreePolyline3, AABBTreePolyline<Vector3f> )
585)
586
587template<typename T> struct IntersectionPrecomputes;
588template<typename T> struct IntersectionPrecomputes2;
589
590MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionResult,
591 ( PolylineProjectionResult2, PolylineProjectionResult<Vector2f> )
592 ( PolylineProjectionResult3, PolylineProjectionResult<Vector3f> )
593)
594
595MR_CANONICAL_TYPEDEFS( (template<typename V> struct [[nodiscard]]), PolylineProjectionWithOffsetResult,
597 ( PolylineProjectionWithOffsetResult3, PolylineProjectionWithOffsetResult<Vector3f> )
598)
599
600class DistanceMap;
603
604using GcodeSource = std::vector<std::string>;
605
606class Object;
607class SceneRootObject;
608class VisualObject;
609class ObjectMeshHolder;
610class ObjectMesh;
611struct ObjectMeshData;
613class ObjectPoints;
615class ObjectLines;
617class ObjectLabel;
618class ObjectGcode;
619class PointObject;
620class LineObject;
621class CircleObject;
622class PlaneObject;
623class SphereObject;
624class CylinderObject;
625class ConeObject;
626
627struct LoadedObjects;
628
629struct Image;
631
632class HistoryAction;
639class ChangeMeshAction;
642class ChangeXfAction;
644class SwapRootAction;
645
646MR_CANONICAL_TYPEDEFS( (template <typename Tag> class MRMESH_CLASS), ColorMapAggregator,
647 ( VertColorMapAggregator, ColorMapAggregator<VertTag> )
648 ( UndirEdgeColorMapAggregator, ColorMapAggregator<UndirectedEdgeTag> )
649 ( FaceColorMapAggregator, ColorMapAggregator<FaceTag> )
650)
651
652template<typename T>
653class FewSmallest;
654
655class Graph;
656class WatershedGraph;
657
659
663typedef std::function<bool( float )> ProgressCallback;
664
665enum class FilterType : char
666{
667 Linear,
669};
670
671enum class WrapType : char
672{
673 Repeat,
674 Mirror,
675 Clamp
676};
677
679enum class Reorder : char
680{
681 None,
683 AABBTree
684};
685
687template <typename T>
688constexpr inline T sqr( T x ) noexcept { return x * x; }
689
691template <typename T>
692constexpr inline int sgn( T x ) noexcept { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
693
695template <typename T>
696constexpr inline T distance( T x, T y ) noexcept { return x >= y ? x - y : y - x; }
697
699template <typename T>
700constexpr inline T distanceSq( T x, T y ) noexcept { return sqr( x - y ); }
701
703template <typename V, typename T>
704constexpr inline auto lerp( V v0, V v1, T t ) noexcept { return ( 1 - t ) * v0 + t * v1; }
705
706template<typename...>
707inline constexpr bool dependent_false = false;
708
709template<class... Ts>
710struct overloaded : Ts... { using Ts::operator()...; };
711
712// explicit deduction guide (not needed as of C++20, but still needed in Clang)
713template<class... Ts>
714overloaded(Ts...) -> overloaded<Ts...>;
715
718class IPointsProjector;
719
720namespace MeshBuilder
721{
722
723struct BuildSettings;
724struct Triangle;
725struct VertDuplication;
726
727} //namespace MeshBuilder
728
729} //namespace MR
730
731#ifdef __cpp_lib_unreachable
732# define MR_UNREACHABLE std::unreachable();
733# define MR_UNREACHABLE_NO_RETURN std::unreachable();
734#else
735# ifdef __GNUC__
736# define MR_UNREACHABLE __builtin_unreachable();
737# define MR_UNREACHABLE_NO_RETURN __builtin_unreachable();
738# else
739# include <cassert>
740# define MR_UNREACHABLE { assert( false ); return {}; }
741# define MR_UNREACHABLE_NO_RETURN assert( false );
742# endif
743#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:550
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 for computing the closest points of point clouds
Definition MRPointsProject.h:91
Abstract class, computes the closest point on mesh to each of given points. Pure virtual functions mu...
Definition MRMesh/MRPointsToMeshProjector.h:13
Definition MRMesh/MRId.h:14
Definition MRMesh/MRLaplacian.h:34
Definition MRLineObject.h:12
Definition MRMesh/MRMeshOrPoints.h:17
Definition MRMesh/MRMeshTopology.h:18
Definition MRMesh/MRId.h:62
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:261
Definition MRSharedThreadSafeOwner.h:19
Definition MRSphereObject.h:15
Definition MRSwapRootAction.h:13
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:132
Union-find data structure for representing disjoin sets of elements with few very quick operations: 1...
Definition MRUnionFind.h:20
Definition MRUniqueThreadSafeOwner.h:18
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
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 TypedBitSet< I > *bitset, I id)
Definition MRMesh/MRBitSet.h:247
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:663
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
Definition MRCameraOrientationPlugin.h:8
std::function< float(VertId)> VertMetric
Definition MRMesh/MRMeshFwd.h:504
phmap::parallel_flat_hash_map< K, V, Hash, Eq > ParallelHashMap
Definition MRMesh/MRMeshFwd.h:530
std::vector< EdgeId > EdgeLoop
Definition MRMesh/MRMeshFwd.h:136
std::vector< std::string > GcodeSource
Definition MRMesh/MRMeshFwd.h:604
WrapType
Definition MRMesh/MRMeshFwd.h:672
std::vector< SurfacePath > SurfacePaths
Definition MRMesh/MRMeshFwd.h:417
std::vector< EdgeLoop > EdgeLoops
Definition MRMesh/MRMeshFwd.h:137
class MRMESH_CLASS UndirectedEdgeTag
Definition MRMesh/MRMeshFwd.h:94
constexpr T sqr(T x) noexcept
squared value
Definition MRMesh/MRMeshFwd.h:688
Cylinder3f
Definition MRMesh/MRMeshFwd.h:301
AABBTreePolyline2
Definition MRMesh/MRMeshFwd.h:583
Contour3< double > Contour3d
Definition MRMesh/MRMeshFwd.h:316
class MRMESH_CLASS ObjTag
Definition MRMesh/MRMeshFwd.h:101
Eq
Definition MRMesh/MRMeshFwd.h:517
std::function< bool(FaceId)> FacePredicate
Definition MRMesh/MRMeshFwd.h:491
MinMax< float > MinMaxf
Definition MRMesh/MRMeshFwd.h:353
Contour2< double > Contour2d
Definition MRMesh/MRMeshFwd.h:314
class MRMESH_CLASS NodeTag
Definition MRMesh/MRMeshFwd.h:100
HashSet< VertId > VertHashSet
Definition MRMesh/MRMeshFwd.h:524
std::function< bool(EdgeId)> EdgePredicate
Definition MRMesh/MRMeshFwd.h:492
Hash
Definition MRMesh/MRMeshFwd.h:517
Contour2< float > Contour2f
Definition MRMesh/MRMeshFwd.h:315
Contours2< double > Contours2d
Definition MRMesh/MRMeshFwd.h:322
std::function< bool(UndirectedEdgeId)> UndirectedEdgePredicate
Definition MRMesh/MRMeshFwd.h:493
SurfacePaths PlaneSections
Definition MRMesh/MRMeshFwd.h:421
HashMap< VertId, VertId > VertHashMap
Definition MRMesh/MRMeshFwd.h:533
class MRMESH_CLASS VoxelTag
Definition MRMesh/MRMeshFwd.h:98
FilterType
Definition MRMesh/MRMeshFwd.h:666
SurfacePath IsoLine
Definition MRMesh/MRMeshFwd.h:418
Vector2f UVCoord
Definition MRMesh/MRMeshFwd.h:447
Triangle3< int > Triangle3i
Definition MRMesh/MRMeshFwd.h:402
MRMESH_CLASS Vector3b
Definition MRMesh/MRMeshFwd.h:178
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:416
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:537
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:320
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4< double > SymMatrix3< double > AffineXf2f
Definition MRMesh/MRMeshFwd.h:242
overloaded(Ts...) -> overloaded< Ts... >
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4b
Definition MRMesh/MRMeshFwd.h:210
constexpr int sgn(T x) noexcept
sign of given value in { -1, 0, 1 }
Definition MRMesh/MRMeshFwd.h:692
Contours2< float > Contours2f
Definition MRMesh/MRMeshFwd.h:323
RigidScaleXf3f
Definition MRMesh/MRMeshFwd.h:256
std::function< float(EdgeId)> EdgeMetric
Definition MRMesh/MRMeshFwd.h:506
MinMax< double > MinMaxd
Definition MRMesh/MRMeshFwd.h:354
std::function< bool(EdgeId edgeToCollapse, const Vector3f &newEdgeOrgPos)> PreCollapseCallback
Definition MRMesh/MRMeshFwd.h:495
MinMax< int > MinMaxi
Definition MRMesh/MRMeshFwd.h:355
Contour< Vector2< T > > Contour2
Definition MRMesh/MRMeshFwd.h:312
SurfacePath PlaneSection
Definition MRMesh/MRMeshFwd.h:420
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:532
std::function< float(FaceId)> FaceMetric
Definition MRMesh/MRMeshFwd.h:505
Triangle3< double > Triangle3d
Definition MRMesh/MRMeshFwd.h:404
Box1i
Definition MRMesh/MRMeshFwd.h:339
Contour< Vector3< T > > Contour3
Definition MRMesh/MRMeshFwd.h:313
HashSet< FaceId > FaceHashSet
Definition MRMesh/MRMeshFwd.h:523
std::vector< EdgeId > EdgePath
Definition MRMesh/MRMeshFwd.h:135
std::array< VertId, 3 > ThreeVertIds
three vertex ids describing a triangle topology
Definition MRMesh/MRMeshFwd.h:450
class MRMESH_CLASS VertTag
Definition MRMesh/MRMeshFwd.h:96
std::pair< FaceId, FaceId > FacePair
Definition MRMesh/MRMeshFwd.h:426
constexpr NoInit noInit
Definition MRMesh/MRMeshFwd.h:90
HashSet< EdgeId > EdgeHashSet
Definition MRMesh/MRMeshFwd.h:525
std::pair< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgePair
Definition MRMesh/MRMeshFwd.h:428
Cone3f
Definition MRMesh/MRMeshFwd.h:306
BestFitParabolaf
Definition MRMesh/MRMeshFwd.h:296
std::pair< EdgeId, EdgeId > EdgePair
Definition MRMesh/MRMeshFwd.h:427
std::function< void(EdgeId e1, EdgeId e)> OnEdgeSplit
Definition MRMesh/MRMeshFwd.h:496
std::function< float(UndirectedEdgeId)> UndirectedEdgeMetric
Definition MRMesh/MRMeshFwd.h:507
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:704
constexpr bool dependent_false
Definition MRMesh/MRMeshFwd.h:707
Triangle3< float > Triangle3f
Definition MRMesh/MRMeshFwd.h:403
SurfacePaths IsoLines
Definition MRMesh/MRMeshFwd.h:419
class MRMESH_CLASS EdgeTag
Definition MRMesh/MRMeshFwd.h:93
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:325
std::vector< Contour< V > > Contours
Definition MRMesh/MRMeshFwd.h:319
Polyline2ProjectionWithOffsetResult
Definition MRMesh/MRMeshFwd.h:596
HashMap< EdgeId, EdgeId > EdgeHashMap
Definition MRMesh/MRMeshFwd.h:534
phmap::parallel_flat_hash_set< T, Hash, Eq > ParallelHashSet
Definition MRMesh/MRMeshFwd.h:520
MRMESH_CLASS Vector3< double > Matrix2b
Definition MRMesh/MRMeshFwd.h:194
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:425
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:317
HashMap< UndirectedEdgeId, UndirectedEdgeId > UndirectedEdgeHashMap
Definition MRMesh/MRMeshFwd.h:535
Contours< Vector3< T > > Contours3
Definition MRMesh/MRMeshFwd.h:321
Contours3< double > Contours3d
Definition MRMesh/MRMeshFwd.h:324
NoInitNodeId
Definition MRMesh/MRMeshFwd.h:122
class MRMESH_CLASS RegionTag
Definition MRMesh/MRMeshFwd.h:99
MRMESH_CLASS Vector3< double > Matrix2< double > Matrix4< double > SymMatrix3b
Definition MRMesh/MRMeshFwd.h:226
class MRMESH_CLASS GraphVertTag
Definition MRMesh/MRMeshFwd.h:103
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:528
class MRMESH_CLASS GraphEdgeTag
Definition MRMesh/MRMeshFwd.h:104
Reorder
determines how points to be ordered
Definition MRMesh/MRMeshFwd.h:680
@ 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
Definition MREdgeLengthMesh.h:13
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:588
Definition MRMesh/MRMeshFwd.h:441
Definition MRMesh/MRMeshFwd.h:443
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 MRMesh/MRMeshFwd.h:540
Definition MRMatrix2.h:19
Definition MRMesh/MRMatrix3.h:19
Definition MRMatrix4.h:20
Definition MRMinMaxArg.h:46
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:22
Definition MRMinMaxArg.h:13
Definition MRMinMaxArg.h:79
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
mapping among elements of source mesh, from which a part is taken, and target mesh
Definition MRPartMapping.h:10
Definition MRPlane3.h:17
Definition MRMesh/MRPointCloud.h:16
a point located on some mesh's face
Definition MRMesh/MRPointOnFace.h:11
Definition MRPointOnObject.h:17
Definition MRPointsProject.h:15
Definition MRPolylineProject.h:15
Definition MRPolylineProject.h:73
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 MRTbbTaskArenaAndGroup.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:710