MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/MRMesh.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshMath.h"
5#include "MRMeshProject.h"
6#include "MREdgePoint.h"
8#include "MRWriter.h"
9#include "MRConstants.h"
10#include "MRProgressCallback.h"
11#include <cfloat>
12
13namespace MR
14{
15
17
21struct [[nodiscard]] Mesh
22{
24 VertCoords points;
25
27 [[nodiscard]] MRMESH_API static Mesh fromTriangles(
28 VertCoords vertexCoordinates,
29 const Triangulation& t, const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
30
32 [[nodiscard]] MRMESH_API static Mesh fromTriMesh(
33 TriMesh && triMesh,
34 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
35
39 VertCoords vertexCoordinates,
40 Triangulation & t,
41 std::vector<MeshBuilder::VertDuplication> * dups = nullptr,
42 const MeshBuilder::BuildSettings & settings = {} );
43
47 [[nodiscard]] MRMESH_API static Mesh fromFaceSoup(
48 VertCoords vertexCoordinates,
49 const std::vector<VertId> & verts, const Vector<MeshBuilder::VertSpan, FaceId> & faces,
50 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
51
55 [[nodiscard]] MRMESH_API static Mesh fromPointTriples( const std::vector<Triangle3f> & posTriples, bool duplicateNonManifoldVertices );
56
58 [[nodiscard]] MRMESH_API bool operator ==( const Mesh & b ) const;
59
61 [[nodiscard]] Vector3f orgPnt( EdgeId e ) const { return MR::orgPnt( topology, points, e ); }
62
64 [[nodiscard]] Vector3f destPnt( EdgeId e ) const { return MR::destPnt( topology, points, e ); }
65
67 [[nodiscard]] Vector3f edgeVector( EdgeId e ) const { return MR::edgeVector( topology, points, e ); }
68
70 [[nodiscard]] LineSegm3f edgeSegment( EdgeId e ) const { return MR::edgeSegment( topology, points, e ); }
71
73 [[nodiscard]] Vector3f edgePoint( EdgeId e, float f ) const { return MR::edgePoint( topology, points, e, f ); }
74
76 [[nodiscard]] Vector3f edgePoint( const MeshEdgePoint & ep ) const { return MR::edgePoint( topology, points, ep ); }
77
79 [[nodiscard]] Vector3f edgeCenter( UndirectedEdgeId e ) const { return MR::edgeCenter( topology, points, e ); }
80
82 void getLeftTriPoints( EdgeId e, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const { return MR::getLeftTriPoints( topology, points, e, v0, v1, v2 ); }
83
85 void getLeftTriPoints( EdgeId e, Vector3f (&v)[3] ) const { return MR::getLeftTriPoints( topology, points, e, v ); }
86
88 [[nodiscard]] Triangle3f getLeftTriPoints( EdgeId e ) const { return MR::getLeftTriPoints( topology, points, e ); }
89
91 void getTriPoints( FaceId f, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const { return MR::getTriPoints( topology, points, f, v0, v1, v2 ); }
92
94 void getTriPoints( FaceId f, Vector3f (&v)[3] ) const { return MR::getTriPoints( topology, points, f, v ); }
95
97 [[nodiscard]] Triangle3f getTriPoints( FaceId f ) const { return MR::getTriPoints( topology, points, f ); }
98
100 [[nodiscard]] Vector3f triPoint( const MeshTriPoint & p ) const { return MR::triPoint( topology, points, p ); }
101
103 [[nodiscard]] Vector3f triCenter( FaceId f ) const { return MR::triCenter( topology, points, f ); }
104
106 [[nodiscard]] float triangleAspectRatio( FaceId f ) const { return MR::triangleAspectRatio( topology, points, f ); }
107
109 [[nodiscard]] float circumcircleDiameterSq( FaceId f ) const { return MR::circumcircleDiameterSq( topology, points, f ); }
110
112 [[nodiscard]] float circumcircleDiameter( FaceId f ) const { return MR::circumcircleDiameter( topology, points, f ); }
113
115 [[nodiscard]] MRMESH_API MeshTriPoint toTriPoint( VertId v ) const;
116
118 [[nodiscard]] MeshTriPoint toTriPoint( FaceId f, const Vector3f & p ) const { return MR::toTriPoint( topology, points, f, p ); }
119
121 [[nodiscard]] MeshTriPoint toTriPoint( const PointOnFace& p ) const { return MR::toTriPoint( topology, points, p ); }
122
124 [[nodiscard]] MRMESH_API MeshEdgePoint toEdgePoint( VertId v ) const;
125
127 [[nodiscard]] MeshEdgePoint toEdgePoint( EdgeId e, const Vector3f & p ) const { return MR::toEdgePoint( topology, points, e, p ); }
128
130 [[nodiscard]] VertId getClosestVertex( const PointOnFace & p ) const { return MR::getClosestVertex( topology, points, p ); }
131
133 [[nodiscard]] VertId getClosestVertex( const MeshTriPoint & p ) const { return MR::getClosestVertex( topology, points, p ); }
134
136 [[nodiscard]] UndirectedEdgeId getClosestEdge( const PointOnFace & p ) const { return MR::getClosestEdge( topology, points, p ); }
137
139 [[nodiscard]] UndirectedEdgeId getClosestEdge( const MeshTriPoint & p ) const { return MR::getClosestEdge( topology, points, p ); }
140
142 [[nodiscard]] float edgeLength( UndirectedEdgeId e ) const { return MR::edgeLength( topology, points, e ); }
143
145 [[nodiscard]] UndirectedEdgeScalars edgeLengths() const { return MR::edgeLengths( topology, points ); }
146
148 [[nodiscard]] float edgeLengthSq( UndirectedEdgeId e ) const { return MR::edgeLengthSq( topology, points, e ); }
149
151 [[nodiscard]] Vector3f leftDirDblArea( EdgeId e ) const { return MR::leftDirDblArea( topology, points, e ); }
152
154 [[nodiscard]] Vector3f dirDblArea( FaceId f ) const { return MR::dirDblArea( topology, points, f ); }
155
157 [[nodiscard]] float dblArea( FaceId f ) const { return MR::dblArea( topology, points, f ); }
158
160 [[nodiscard]] float area( FaceId f ) const { return MR::area( topology, points, f ); }
161
163 [[nodiscard]] double area( const FaceBitSet & fs ) const { return MR::area( topology, points, fs ); }
164
166 [[nodiscard]] double area( const FaceBitSet * fs = nullptr ) const { return MR::area( topology, points, fs ); }
167
169 [[nodiscard]] Vector3d dirArea( const FaceBitSet & fs ) const { return MR::dirArea( topology, points, fs ); }
170
172 [[nodiscard]] Vector3d dirArea( const FaceBitSet * fs = nullptr ) const { return MR::dirArea( topology, points, fs ); }
173
175 [[nodiscard]] double projArea( const Vector3f & dir, const FaceBitSet & fs ) const { return MR::projArea( topology, points, dir, fs ); }
176
178 [[nodiscard]] double projArea( const Vector3f & dir, const FaceBitSet * fs = nullptr ) const { return MR::projArea( topology, points, dir, fs ); }
179
182 [[nodiscard]] double volume( const FaceBitSet* region = nullptr ) const { return MR::volume( topology, points, region ); }
183
185 [[nodiscard]] double holePerimiter( EdgeId e ) const { return MR::holePerimiter( topology, points, e ); }
186
189 [[nodiscard]] Vector3d holeDirArea( EdgeId e ) const { return MR::holeDirArea( topology, points, e ); }
190
192 [[nodiscard]] Vector3f leftTangent( EdgeId e ) const { return MR::leftTangent( topology, points, e ); }
193
195 [[nodiscard]] Vector3f leftNormal( EdgeId e ) const { return MR::leftNormal( topology, points, e ); }
196
198 [[nodiscard]] Vector3f normal( FaceId f ) const { return MR::normal( topology, points, f ); }
199
201 [[nodiscard]] Vector3f dirDblArea( VertId v ) const { return MR::dirDblArea( topology, points, v ); }
202
204 [[nodiscard]] float dblArea( VertId v ) const { return MR::dblArea( topology, points, v ); }
205
207 [[nodiscard]] Vector3f normal( VertId v ) const { return MR::normal( topology, points, v ); }
208
211 [[nodiscard]] Vector3f normal( const MeshTriPoint & p ) const { return MR::normal( topology, points, p ); }
212
215 [[nodiscard]] Vector3f pseudonormal( VertId v, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, v, region ); }
216
218 [[nodiscard]] Vector3f pseudonormal( UndirectedEdgeId e, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, e, region ); }
219
224 [[nodiscard]] Vector3f pseudonormal( const MeshTriPoint & p, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, p, region ); }
225
229 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
230 [[deprecated]] MRMESH_API float signedDistance( const Vector3f & pt, const MeshTriPoint & proj, const FaceBitSet * region = nullptr ) const;
231
235 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt ) const;
236
241 [[nodiscard]] MRMESH_API std::optional<float> signedDistance( const Vector3f & pt, float maxDistSq, const FaceBitSet * region = nullptr ) const;
242
248 [[nodiscard]] MRMESH_API float calcFastWindingNumber( const Vector3f & pt, float beta = 2 ) const;
249
252 [[nodiscard]] bool isOutside( const Vector3f & pt, float windingNumberThreshold = 0.5f, float beta = 2 ) const { return calcFastWindingNumber( pt, beta ) <= windingNumberThreshold; }
253
257 [[nodiscard]] MRMESH_API bool isOutsideByProjNorm( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
258
260 [[nodiscard]] float sumAngles( VertId v, bool * outBoundaryVert = nullptr ) const { return MR::sumAngles( topology, points, v, outBoundaryVert ); }
261
263 [[nodiscard]] Expected<VertBitSet> findSpikeVertices( float minSumAngle, const VertBitSet* region = nullptr, const ProgressCallback& cb = {} ) const { return MR::findSpikeVertices( topology, points, minSumAngle, region, cb ); }
264
269 [[nodiscard]] float dihedralAngleSin( UndirectedEdgeId e ) const { return MR::dihedralAngleSin( topology, points, e ); }
270
275 [[nodiscard]] float dihedralAngleCos( UndirectedEdgeId e ) const { return MR::dihedralAngleCos( topology, points, e ); }
276
282 [[nodiscard]] float dihedralAngle( UndirectedEdgeId e ) const { return MR::dihedralAngle( topology, points, e ); }
283
286 [[nodiscard]] float discreteMeanCurvature( VertId v ) const { return MR::discreteMeanCurvature( topology, points, v ); }
287
290 [[nodiscard]] float discreteMeanCurvature( UndirectedEdgeId e ) const { return MR::discreteMeanCurvature( topology, points, e ); }
291
295 [[nodiscard]] float discreteGaussianCurvature( VertId v, bool * outBoundaryVert = nullptr ) const { return MR::discreteGaussianCurvature( topology, points, v, outBoundaryVert ); }
296
298 [[nodiscard]] UndirectedEdgeBitSet findCreaseEdges( float angleFromPlanar ) const { return MR::findCreaseEdges( topology, points, angleFromPlanar ); }
299
302 [[nodiscard]] float leftCotan( EdgeId e ) const { return MR::leftCotan( topology, points, e ); }
303
306 [[nodiscard]] float cotan( UndirectedEdgeId ue ) const { return MR::cotan( topology, points, ue ); }
307
311 [[nodiscard]] MRMESH_API QuadraticForm3f quadraticForm( VertId v, bool angleWeigted,
312 const FaceBitSet * region = nullptr, const UndirectedEdgeBitSet * creases = nullptr ) const;
313
316 [[nodiscard]] MRMESH_API Box3f getBoundingBox() const;
317
320 [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const AffineXf3f * toWorld = nullptr ) const;
321
324 [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const FaceBitSet* region, const AffineXf3f* toWorld = nullptr ) const;
325
327 [[nodiscard]] float averageEdgeLength() const { return MR::averageEdgeLength( topology, points ); }
328
330 [[nodiscard]] Vector3f findCenterFromPoints() const { return MR::findCenterFromPoints( topology, points ); }
331
333 [[nodiscard]] Vector3f findCenterFromFaces() const { return MR::findCenterFromFaces( topology, points ); }
334
336 [[nodiscard]] Vector3f findCenterFromBBox() const { return MR::findCenterFromBBox( topology, points ); }
337
340
343 MRMESH_API void transform( const AffineXf3f& xf, const VertBitSet* region = nullptr );
344
346 MRMESH_API VertId addPoint( const Vector3f & pos );
347
350 MRMESH_API EdgeId addSeparateEdgeLoop(const std::vector<Vector3f>& contourPoints);
351
354 MRMESH_API EdgeId addSeparateContours( const Contours3f& contours, const AffineXf3f* xf = nullptr );
355
360 MRMESH_API void attachEdgeLoopPart( EdgeId first, EdgeId last, const std::vector<Vector3f>& contourPoints );
361
370 MRMESH_API EdgeId splitEdge( EdgeId e, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
371 // same, but split given edge on two equal parts
372 EdgeId splitEdge( EdgeId e, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitEdge( e, edgeCenter( e ), region, new2Old ); }
373
377 MRMESH_API VertId splitFace( FaceId f, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
378 // same, putting new vertex in the centroid of original triangle
379 VertId splitFace( FaceId f, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitFace( f, triCenter( f ), region, new2Old ); }
380
382 MRMESH_API void addMesh( const Mesh & from,
383 // optionally returns mappings: from.id -> this.id
384 FaceMap * outFmap = nullptr, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
385 [[deprecated]] void addPart( const Mesh & from, FaceMap * outFmap = nullptr, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false )
386 { addMesh( from, outFmap, outVmap, outEmap, rearrangeTriangles ); }
387
389 MRMESH_API void addMeshPart( const MeshPart & from, const PartMapping & map );
390 [[deprecated]] void addPartByMask( const Mesh & from, const FaceBitSet & fromFaces, const PartMapping & map ) { addMeshPart( { from, &fromFaces }, map ); }
391
394 MRMESH_API void addMeshPart( const MeshPart & from, bool flipOrientation = false,
395 const std::vector<EdgePath> & thisContours = {}, // contours on this mesh that have to be stitched with
396 const std::vector<EdgePath> & fromContours = {}, // contours on from mesh during addition
397 // optionally returns mappings: from.id -> this.id
398 const PartMapping & map = {} );
399 [[deprecated]] void addPartByMask( const Mesh & from, const FaceBitSet & fromFaces, bool flipOrientation = false,
400 const std::vector<EdgePath> & thisContours = {}, const std::vector<EdgePath> & fromContours = {}, const PartMapping & map = {} )
401 { addMeshPart( { from, &fromFaces }, flipOrientation, thisContours, fromContours, map ); }
402
404 MRMESH_API void addPartByFaceMap( const Mesh & from, const FaceMap & fromFaces, bool flipOrientation = false,
405 const std::vector<EdgePath> & thisContours = {}, // contours on this mesh that have to be stitched with
406 const std::vector<EdgePath> & fromContours = {}, // contours on from mesh during addition
407 // optionally returns mappings: from.id -> this.id
408 const PartMapping & map = {} );
409
411 template<typename I>
412 MRMESH_API void addPartBy( const Mesh & from, I fbegin, I fend, size_t fcount, bool flipOrientation = false,
413 const std::vector<EdgePath> & thisContours = {},
414 const std::vector<EdgePath> & fromContours = {},
415 PartMapping map = {} );
416
418 MRMESH_API Mesh cloneRegion( const FaceBitSet & region, bool flipOrientation = false, const PartMapping & map = {} ) const;
419
422 MRMESH_API void pack( FaceMap * outFmap = nullptr, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
423
427
430 MRMESH_API PackMapping packOptimally( bool preserveAABBTree = true );
432
434 MRMESH_API void deleteFaces( const FaceBitSet & fs, const UndirectedEdgeBitSet * keepEdges = nullptr );
435
442 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, PointOnFace& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
443
450 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, MeshProjectionResult& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
451 [[nodiscard]] bool findClosestPoint( const Vector3f& point, MeshProjectionResult& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const { return projectPoint( point, res, maxDistSq, region, xf ); }
452
459 [[nodiscard]] MRMESH_API std::optional<MeshProjectionResult> projectPoint( const Vector3f& point, float maxDistSq = FLT_MAX, const FaceBitSet * region = nullptr, const AffineXf3f * xf = nullptr ) const;
460 [[nodiscard]] std::optional<MeshProjectionResult> findClosestPoint( const Vector3f& point, float maxDistSq = FLT_MAX, const FaceBitSet * region = nullptr, const AffineXf3f * xf = nullptr ) const { return projectPoint( point, maxDistSq, region, xf ); }
461
464
466 [[nodiscard]] const AABBTree * getAABBTreeNotCreate() const { return AABBTreeOwner_.get(); }
467
470
472 [[nodiscard]] const AABBTreePoints * getAABBTreePointsNotCreate() const { return AABBTreePointsOwner_.get(); }
473
475 MRMESH_API const Dipoles & getDipoles() const;
476
478 [[nodiscard]] const Dipoles * getDipolesNotCreate() const { return dipolesOwner_.get(); }
479
482 MRMESH_API void invalidateCaches( bool pointsChanged = true );
483
487 MRMESH_API void updateCaches( const VertBitSet & changedVerts );
488
489 // returns the amount of memory this object occupies on heap
490 [[nodiscard]] MRMESH_API size_t heapBytes() const;
491
494
496 MRMESH_API void mirror( const Plane3f& plane );
497
498private:
499 mutable SharedThreadSafeOwner<AABBTree> AABBTreeOwner_;
500 mutable SharedThreadSafeOwner<AABBTreePoints> AABBTreePointsOwner_;
501 mutable SharedThreadSafeOwner<Dipoles> dipolesOwner_;
502};
503
504} //namespace MR
constexpr bool operator==(ImVec2 a, ImVec2 b)
Definition MRImGuiVectorOperators.h:117
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
Definition MRAABBTree.h:16
Definition MRMesh/MRMeshTopology.h:18
Definition MRSharedThreadSafeOwner.h:19
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:641
MRMESH_API Vector3f findCenterFromBBox(const MeshTopology &topology, const VertCoords &points)
computes bounding box and returns its center
float discreteGaussianCurvature(const MeshTopology &topology, const VertCoords &points, VertId v, bool *outBoundaryVert=nullptr)
Definition MRMeshMath.h:292
MRMESH_API Vector3f findCenterFromFaces(const MeshTopology &topology, const VertCoords &points)
computes center of mass considering that density of all triangles is the same
MRMESH_API Vector3f findCenterFromPoints(const MeshTopology &topology, const VertCoords &points)
computes average position of all valid mesh vertices
MRMESH_API UndirectedEdgeScalars edgeLengths(const MeshTopology &topology, const VertCoords &points)
computes and returns the lengths of all edges in the mesh
MRMESH_API Expected< VertBitSet > findSpikeVertices(const MeshTopology &topology, const VertCoords &points, float minSumAngle, const VertBitSet *region=nullptr, const ProgressCallback &cb={})
returns vertices where the sum of triangle angles is below given threshold
float area(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns the area of given face
Definition MRMeshMath.h:166
MRMESH_API Vector3f leftTangent(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes unit vector that is both orthogonal to given edge and to the normal of its left triangle,...
LineSegm3f edgeSegment(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns line segment of given edge
Definition MRMeshMath.h:30
MRMESH_API float circumcircleDiameter(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns circumcircle diameter of given mesh triangle
Vector3f edgeVector(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns vector equal to edge destination point minus edge origin point
Definition MRMeshMath.h:24
MRMESH_API float dihedralAngle(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
MRMESH_API MeshEdgePoint toEdgePoint(const MeshTopology &topology, const VertCoords &points, EdgeId e, const Vector3f &p)
converts edge and 3d point into edge-point representation
MRMESH_API Vector3f triCenter(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns the centroid of given triangle
MRMESH_API UndirectedEdgeBitSet findCreaseEdges(const MeshTopology &topology, const VertCoords &points, float angleFromPlanar)
finds all mesh edges where dihedral angle is distinct from planar PI angle on at least given value
MRMESH_API float dihedralAngleCos(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
void getTriPoints(const MeshTopology &topology, const VertCoords &points, FaceId f, Vector3f &v0, Vector3f &v1, Vector3f &v2)
returns three points of given face
Definition MRMeshMath.h:71
MRMESH_API Vector3d holeDirArea(const MeshTopology &topology, const VertCoords &points, EdgeId e)
MRMESH_API MeshTriPoint toTriPoint(const MeshTopology &topology, const VertCoords &points, FaceId f, const Vector3f &p)
converts face id and 3d point into barycentric representation
MRMESH_API float averageEdgeLength(const MeshTopology &topology, const VertCoords &points)
computes average length of an edge in the mesh given by (topology, points)
Vector3f destPnt(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns coordinates of the edge destination
Definition MRMeshMath.h:18
MRMESH_API float leftCotan(const MeshTopology &topology, const VertCoords &points, EdgeId e)
Vector3f dirDblArea(const MeshTopology &topology, const VertCoords &points, FaceId f)
computes directed double area for a triangular face from its vertices
Definition MRMeshMath.h:151
MRMESH_API float triangleAspectRatio(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns aspect ratio of given mesh triangle equal to the ratio of the circum-radius to twice its in-r...
MRMESH_API Vector3d dirArea(const MeshTopology &topology, const VertCoords &points, const FaceBitSet &fs)
computes the sum of directed areas for faces from given region
tl::expected< T, E > Expected
Definition MRExpected.h:59
MRMESH_API void getLeftTriPoints(const MeshTopology &topology, const VertCoords &points, EdgeId e, Vector3f &v0, Vector3f &v1, Vector3f &v2)
returns three points of left face of e: v0 = orgPnt( e ), v1 = destPnt( e )
Vector3f edgePoint(const MeshTopology &topology, const VertCoords &points, EdgeId e, float f)
returns a point on the edge: origin point for f=0 and destination point for f=1
Definition MRMeshMath.h:36
MRMESH_API Vector3f pseudonormal(const MeshTopology &topology, const VertCoords &points, VertId v, const FaceBitSet *region=nullptr)
float edgeLengthSq(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
returns squared Euclidean length of the edge (faster to compute than length)
Definition MRMeshMath.h:142
MRMESH_API double volume(const MeshTopology &topology, const VertCoords &points, const FaceBitSet *region=nullptr)
MRMESH_API Vector3f triPoint(const MeshTopology &topology, const VertCoords &points, const MeshTriPoint &p)
computes coordinates of point given as face and barycentric representation
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:520
Vector3f orgPnt(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns coordinates of the edge origin
Definition MRMeshMath.h:12
MRMESH_API float discreteMeanCurvature(const MeshTopology &topology, const VertCoords &points, VertId v)
MRMESH_API float circumcircleDiameterSq(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns squared circumcircle diameter of given mesh triangle
Vector3f edgeCenter(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
computes the center of given edge
Definition MRMeshMath.h:48
MRMESH_API UndirectedEdgeId getClosestEdge(const MeshTopology &topology, const VertCoords &points, const PointOnFace &p)
returns one of three face edges, closest to given point
float dblArea(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns twice the area of given face
Definition MRMeshMath.h:160
Triangle3< float > Triangle3f
Definition MRMesh/MRMeshFwd.h:391
float edgeLength(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
returns Euclidean length of the edge
Definition MRMeshMath.h:133
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:318
MRMESH_API double holePerimiter(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes the perimeter of the hole specified by one of its edges with no valid left face (left is hol...
MRMESH_API VertId getClosestVertex(const MeshTopology &topology, const VertCoords &points, const PointOnFace &p)
returns one of three face vertices, closest to given point
MRMESH_API Vector3f leftDirDblArea(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes directed double area of left triangular face of given edge
MRMESH_API double projArea(const MeshTopology &topology, const VertCoords &points, const Vector3f &dir, const FaceBitSet &fs)
computes the sum of absolute projected area of faces from given region as visible if look from given ...
float cotan(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId ue)
Definition MRMeshMath.h:306
MRMESH_API float sumAngles(const MeshTopology &topology, const VertCoords &points, VertId v, bool *outBoundaryVert=nullptr)
computes the sum of triangle angles at given vertex; optionally returns whether the vertex is on boun...
Vector3f leftNormal(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes triangular face normal from its vertices
Definition MRMeshMath.h:213
MRMESH_API float dihedralAngleSin(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:11
Definition MRMeshBuilderTypes.h:30
Definition MRMesh/MRMeshProject.h:18
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:22
MRMESH_API float signedDistance(const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
Vector3d dirArea(const FaceBitSet *fs=nullptr) const
computes the sum of directed areas for faces from given region (or whole mesh)
Definition MRMesh/MRMesh.h:172
Vector3f pseudonormal(VertId v, const FaceBitSet *region=nullptr) const
Definition MRMesh/MRMesh.h:215
float area(FaceId f) const
returns the area of given face
Definition MRMesh/MRMesh.h:160
MRMESH_API void addMesh(const Mesh &from, FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
appends another mesh as separate connected component(s) to this
float discreteMeanCurvature(VertId v) const
Definition MRMesh/MRMesh.h:286
VertId getClosestVertex(const MeshTriPoint &p) const
returns one of three face vertices, closest to given point
Definition MRMesh/MRMesh.h:133
MRMESH_API Box3f computeBoundingBox(const FaceBitSet *region, const AffineXf3f *toWorld=nullptr) const
float circumcircleDiameterSq(FaceId f) const
returns squared circumcircle diameter of given mesh triangle
Definition MRMesh/MRMesh.h:109
MRMESH_API float calcFastWindingNumber(const Vector3f &pt, float beta=2) const
float dihedralAngleCos(UndirectedEdgeId e) const
Definition MRMesh/MRMesh.h:275
MRMESH_API bool isOutsideByProjNorm(const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
MRMESH_API void shrinkToFit()
requests the removal of unused capacity
Vector3f normal(const MeshTriPoint &p) const
Definition MRMesh/MRMesh.h:211
Vector3d dirArea(const FaceBitSet &fs) const
computes the sum of directed areas for faces from given region
Definition MRMesh/MRMesh.h:169
MRMESH_API const AABBTree & getAABBTree() const
returns cached aabb-tree for this mesh, creating it if it did not exist in a thread-safe manner
float discreteGaussianCurvature(VertId v, bool *outBoundaryVert=nullptr) const
Definition MRMesh/MRMesh.h:295
Vector3f edgeVector(EdgeId e) const
returns vector equal to edge destination point minus edge origin point
Definition MRMesh/MRMesh.h:67
MRMESH_API QuadraticForm3f quadraticForm(VertId v, bool angleWeigted, const FaceBitSet *region=nullptr, const UndirectedEdgeBitSet *creases=nullptr) const
MRMESH_API std::optional< MeshProjectionResult > projectPoint(const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
float dblArea(FaceId f) const
returns twice the area of given face
Definition MRMesh/MRMesh.h:157
UndirectedEdgeBitSet findCreaseEdges(float angleFromPlanar) const
finds all mesh edges where dihedral angle is distinct from planar PI angle on at least given value
Definition MRMesh/MRMesh.h:298
MRMESH_API void deleteFaces(const FaceBitSet &fs, const UndirectedEdgeBitSet *keepEdges=nullptr)
deletes multiple given faces, also deletes adjacent edges and vertices if they were not shared by rem...
MRMESH_API float signedDistance(const Vector3f &pt, const MeshTriPoint &proj, const FaceBitSet *region=nullptr) const
MRMESH_API MeshTriPoint toTriPoint(VertId v) const
converts vertex into barycentric representation
MRMESH_API void addMeshPart(const MeshPart &from, const PartMapping &map)
appends whole or part of another mesh as separate connected component(s) to this
VertId getClosestVertex(const PointOnFace &p) const
returns one of three face vertices, closest to given point
Definition MRMesh/MRMesh.h:130
MRMESH_API Mesh cloneRegion(const FaceBitSet &region, bool flipOrientation=false, const PartMapping &map={}) const
creates new mesh from given triangles of this mesh
MRMESH_API Box3f computeBoundingBox(const AffineXf3f *toWorld=nullptr) const
const AABBTree * getAABBTreeNotCreate() const
returns cached aabb-tree for this mesh, but does not create it if it did not exist
Definition MRMesh/MRMesh.h:466
MRMESH_API void addPartBy(const Mesh &from, I fbegin, I fend, size_t fcount, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, PartMapping map={})
both addPartByMask and addPartByFaceMap call this general implementation
MRMESH_API std::optional< float > signedDistance(const Vector3f &pt, float maxDistSq, const FaceBitSet *region=nullptr) const
MRMESH_API const Dipoles & getDipoles() const
returns cached dipoles of aabb-tree nodes for this mesh, creating it if it did not exist in a thread-...
static MRMESH_API Mesh fromTriangles(VertCoords vertexCoordinates, const Triangulation &t, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
construct mesh from vertex coordinates and a set of triangles with given ids
double area(const FaceBitSet *fs=nullptr) const
computes the area of given face-region (or whole mesh)
Definition MRMesh/MRMesh.h:166
float sumAngles(VertId v, bool *outBoundaryVert=nullptr) const
computes the sum of triangle angles at given vertex; optionally returns whether the vertex is on boun...
Definition MRMesh/MRMesh.h:260
MRMESH_API VertId splitFace(FaceId f, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
double area(const FaceBitSet &fs) const
computes the area of given face-region
Definition MRMesh/MRMesh.h:163
float edgeLengthSq(UndirectedEdgeId e) const
returns squared Euclidean length of the edge (faster to compute than length)
Definition MRMesh/MRMesh.h:148
float discreteMeanCurvature(UndirectedEdgeId e) const
Definition MRMesh/MRMesh.h:290
MRMESH_API void zeroUnusedPoints()
for all points not in topology.getValidVerts() sets coordinates to (0,0,0)
static MRMESH_API Mesh fromPointTriples(const std::vector< Triangle3f > &posTriples, bool duplicateNonManifoldVertices)
Triangle3f getTriPoints(FaceId f) const
returns three points of given face
Definition MRMesh/MRMesh.h:97
EdgeId splitEdge(EdgeId e, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
Definition MRMesh/MRMesh.h:372
Vector3f edgePoint(EdgeId e, float f) const
returns a point on the edge: origin point for f=0 and destination point for f=1
Definition MRMesh/MRMesh.h:73
void getLeftTriPoints(EdgeId e, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
returns three points of left face of e: v0 = orgPnt( e ), v1 = destPnt( e )
Definition MRMesh/MRMesh.h:82
Vector3d holeDirArea(EdgeId e) const
Definition MRMesh/MRMesh.h:189
static MRMESH_API Mesh fromTrianglesDuplicatingNonManifoldVertices(VertCoords vertexCoordinates, Triangulation &t, std::vector< MeshBuilder::VertDuplication > *dups=nullptr, const MeshBuilder::BuildSettings &settings={})
Vector3f orgPnt(EdgeId e) const
returns coordinates of the edge origin
Definition MRMesh/MRMesh.h:61
UndirectedEdgeScalars edgeLengths() const
computes and returns the lengths of all edges in the mesh
Definition MRMesh/MRMesh.h:145
Vector3f destPnt(EdgeId e) const
returns coordinates of the edge destination
Definition MRMesh/MRMesh.h:64
float triangleAspectRatio(FaceId f) const
returns aspect ratio of given mesh triangle equal to the ratio of the circum-radius to twice its in-r...
Definition MRMesh/MRMesh.h:106
void addPartByMask(const Mesh &from, const FaceBitSet &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={})
Definition MRMesh/MRMesh.h:399
MRMESH_API Box3f getBoundingBox() const
float dihedralAngleSin(UndirectedEdgeId e) const
Definition MRMesh/MRMesh.h:269
bool findClosestPoint(const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Definition MRMesh/MRMesh.h:451
MRMESH_API void pack(FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
Triangle3f getLeftTriPoints(EdgeId e) const
returns three points of left face of e: res[0] = orgPnt( e ), res[1] = destPnt( e )
Definition MRMesh/MRMesh.h:88
MeshTriPoint toTriPoint(FaceId f, const Vector3f &p) const
converts face id and 3d point into barycentric representation
Definition MRMesh/MRMesh.h:118
MRMESH_API bool projectPoint(const Vector3f &point, PointOnFace &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
MRMESH_API EdgeId splitEdge(EdgeId e, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
float leftCotan(EdgeId e) const
Definition MRMesh/MRMesh.h:302
Vector3f leftNormal(EdgeId e) const
computes triangular face normal from its vertices
Definition MRMesh/MRMesh.h:195
MRMESH_API Expected< void > pack(const PackMapping &map, ProgressCallback cb={})
bool isOutside(const Vector3f &pt, float windingNumberThreshold=0.5f, float beta=2) const
Definition MRMesh/MRMesh.h:252
LineSegm3f edgeSegment(EdgeId e) const
returns line segment of given edge
Definition MRMesh/MRMesh.h:70
Vector3f leftTangent(EdgeId e) const
computes unit vector that is both orthogonal to given edge and to the normal of its left triangle,...
Definition MRMesh/MRMesh.h:192
MRMESH_API float signedDistance(const Vector3f &pt) const
std::optional< MeshProjectionResult > findClosestPoint(const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Definition MRMesh/MRMesh.h:460
const AABBTreePoints * getAABBTreePointsNotCreate() const
returns cached aabb-tree for points of this mesh, but does not create it if it did not exist
Definition MRMesh/MRMesh.h:472
void addPartByMask(const Mesh &from, const FaceBitSet &fromFaces, const PartMapping &map)
Definition MRMesh/MRMesh.h:390
VertId splitFace(FaceId f, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
Definition MRMesh/MRMesh.h:379
MRMESH_API void mirror(const Plane3f &plane)
reflects the mesh from a given plane
MeshTopology topology
Definition MRMesh/MRMesh.h:23
UndirectedEdgeId getClosestEdge(const MeshTriPoint &p) const
returns one of three face edges, closest to given point
Definition MRMesh/MRMesh.h:139
MRMESH_API void transform(const AffineXf3f &xf, const VertBitSet *region=nullptr)
MRMESH_API bool projectPoint(const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Vector3f findCenterFromFaces() const
computes center of mass considering that density of all triangles is the same
Definition MRMesh/MRMesh.h:333
Vector3f triCenter(FaceId f) const
returns the centroid of given triangle
Definition MRMesh/MRMesh.h:103
Vector3f triPoint(const MeshTriPoint &p) const
computes coordinates of point given as face and barycentric representation
Definition MRMesh/MRMesh.h:100
VertCoords points
Definition MRMesh/MRMesh.h:24
const Dipoles * getDipolesNotCreate() const
returns cached dipoles of aabb-tree nodes for this mesh, but does not create it if it did not exist
Definition MRMesh/MRMesh.h:478
Vector3f findCenterFromPoints() const
computes average position of all valid mesh vertices
Definition MRMesh/MRMesh.h:330
float cotan(UndirectedEdgeId ue) const
Definition MRMesh/MRMesh.h:306
float dblArea(VertId v) const
computes the length of summed directed double areas of all triangles around given vertex
Definition MRMesh/MRMesh.h:204
float dihedralAngle(UndirectedEdgeId e) const
Definition MRMesh/MRMesh.h:282
float averageEdgeLength() const
computes average length of an edge in this mesh
Definition MRMesh/MRMesh.h:327
MRMESH_API void attachEdgeLoopPart(EdgeId first, EdgeId last, const std::vector< Vector3f > &contourPoints)
Vector3f leftDirDblArea(EdgeId e) const
computes directed double area of left triangular face of given edge
Definition MRMesh/MRMesh.h:151
MRMESH_API Expected< PackMapping > packOptimally(bool preserveAABBTree, ProgressCallback cb)
MRMESH_API EdgeId addSeparateContours(const Contours3f &contours, const AffineXf3f *xf=nullptr)
Vector3f edgePoint(const MeshEdgePoint &ep) const
computes coordinates of point given as edge and relative position on it
Definition MRMesh/MRMesh.h:76
void getTriPoints(FaceId f, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
returns three points of given face
Definition MRMesh/MRMesh.h:91
void getTriPoints(FaceId f, Vector3f(&v)[3]) const
returns three points of given face
Definition MRMesh/MRMesh.h:94
MRMESH_API void addPartByFaceMap(const Mesh &from, const FaceMap &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={})
fromFaces contains mapping from this-mesh (considering it is empty) to from-mesh
MRMESH_API size_t heapBytes() const
Vector3f findCenterFromBBox() const
computes bounding box and returns its center
Definition MRMesh/MRMesh.h:336
Vector3f pseudonormal(const MeshTriPoint &p, const FaceBitSet *region=nullptr) const
Definition MRMesh/MRMesh.h:224
MRMESH_API void invalidateCaches(bool pointsChanged=true)
static MRMESH_API Mesh fromTriMesh(TriMesh &&triMesh, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
construct mesh from TriMesh representation
MRMESH_API PackMapping packOptimally(bool preserveAABBTree=true)
static MRMESH_API Mesh fromFaceSoup(VertCoords vertexCoordinates, const std::vector< VertId > &verts, const Vector< MeshBuilder::VertSpan, FaceId > &faces, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
Vector3f normal(FaceId f) const
computes triangular face normal from its vertices
Definition MRMesh/MRMesh.h:198
float circumcircleDiameter(FaceId f) const
returns circumcircle diameter of given mesh triangle
Definition MRMesh/MRMesh.h:112
MRMESH_API const AABBTreePoints & getAABBTreePoints() const
returns cached aabb-tree for points of this mesh, creating it if it did not exist in a thread-safe ma...
Vector3f pseudonormal(UndirectedEdgeId e, const FaceBitSet *region=nullptr) const
computes normalized half sum of face normals sharing given edge (only (region) faces will be consider...
Definition MRMesh/MRMesh.h:218
Vector3f edgeCenter(UndirectedEdgeId e) const
computes the center of given edge
Definition MRMesh/MRMesh.h:79
double holePerimiter(EdgeId e) const
computes the perimeter of the hole specified by one of its edges with no valid left face (left is hol...
Definition MRMesh/MRMesh.h:185
MRMESH_API void updateCaches(const VertBitSet &changedVerts)
float edgeLength(UndirectedEdgeId e) const
returns Euclidean length of the edge
Definition MRMesh/MRMesh.h:142
void addPart(const Mesh &from, FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
Definition MRMesh/MRMesh.h:385
MeshEdgePoint toEdgePoint(EdgeId e, const Vector3f &p) const
converts edge and 3d point into edge-point representation
Definition MRMesh/MRMesh.h:127
MRMESH_API MeshEdgePoint toEdgePoint(VertId v) const
converts vertex into edge-point representation
Vector3f dirDblArea(VertId v) const
computes sum of directed double areas of all triangles around given vertex
Definition MRMesh/MRMesh.h:201
Expected< VertBitSet > findSpikeVertices(float minSumAngle, const VertBitSet *region=nullptr, const ProgressCallback &cb={}) const
returns vertices where the sum of triangle angles is below given threshold
Definition MRMesh/MRMesh.h:263
double volume(const FaceBitSet *region=nullptr) const
Definition MRMesh/MRMesh.h:182
MRMESH_API void addMeshPart(const MeshPart &from, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={})
MRMESH_API VertId addPoint(const Vector3f &pos)
creates new point and assigns given position to it
void getLeftTriPoints(EdgeId e, Vector3f(&v)[3]) const
returns three points of left face of e: v[0] = orgPnt( e ), v[1] = destPnt( e )
Definition MRMesh/MRMesh.h:85
double projArea(const Vector3f &dir, const FaceBitSet *fs=nullptr) const
computes the sum of absolute projected area of faces from given region (or whole mesh) as visible if ...
Definition MRMesh/MRMesh.h:178
UndirectedEdgeId getClosestEdge(const PointOnFace &p) const
returns one of three face edges, closest to given point
Definition MRMesh/MRMesh.h:136
MeshTriPoint toTriPoint(const PointOnFace &p) const
converts face id and 3d point into barycentric representation
Definition MRMesh/MRMesh.h:121
double projArea(const Vector3f &dir, const FaceBitSet &fs) const
computes the sum of absolute projected area of faces from given region as visible if look from given ...
Definition MRMesh/MRMesh.h:175
Vector3f dirDblArea(FaceId f) const
computes directed double area for a triangular face from its vertices
Definition MRMesh/MRMesh.h:154
MRMESH_API EdgeId addSeparateEdgeLoop(const std::vector< Vector3f > &contourPoints)
Vector3f normal(VertId v) const
computes normal in a vertex using sum of directed areas of neighboring triangles
Definition MRMesh/MRMesh.h:207
Definition MRBuffer.h:151
Definition MRPartMapping.h:10
a point located on some mesh's face
Definition MRMesh/MRPointOnFace.h:11
Definition MRTriMesh.h:13