MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRPch/MRBindingMacros.h"
4#include "MRMeshMath.h"
6#include "MRVertDuplication.h"
7#include "MRMeshProject.h"
8#include "MREdgePoint.h"
10#include "MRWriter.h"
11#include "MRConstants.h"
12#include "MRProgressCallback.h"
13#include <cfloat>
14
15namespace MR
16{
17
19
23struct [[nodiscard]] Mesh
24{
26 VertCoords points;
27
29 [[nodiscard]] MRMESH_API static Mesh fromTriangles(
30 VertCoords vertexCoordinates,
31 const Triangulation& t, const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
32
34 [[nodiscard]] MRMESH_API static Mesh fromTriMesh(
35 TriMesh && triMesh,
36 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
37
42 VertCoords vertexCoordinates,
43 Triangulation & t,
44 std::vector<MeshBuilder::VertDuplication> * dups = nullptr,
45 const MeshBuilder::BuildSettings & settings = {},
46 const MeshBuilder::BetterDupContinuation & betterCont = {} );
47
52 TriMesh && triMesh,
53 std::vector<MeshBuilder::VertDuplication> * dups = nullptr,
54 const MeshBuilder::BuildSettings & settings = {},
55 const MeshBuilder::BetterDupContinuation & betterCont = {} );
56
59 [[nodiscard]] MRMESH_API static Mesh fromFaceSoup(
60 FaceSoup && soup,
61 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
62
66 [[nodiscard]] MRMESH_API static Mesh fromPointTriples( const std::vector<Triangle3f> & posTriples, bool duplicateNonManifoldVertices );
67
69 [[nodiscard]] MRMESH_API bool operator ==( const Mesh & b ) const;
70
72 [[nodiscard]] Vector3f orgPnt( EdgeId e ) const { return MR::orgPnt( topology, points, e ); }
73
75 [[nodiscard]] Vector3f destPnt( EdgeId e ) const { return MR::destPnt( topology, points, e ); }
76
78 [[nodiscard]] Vector3f edgeVector( EdgeId e ) const { return MR::edgeVector( topology, points, e ); }
79
81 [[nodiscard]] MRMESH_API LineSegm3f edgeSegment( EdgeId e ) const;
82
84 [[nodiscard]] Vector3f edgePoint( EdgeId e, float f ) const { return MR::edgePoint( topology, points, e, f ); }
85
87 [[nodiscard]] Vector3f edgePoint( const MeshEdgePoint & ep ) const { return MR::edgePoint( topology, points, ep ); }
88
90 [[nodiscard]] Vector3f edgeCenter( UndirectedEdgeId e ) const { return MR::edgeCenter( topology, points, e ); }
91
93 void getLeftTriPoints( EdgeId e, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const { return MR::getLeftTriPoints( topology, points, e, v0, v1, v2 ); }
94
97 MR_BIND_IGNORE void getLeftTriPoints( EdgeId e, Vector3f (&v)[3] ) const { return MR::getLeftTriPoints( topology, points, e, v ); }
98
100 [[nodiscard]] Triangle3f getLeftTriPoints( EdgeId e ) const { return MR::getLeftTriPoints( topology, points, e ); }
101
103 void getTriPoints( FaceId f, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const { return MR::getTriPoints( topology, points, f, v0, v1, v2 ); }
104
107 MR_BIND_IGNORE void getTriPoints( FaceId f, Vector3f (&v)[3] ) const { return MR::getTriPoints( topology, points, f, v ); }
108
110 [[nodiscard]] Triangle3f getTriPoints( FaceId f ) const { return MR::getTriPoints( topology, points, f ); }
111
113 [[nodiscard]] Vector3f triPoint( const MeshTriPoint & p ) const { return MR::triPoint( topology, points, p ); }
114
116 [[nodiscard]] Vector3f triCenter( FaceId f ) const { return MR::triCenter( topology, points, f ); }
117
119 [[nodiscard]] float triangleAspectRatio( FaceId f ) const { return MR::triangleAspectRatio( topology, points, f ); }
120
122 [[nodiscard]] float circumcircleDiameterSq( FaceId f ) const { return MR::circumcircleDiameterSq( topology, points, f ); }
123
125 [[nodiscard]] float circumcircleDiameter( FaceId f ) const { return MR::circumcircleDiameter( topology, points, f ); }
126
128 [[nodiscard]] MRMESH_API MeshTriPoint toTriPoint( VertId v ) const;
129
131 [[nodiscard]] MeshTriPoint toTriPoint( FaceId f, const Vector3f & p ) const { return MR::toTriPoint( topology, points, f, p ); }
132
134 [[nodiscard]] MeshTriPoint toTriPoint( const PointOnFace& p ) const { return MR::toTriPoint( topology, points, p ); }
135
137 [[nodiscard]] MRMESH_API MeshEdgePoint toEdgePoint( VertId v ) const;
138
140 [[nodiscard]] MeshEdgePoint toEdgePoint( EdgeId e, const Vector3f & p ) const { return MR::toEdgePoint( topology, points, e, p ); }
141
143 [[nodiscard]] VertId getClosestVertex( const PointOnFace & p ) const { return MR::getClosestVertex( topology, points, p ); }
144
146 [[nodiscard]] VertId getClosestVertex( const MeshTriPoint & p ) const { return MR::getClosestVertex( topology, points, p ); }
147
149 [[nodiscard]] UndirectedEdgeId getClosestEdge( const PointOnFace & p ) const { return MR::getClosestEdge( topology, points, p ); }
150
152 [[nodiscard]] UndirectedEdgeId getClosestEdge( const MeshTriPoint & p ) const { return MR::getClosestEdge( topology, points, p ); }
153
155 [[nodiscard]] float edgeLength( UndirectedEdgeId e ) const { return MR::edgeLength( topology, points, e ); }
156
158 [[nodiscard]] UndirectedEdgeScalars edgeLengths() const { return MR::edgeLengths( topology, points ); }
159
161 [[nodiscard]] float edgeLengthSq( UndirectedEdgeId e ) const { return MR::edgeLengthSq( topology, points, e ); }
162
164 [[nodiscard]] Vector3f leftDirDblArea( EdgeId e ) const { return MR::leftDirDblArea( topology, points, e ); }
165
167 [[nodiscard]] Vector3f dirDblArea( FaceId f ) const { return MR::dirDblArea( topology, points, f ); }
168
170 [[nodiscard]] float dblArea( FaceId f ) const { return MR::dblArea( topology, points, f ); }
171
173 [[nodiscard]] float area( FaceId f ) const { return MR::area( topology, points, f ); }
174
177 [[nodiscard]] MR_BIND_IGNORE double area( const FaceBitSet & fs ) const { return MR::area( topology, points, fs ); }
178
180 [[nodiscard]] double area( const FaceBitSet * fs = nullptr ) const { return MR::area( topology, points, fs ); }
181
184 [[nodiscard]] MR_BIND_IGNORE Vector3d dirArea( const FaceBitSet & fs ) const { return MR::dirArea( topology, points, fs ); }
185
187 [[nodiscard]] Vector3d dirArea( const FaceBitSet * fs = nullptr ) const { return MR::dirArea( topology, points, fs ); }
188
191 [[nodiscard]] MR_BIND_IGNORE double projArea( const Vector3f & dir, const FaceBitSet & fs ) const { return MR::projArea( topology, points, dir, fs ); }
192
194 [[nodiscard]] double projArea( const Vector3f & dir, const FaceBitSet * fs = nullptr ) const { return MR::projArea( topology, points, dir, fs ); }
195
198 [[nodiscard]] double volume( const FaceBitSet* region = nullptr ) const { return MR::volume( topology, points, region ); }
199
201 [[nodiscard]] double holePerimeter( EdgeId e ) const { return MR::holePerimeter( topology, points, e ); }
202
205 [[nodiscard]] Vector3d holeDirArea( EdgeId e ) const { return MR::holeDirArea( topology, points, e ); }
206
208 [[nodiscard]] Vector3f leftTangent( EdgeId e ) const { return MR::leftTangent( topology, points, e ); }
209
211 [[nodiscard]] Vector3f leftNormal( EdgeId e ) const { return MR::leftNormal( topology, points, e ); }
212
214 [[nodiscard]] Vector3f normal( FaceId f ) const { return MR::normal( topology, points, f ); }
215
217 [[nodiscard]] MRMESH_API Plane3f getPlane3f( FaceId f ) const;
218 [[nodiscard]] MRMESH_API Plane3d getPlane3d( FaceId f ) const;
219
221 [[nodiscard]] Vector3f dirDblArea( VertId v ) const { return MR::dirDblArea( topology, points, v ); }
222
224 [[nodiscard]] float dblArea( VertId v ) const { return MR::dblArea( topology, points, v ); }
225
227 [[nodiscard]] Vector3f normal( VertId v ) const { return MR::normal( topology, points, v ); }
228
231 [[nodiscard]] Vector3f normal( const MeshTriPoint & p ) const { return MR::normal( topology, points, p ); }
232
235 [[nodiscard]] Vector3f pseudonormal( VertId v, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, v, region ); }
236
238 [[nodiscard]] Vector3f pseudonormal( UndirectedEdgeId e, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, e, region ); }
239
244 [[nodiscard]] Vector3f pseudonormal( const MeshTriPoint & p, const FaceBitSet * region = nullptr ) const { return MR::pseudonormal( topology, points, p, region ); }
245
249 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
250
254 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt ) const;
255
260 [[nodiscard]] MRMESH_API std::optional<float> signedDistance( const Vector3f & pt, float maxDistSq, const FaceBitSet * region = nullptr ) const;
261
267 [[nodiscard]] MRMESH_API float calcFastWindingNumber( const Vector3f & pt, float beta = 2 ) const;
268
271 [[nodiscard]] bool isOutside( const Vector3f & pt, float windingNumberThreshold = 0.5f, float beta = 2 ) const { return calcFastWindingNumber( pt, beta ) <= windingNumberThreshold; }
272
276 [[nodiscard]] MRMESH_API bool isOutsideByProjNorm( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
277
279 [[nodiscard]] float sumAngles( VertId v, bool * outBoundaryVert = nullptr ) const { return MR::sumAngles( topology, points, v, outBoundaryVert ); }
280
282 [[nodiscard]] Expected<VertBitSet> findSpikeVertices( float minSumAngle, const VertBitSet* region = nullptr, const ProgressCallback& cb = {} ) const { return MR::findSpikeVertices( topology, points, minSumAngle, region, cb ); }
283
288 [[nodiscard]] float dihedralAngleSin( UndirectedEdgeId e ) const { return MR::dihedralAngleSin( topology, points, e ); }
289
294 [[nodiscard]] float dihedralAngleCos( UndirectedEdgeId e ) const { return MR::dihedralAngleCos( topology, points, e ); }
295
301 [[nodiscard]] float dihedralAngle( UndirectedEdgeId e ) const { return MR::dihedralAngle( topology, points, e ); }
302
305 [[nodiscard]] float discreteMeanCurvature( VertId v ) const { return MR::discreteMeanCurvature( topology, points, v ); }
306
309 [[nodiscard]] float discreteMeanCurvature( UndirectedEdgeId e ) const { return MR::discreteMeanCurvature( topology, points, e ); }
310
314 [[nodiscard]] float discreteGaussianCurvature( VertId v, bool * outBoundaryVert = nullptr ) const { return MR::discreteGaussianCurvature( topology, points, v, outBoundaryVert ); }
315
318 [[nodiscard]] VertScalars discreteMeanCurvatures( const VertBitSet * region = nullptr ) const { return MR::discreteMeanCurvatures( topology, points, region ); }
319
322 [[nodiscard]] VertScalars discreteGaussianCurvatures( const VertBitSet * region = nullptr ) const { return MR::discreteGaussianCurvatures( topology, points, region ); }
323
325 [[nodiscard]] UndirectedEdgeBitSet findSharpEdges( float minSharpCos, float maxSharpCos ) const { return MR::findSharpEdges( topology, points, minSharpCos, maxSharpCos ); }
326
328 [[nodiscard]] UndirectedEdgeBitSet findCreaseEdges( float angleFromPlanar ) const { return MR::findCreaseEdges( topology, points, angleFromPlanar ); }
329
332 [[nodiscard]] float leftCotan( EdgeId e ) const { return MR::leftCotan( topology, points, e ); }
333
336 [[nodiscard]] float cotan( UndirectedEdgeId ue ) const { return MR::cotan( topology, points, ue ); }
337
341 [[nodiscard]] MRMESH_API QuadraticForm3f quadraticForm( VertId v, bool angleWeigted,
342 const FaceBitSet * region = nullptr, const UndirectedEdgeBitSet * creases = nullptr ) const;
343
346 [[nodiscard]] MRMESH_API Box3f getBoundingBox() const;
347
350 MR_BIND_OVERLOAD_SUFFIX() [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const AffineXf3f * toWorld = nullptr ) const;
351
354 MR_BIND_OVERLOAD_SUFFIX(region) [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const FaceBitSet* region, const AffineXf3f* toWorld = nullptr ) const;
355
357 [[nodiscard]] float averageEdgeLength() const { return MR::averageEdgeLength( topology, points ); }
358
360 [[nodiscard]] Vector3f findCenterFromPoints() const { return MR::findCenterFromPoints( topology, points ); }
361
363 [[nodiscard]] Vector3f findCenterFromFaces() const { return MR::findCenterFromFaces( topology, points ); }
364
366 [[nodiscard]] Vector3f findCenterFromBBox() const { return MR::findCenterFromBBox( topology, points ); }
367
370
374 MRMESH_API void transform( const AffineXf3f& xf, const VertBitSet* region = nullptr );
375
377 MRMESH_API VertId addPoint( const Vector3f & pos );
378
381 MRMESH_API EdgeId addSeparateEdgeLoop(const std::vector<Vector3f>& contourPoints);
382
385 MRMESH_API EdgeId addSeparateContours( const Contours3f& contours, const AffineXf3f* xf = nullptr );
386
391 MRMESH_API void attachEdgeLoopPart( EdgeId first, EdgeId last, const std::vector<Vector3f>& contourPoints );
392
401 MRMESH_API EdgeId splitEdge( EdgeId e, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
403 EdgeId splitEdge( EdgeId e, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitEdge( e, edgeCenter( e ), region, new2Old ); }
404
408 MRMESH_API VertId splitFace( FaceId f, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
410 VertId splitFace( FaceId f, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitFace( f, triCenter( f ), region, new2Old ); }
411
413 MR_BIND_OVERLOAD_SUFFIX() MRMESH_API void addMesh( const Mesh & from, PartMapping map = {}, bool rearrangeTriangles = false );
414 MR_BIND_OVERLOAD_SUFFIX(outMaps) MRMESH_API void addMesh( const Mesh & from,
416 FaceMap * outFmap, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
417
420 MR_BIND_OVERLOAD_SUFFIX(mapping) MRMESH_API void addMeshPart( const MeshPart & from, const PartMapping & map, VacantElements * vacant = {} );
421
427 MR_BIND_OVERLOAD_SUFFIX() MRMESH_API bool addMeshPart( const MeshPart & from, bool flipOrientation = false,
428 const std::vector<EdgePath> & thisContours = {},
429 const std::vector<EdgePath> & fromContours = {},
431 PartMapping map = {}, VacantElements * vacant = {} );
432
434 MRMESH_API Mesh cloneRegion( const FaceBitSet & region, bool flipOrientation = false, const PartMapping & map = {} ) const;
435
437 MRMESH_API void pack( const PartMapping & map = {}, bool rearrangeTriangles = false );
439 FaceMap * outFmap, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
440
444
448 MRMESH_API PackMapping packOptimally( bool preserveAABBTree = true );
450
453 MRMESH_API void deleteFaces( const FaceBitSet & fs, const UndirectedEdgeBitSet * keepEdges = nullptr );
454
457 MRMESH_API VacantElements deleteFacesFindVacant( const FaceBitSet & fs, const UndirectedEdgeBitSet * keepEdges = nullptr );
458
465 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, PointOnFace& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
466
473 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, MeshProjectionResult& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
474 [[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 ); }
475
482 [[nodiscard]] MRMESH_API MeshProjectionResult projectPoint( const Vector3f& point, float maxDistSq = FLT_MAX, const FaceBitSet * region = nullptr, const AffineXf3f * xf = nullptr ) const;
483 [[nodiscard]] MeshProjectionResult findClosestPoint( const Vector3f& point, float maxDistSq = FLT_MAX, const FaceBitSet * region = nullptr, const AffineXf3f * xf = nullptr ) const { return projectPoint( point, maxDistSq, region, xf ); }
484
487
489 [[nodiscard]] const AABBTree * getAABBTreeNotCreate() const { return AABBTreeOwner_.get(); }
490
493
495 [[nodiscard]] const AABBTreePoints * getAABBTreePointsNotCreate() const { return AABBTreePointsOwner_.get(); }
496
498 MRMESH_API const Dipoles & getDipoles() const;
499
501 [[nodiscard]] const Dipoles * getDipolesNotCreate() const { return dipolesOwner_.get(); }
502
505 MRMESH_API void invalidateCaches( bool pointsChanged = true );
506
511 MRMESH_API void updateCaches( const VertBitSet * changedVerts );
512
519
522 MRMESH_API void flipOrientation( const UndirectedEdgeBitSet * fullComponents = nullptr );
523
525 [[nodiscard]] MRMESH_API size_t heapBytes() const;
526
529
531 MRMESH_API void mirror( const Plane3f& plane );
532
533private:
534 mutable SharedThreadSafeOwner<AABBTree> AABBTreeOwner_;
535 mutable SharedThreadSafeOwner<AABBTreePoints> AABBTreePointsOwner_;
536 mutable SharedThreadSafeOwner<Dipoles> dipolesOwner_;
537};
538
539}
constexpr bool operator==(ImVec2 a, ImVec2 b)
Definition MRImGuiVectorOperators.h:117
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRAABBTreePoints.h:21
Definition MRAABBTree.h:41
Definition MRMeshTopology.h:31
Definition MRSharedThreadSafeOwner.h:19
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:790
float discreteGaussianCurvature(const MeshTopology &topology, const VertCoords &points, VertId v, bool *outBoundaryVert=nullptr)
Definition MRMeshMath.h:301
Vector3d dirArea(const MeshTopology &topology, const VertCoords &points, const FaceBitSet &fs)
float area(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns the area of given face
Definition MRMeshMath.h:168
double volume(const MeshTopology &topology, const VertCoords &points, const FaceBitSet *region=nullptr)
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...
double holePerimeter(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...
VertId getClosestVertex(const MeshTopology &topology, const VertCoords &points, const PointOnFace &p)
returns one of three face vertices, closest to given point
Vector3f leftDirDblArea(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes directed double area of left triangular face of given edge
Vector3f findCenterFromFaces(const MeshTopology &topology, const VertCoords &points)
computes center of mass considering that density of all triangles is the same
VertScalars discreteGaussianCurvatures(const MeshTopology &topology, const VertCoords &points, const VertBitSet *region=nullptr)
float dihedralAngleSin(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
Vector3f edgeVector(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns vector equal to edge destination point minus edge origin point
Definition MRMeshMath.h:27
MeshTriPoint
Definition MRMeshFwd.h:515
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
Contours3< float > Contours3f
Definition MRMeshFwd.h:388
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:72
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...
Vector3d holeDirArea(const MeshTopology &topology, const VertCoords &points, EdgeId e)
Vector3f destPnt(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns coordinates of the edge destination
Definition MRMeshMath.h:21
Vector3f dirDblArea(const MeshTopology &topology, const VertCoords &points, FaceId f)
computes directed double area for a triangular face from its vertices
Definition MRMeshMath.h:153
float dihedralAngleCos(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
UndirectedEdgeBitSet findSharpEdges(const MeshTopology &topology, const VertCoords &points, float minSharpCos, float maxSharpCos)
finds all mesh edges with the cosine of dihedral angle (see dihedralAngleCos) in [minSharpCos,...
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
Plane3f
Definition MRMeshFwd.h:391
tl::expected< T, E > Expected
Definition MRExpected.h:31
Vector3f findCenterFromPoints(const MeshTopology &topology, const VertCoords &points)
computes average position of all valid mesh vertices
Vector3f triPoint(const MeshTopology &topology, const VertCoords &points, const MeshTriPoint &p)
computes coordinates of point given as face and barycentric representation
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
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:144
Vector3f findCenterFromBBox(const MeshTopology &topology, const VertCoords &points)
computes bounding box and returns its center
EdgePoint MeshEdgePoint
Definition MRMeshFwd.h:486
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMeshFwd.h:635
UndirectedEdgeScalars edgeLengths(const MeshTopology &topology, const VertCoords &points)
computes and returns the lengths of all edges in the mesh
Vector3f triCenter(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns the centroid of given triangle
float circumcircleDiameter(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns circumcircle diameter of given mesh triangle
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,...
std::vector< EdgeId > EdgePath
Definition MRMeshFwd.h:155
Vector3f orgPnt(const MeshTopology &topology, const VertCoords &points, EdgeId e)
returns coordinates of the edge origin
Definition MRMeshMath.h:15
std::function< bool(VertId e0, VertId e1, VertId vRef, VertId vCand, VertId vBest)> BetterDupContinuation
Definition MRVertDuplication.h:47
Vector3f edgeCenter(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
computes the center of given edge
Definition MRMeshMath.h:48
float discreteMeanCurvature(const MeshTopology &topology, const VertCoords &points, VertId v)
float dblArea(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns twice the area of given face
Definition MRMeshMath.h:162
MeshEdgePoint toEdgePoint(const MeshTopology &topology, const VertCoords &points, EdgeId e, const Vector3f &p)
converts edge and 3d point into edge-point representation
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 )
Triangle3< float > Triangle3f
Definition MRMeshFwd.h:466
float edgeLength(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
returns Euclidean length of the edge
Definition MRMeshMath.h:135
float leftCotan(const MeshTopology &topology, const VertCoords &points, EdgeId e)
UndirectedEdgeId getClosestEdge(const MeshTopology &topology, const VertCoords &points, const PointOnFace &p)
returns one of three face edges, closest to given point
VertScalars discreteMeanCurvatures(const MeshTopology &topology, const VertCoords &points, const VertBitSet *region=nullptr)
float circumcircleDiameterSq(const MeshTopology &topology, const VertCoords &points, FaceId f)
returns squared circumcircle diameter of given mesh triangle
Vector3f pseudonormal(const MeshTopology &topology, const VertCoords &points, VertId v, const FaceBitSet *region=nullptr)
double projArea(const MeshTopology &topology, const VertCoords &points, const Vector3f &dir, const FaceBitSet &fs)
float cotan(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId ue)
Definition MRMeshMath.h:326
float averageEdgeLength(const MeshTopology &topology, const VertCoords &points)
computes average length of an edge in the mesh given by (topology, points)
Vector3f leftNormal(const MeshTopology &topology, const VertCoords &points, EdgeId e)
computes triangular face normal from its vertices
Definition MRMeshMath.h:218
float dihedralAngle(const MeshTopology &topology, const VertCoords &points, UndirectedEdgeId e)
MeshTriPoint toTriPoint(const MeshTopology &topology, const VertCoords &points, FaceId f, const Vector3f &p)
converts face id and 3d point into barycentric representation
@ normal
Definition MRUnits.h:45
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRFaceSoup.h:16
Definition MRMeshBuilderTypes.h:33
Definition MRMeshProject.h:18
Definition MRMesh.h:24
bool projectPoint(const Vector3f &point, PointOnFace &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=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.h:187
Vector3f pseudonormal(VertId v, const FaceBitSet *region=nullptr) const
Definition MRMesh.h:235
float area(FaceId f) const
returns the area of given face
Definition MRMesh.h:173
EdgeId splitEdge(EdgeId e, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
PackMapping packOptimally(bool preserveAABBTree=true)
VertId addPoint(const Vector3f &pos)
creates new point and assigns given position to it
EdgeId addSeparateEdgeLoop(const std::vector< Vector3f > &contourPoints)
float discreteMeanCurvature(VertId v) const
Definition MRMesh.h:305
VertId getClosestVertex(const MeshTriPoint &p) const
returns one of three face vertices, closest to given point
Definition MRMesh.h:146
float circumcircleDiameterSq(FaceId f) const
returns squared circumcircle diameter of given mesh triangle
Definition MRMesh.h:122
void updateCachesAfterSplits(const FaceHashMap &new2Old)
float dihedralAngleCos(UndirectedEdgeId e) const
Definition MRMesh.h:294
void shrinkToFit()
requests the removal of unused capacity
Vector3f normal(const MeshTriPoint &p) const
Definition MRMesh.h:231
Vector3d dirArea(const FaceBitSet &fs) const
Definition MRMesh.h:184
float signedDistance(const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
float discreteGaussianCurvature(VertId v, bool *outBoundaryVert=nullptr) const
Definition MRMesh.h:314
Vector3f edgeVector(EdgeId e) const
returns vector equal to edge destination point minus edge origin point
Definition MRMesh.h:78
void pack(const PartMapping &map={}, bool rearrangeTriangles=false)
tightly packs all arrays eliminating lone edges and invalid faces, vertices and points
void attachEdgeLoopPart(EdgeId first, EdgeId last, const std::vector< Vector3f > &contourPoints)
static Mesh fromTriMeshDuplicatingNonManifoldVertices(TriMesh &&triMesh, std::vector< MeshBuilder::VertDuplication > *dups=nullptr, const MeshBuilder::BuildSettings &settings={}, const MeshBuilder::BetterDupContinuation &betterCont={})
double holePerimeter(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.h:201
float dblArea(FaceId f) const
returns twice the area of given face
Definition MRMesh.h:170
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.h:328
MeshTriPoint toTriPoint(VertId v) const
converts vertex into barycentric representation
const Dipoles & getDipoles() const
returns cached dipoles of aabb-tree nodes for this mesh, creating it if it did not exist in a thread-...
VertId getClosestVertex(const PointOnFace &p) const
returns one of three face vertices, closest to given point
Definition MRMesh.h:143
UndirectedEdgeBitSet findSharpEdges(float minSharpCos, float maxSharpCos) const
finds all mesh edges with the cosine of dihedral angle (see dihedralAngleCos) in [minSharpCos,...
Definition MRMesh.h:325
const AABBTree * getAABBTreeNotCreate() const
returns cached aabb-tree of this mesh's triangles, but does not create it if it did not exist
Definition MRMesh.h:489
Expected< void > pack(const PackMapping &map, ProgressCallback cb={})
Box3f computeBoundingBox(const FaceBitSet *region, const AffineXf3f *toWorld=nullptr) const
void addMeshPart(const MeshPart &from, const PartMapping &map, VacantElements *vacant={})
double area(const FaceBitSet *fs=nullptr) const
computes the area of given face-region (or whole mesh)
Definition MRMesh.h:180
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.h:279
void invalidateCaches(bool pointsChanged=true)
void addMesh(const Mesh &from, PartMapping map={}, bool rearrangeTriangles=false)
appends another mesh as separate connected component(s) to this
VacantElements deleteFacesFindVacant(const FaceBitSet &fs, const UndirectedEdgeBitSet *keepEdges=nullptr)
double area(const FaceBitSet &fs) const
Definition MRMesh.h:177
float edgeLengthSq(UndirectedEdgeId e) const
returns squared Euclidean length of the edge (faster to compute than length)
Definition MRMesh.h:161
float discreteMeanCurvature(UndirectedEdgeId e) const
Definition MRMesh.h:309
void updateCaches(const VertBitSet *changedVerts)
Triangle3f getTriPoints(FaceId f) const
returns three points of given face
Definition MRMesh.h:110
EdgeId splitEdge(EdgeId e, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
same, but split given edge on two equal parts
Definition MRMesh.h:403
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.h:84
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.h:93
Vector3d holeDirArea(EdgeId e) const
Definition MRMesh.h:205
MeshProjectionResult findClosestPoint(const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Definition MRMesh.h:483
Vector3f orgPnt(EdgeId e) const
returns coordinates of the edge origin
Definition MRMesh.h:72
UndirectedEdgeScalars edgeLengths() const
computes and returns the lengths of all edges in the mesh
Definition MRMesh.h:158
Vector3f destPnt(EdgeId e) const
returns coordinates of the edge destination
Definition MRMesh.h:75
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.h:119
bool isOutsideByProjNorm(const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
void flipOrientation(const UndirectedEdgeBitSet *fullComponents=nullptr)
float dihedralAngleSin(UndirectedEdgeId e) const
Definition MRMesh.h:288
bool findClosestPoint(const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Definition MRMesh.h:474
void mirror(const Plane3f &plane)
reflects the mesh from a given plane
float signedDistance(const Vector3f &pt) const
void pack(FaceMap *outFmap, 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.h:100
MeshTriPoint toTriPoint(FaceId f, const Vector3f &p) const
converts face id and 3d point into barycentric representation
Definition MRMesh.h:131
std::optional< float > signedDistance(const Vector3f &pt, float maxDistSq, const FaceBitSet *region=nullptr) const
MeshEdgePoint toEdgePoint(VertId v) const
converts vertex into edge-point representation
float leftCotan(EdgeId e) const
Definition MRMesh.h:332
Plane3f getPlane3f(FaceId f) const
returns the plane containing given triangular face with normal looking outwards
Vector3f leftNormal(EdgeId e) const
computes triangular face normal from its vertices
Definition MRMesh.h:211
bool isOutside(const Vector3f &pt, float windingNumberThreshold=0.5f, float beta=2) const
Definition MRMesh.h:271
LineSegm3f edgeSegment(EdgeId e) const
returns line segment of given edge
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.h:208
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.h:495
VertId splitFace(FaceId f, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
same, putting new vertex in the centroid of original triangle
Definition MRMesh.h:410
Box3f computeBoundingBox(const AffineXf3f *toWorld=nullptr) const
MeshTopology topology
Definition MRMesh.h:25
UndirectedEdgeId getClosestEdge(const MeshTriPoint &p) const
returns one of three face edges, closest to given point
Definition MRMesh.h:152
void transform(const AffineXf3f &xf, const VertBitSet *region=nullptr)
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Plane3d getPlane3d(FaceId f) const
Vector3f findCenterFromFaces() const
computes center of mass considering that density of all triangles is the same
Definition MRMesh.h:363
Vector3f triCenter(FaceId f) const
returns the centroid of given triangle
Definition MRMesh.h:116
Vector3f triPoint(const MeshTriPoint &p) const
computes coordinates of point given as face and barycentric representation
Definition MRMesh.h:113
VertCoords points
Definition MRMesh.h:26
VertId splitFace(FaceId f, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
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.h:501
QuadraticForm3f quadraticForm(VertId v, bool angleWeigted, const FaceBitSet *region=nullptr, const UndirectedEdgeBitSet *creases=nullptr) const
Vector3f findCenterFromPoints() const
computes average position of all valid mesh vertices
Definition MRMesh.h:360
float calcFastWindingNumber(const Vector3f &pt, float beta=2) const
Box3f getBoundingBox() const
float cotan(UndirectedEdgeId ue) const
Definition MRMesh.h:336
void zeroUnusedPoints()
for all points not in topology.getValidVerts() sets coordinates to (0,0,0)
float dblArea(VertId v) const
computes the length of summed directed double areas of all triangles around given vertex
Definition MRMesh.h:224
float dihedralAngle(UndirectedEdgeId e) const
Definition MRMesh.h:301
float averageEdgeLength() const
computes average length of an edge in this mesh
Definition MRMesh.h:357
Vector3f leftDirDblArea(EdgeId e) const
computes directed double area of left triangular face of given edge
Definition MRMesh.h:164
Vector3f edgePoint(const MeshEdgePoint &ep) const
computes coordinates of point given as edge and relative position on it
Definition MRMesh.h:87
Expected< PackMapping > packOptimally(bool preserveAABBTree, ProgressCallback cb)
void getTriPoints(FaceId f, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
returns three points of given face
Definition MRMesh.h:103
void getTriPoints(FaceId f, Vector3f(&v)[3]) const
Definition MRMesh.h:107
void addMesh(const Mesh &from, FaceMap *outFmap, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
MeshProjectionResult projectPoint(const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
EdgeId addSeparateContours(const Contours3f &contours, const AffineXf3f *xf=nullptr)
static Mesh fromPointTriples(const std::vector< Triangle3f > &posTriples, bool duplicateNonManifoldVertices)
Vector3f findCenterFromBBox() const
computes bounding box and returns its center
Definition MRMesh.h:366
Vector3f pseudonormal(const MeshTriPoint &p, const FaceBitSet *region=nullptr) const
Definition MRMesh.h:244
Mesh cloneRegion(const FaceBitSet &region, bool flipOrientation=false, const PartMapping &map={}) const
creates new mesh from given triangles of this mesh
bool projectPoint(const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
Vector3f normal(FaceId f) const
computes triangular face normal from its vertices
Definition MRMesh.h:214
static Mesh fromFaceSoup(FaceSoup &&soup, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
float circumcircleDiameter(FaceId f) const
returns circumcircle diameter of given mesh triangle
Definition MRMesh.h:125
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.h:238
const AABBTree & getAABBTree() const
returns cached aabb-tree of this mesh's triangles, creating it if it did not exist in a thread-safe m...
Vector3f edgeCenter(UndirectedEdgeId e) const
computes the center of given edge
Definition MRMesh.h:90
float edgeLength(UndirectedEdgeId e) const
returns Euclidean length of the edge
Definition MRMesh.h:155
void deleteFaces(const FaceBitSet &fs, const UndirectedEdgeBitSet *keepEdges=nullptr)
MeshEdgePoint toEdgePoint(EdgeId e, const Vector3f &p) const
converts edge and 3d point into edge-point representation
Definition MRMesh.h:140
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...
VertScalars discreteGaussianCurvatures(const VertBitSet *region=nullptr) const
Definition MRMesh.h:322
Vector3f dirDblArea(VertId v) const
computes sum of directed double areas of all triangles around given vertex
Definition MRMesh.h:221
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.h:282
double volume(const FaceBitSet *region=nullptr) const
Definition MRMesh.h:198
static 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
void getLeftTriPoints(EdgeId e, Vector3f(&v)[3]) const
Definition MRMesh.h:97
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.h:194
UndirectedEdgeId getClosestEdge(const PointOnFace &p) const
returns one of three face edges, closest to given point
Definition MRMesh.h:149
MeshTriPoint toTriPoint(const PointOnFace &p) const
converts face id and 3d point into barycentric representation
Definition MRMesh.h:134
static Mesh fromTrianglesDuplicatingNonManifoldVertices(VertCoords vertexCoordinates, Triangulation &t, std::vector< MeshBuilder::VertDuplication > *dups=nullptr, const MeshBuilder::BuildSettings &settings={}, const MeshBuilder::BetterDupContinuation &betterCont={})
double projArea(const Vector3f &dir, const FaceBitSet &fs) const
Definition MRMesh.h:191
static Mesh fromTriMesh(TriMesh &&triMesh, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
construct mesh from TriMesh representation
Vector3f dirDblArea(FaceId f) const
computes directed double area for a triangular face from its vertices
Definition MRMesh.h:167
VertScalars discreteMeanCurvatures(const VertBitSet *region=nullptr) const
Definition MRMesh.h:318
Vector3f normal(VertId v) const
computes normal in a vertex using sum of directed areas of neighboring triangles
Definition MRMesh.h:227
Definition MRBuffer.h:156
mapping among elements of source mesh, from which a part is taken, and target mesh
Definition MRPartMapping.h:13
a point located on some mesh's face
Definition MRPointOnFace.h:16
Definition MRTriMesh.h:16
Definition MRMeshTopology.h:22