MeshLib
 
Loading...
Searching...
No Matches
MRMesh/MRMesh.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRMeshTopology.h"
5#include "MRMeshProject.h"
6#include "MREdgePoint.h"
7#include "MRLineSegm.h"
9#include "MRWriter.h"
10#include "MRConstants.h"
11#include "MRProgressCallback.h"
12#include <cfloat>
13
14namespace MR
15{
16
18
22struct [[nodiscard]] Mesh
23{
26
28 [[nodiscard]] MRMESH_API static Mesh fromTriangles(
29 VertCoords vertexCoordinates,
30 const Triangulation& t, const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
31
33 [[nodiscard]] MRMESH_API static Mesh fromTriMesh(
34 TriMesh && triMesh,
35 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
36
40 VertCoords vertexCoordinates,
41 Triangulation & t,
42 std::vector<MeshBuilder::VertDuplication> * dups = nullptr,
43 const MeshBuilder::BuildSettings & settings = {} );
44
48 [[nodiscard]] MRMESH_API static Mesh fromFaceSoup(
49 VertCoords vertexCoordinates,
50 const std::vector<VertId> & verts, const Vector<MeshBuilder::VertSpan, FaceId> & faces,
51 const MeshBuilder::BuildSettings& settings = {}, ProgressCallback cb = {} );
52
56 [[nodiscard]] MRMESH_API static Mesh fromPointTriples( const std::vector<Triangle3f> & posTriples, bool duplicateNonManifoldVertices );
57
59 [[nodiscard]] MRMESH_API bool operator ==( const Mesh & b ) const;
60
62 [[nodiscard]] Vector3f orgPnt( EdgeId e ) const { return points[ topology.org( e ) ]; }
63
65 [[nodiscard]] Vector3f destPnt( EdgeId e ) const { return points[ topology.dest( e ) ]; }
66
68 [[nodiscard]] Vector3f edgeVector( EdgeId e ) const { return destPnt( e ) - orgPnt( e ); }
69
71 [[nodiscard]] LineSegm3f edgeSegment( EdgeId e ) const { return { orgPnt( e ), destPnt( e ) }; }
72
74 [[nodiscard]] Vector3f edgePoint( EdgeId e, float f ) const { return f * destPnt( e ) + ( 1 - f ) * orgPnt( e ); }
75
77 [[nodiscard]] Vector3f edgePoint( const MeshEdgePoint & ep ) const { return edgePoint( ep.e, ep.a ); }
78
80 [[nodiscard]] Vector3f edgeCenter( UndirectedEdgeId e ) const { return edgePoint( e, 0.5f ); }
81
83 MRMESH_API void getLeftTriPoints( EdgeId e, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const;
84
86 void getLeftTriPoints( EdgeId e, Vector3f (&v)[3] ) const { getLeftTriPoints( e, v[0], v[1], v[2] ); }
87
89 [[nodiscard]] Triangle3f getLeftTriPoints( EdgeId e ) const { Triangle3f res; getLeftTriPoints( e, res[0], res[1], res[2] ); return res; }
90
92 void getTriPoints( FaceId f, Vector3f & v0, Vector3f & v1, Vector3f & v2 ) const { getLeftTriPoints( topology.edgeWithLeft( f ), v0, v1, v2 ); }
93
95 void getTriPoints( FaceId f, Vector3f (&v)[3] ) const { getTriPoints( f, v[0], v[1], v[2] ); }
96
98 [[nodiscard]] Triangle3f getTriPoints( FaceId f ) const { Triangle3f res; getTriPoints( f, res[0], res[1], res[2] ); return res; }
99
101 [[nodiscard]] MRMESH_API Vector3f triPoint( const MeshTriPoint & p ) const;
102
104 [[nodiscard]] MRMESH_API Vector3f triCenter( FaceId f ) const;
105
107 [[nodiscard]] MRMESH_API float triangleAspectRatio( FaceId f ) const;
108
110 [[nodiscard]] MRMESH_API float circumcircleDiameterSq( FaceId f ) const;
111
113 [[nodiscard]] MRMESH_API float circumcircleDiameter( FaceId f ) const;
114
116 [[nodiscard]] MRMESH_API MeshTriPoint toTriPoint( VertId v ) const;
117
119 [[nodiscard]] MRMESH_API MeshTriPoint toTriPoint( FaceId f, const Vector3f & p ) const;
120
122 [[nodiscard]] MRMESH_API MeshTriPoint toTriPoint( const PointOnFace& p ) const;
123
125 [[nodiscard]] MRMESH_API MeshEdgePoint toEdgePoint( VertId v ) const;
126
128 [[nodiscard]] MRMESH_API MeshEdgePoint toEdgePoint( EdgeId e, const Vector3f & p ) const;
129
131 [[nodiscard]] MRMESH_API VertId getClosestVertex( const PointOnFace & p ) const;
132
134 [[nodiscard]] VertId getClosestVertex( const MeshTriPoint & p ) const { return getClosestVertex( PointOnFace{ topology.left( p.e ), triPoint( p ) } ); }
135
137 [[nodiscard]] MRMESH_API UndirectedEdgeId getClosestEdge( const PointOnFace & p ) const;
138
140 [[nodiscard]] UndirectedEdgeId getClosestEdge( const MeshTriPoint & p ) const { return getClosestEdge( PointOnFace{ topology.left( p.e ), triPoint( p ) } ); }
141
143 [[nodiscard]] float edgeLength( UndirectedEdgeId e ) const { return edgeVector( e ).length(); }
144
146 [[nodiscard]] float edgeLengthSq( UndirectedEdgeId e ) const { return edgeVector( e ).lengthSq(); }
147
149 [[nodiscard]] MRMESH_API Vector3f leftDirDblArea( EdgeId e ) const;
150
152 [[nodiscard]] Vector3f dirDblArea( FaceId f ) const { return leftDirDblArea( topology.edgeWithLeft( f ) ); }
153
155 [[nodiscard]] float dblArea( FaceId f ) const { return dirDblArea( f ).length(); }
156
158 [[nodiscard]] float area( FaceId f ) const { return 0.5f * dblArea( f ); }
159
161 [[nodiscard]] MRMESH_API double area( const FaceBitSet & fs ) const;
162
164 [[nodiscard]] double area( const FaceBitSet * fs = nullptr ) const { return area( topology.getFaceIds( fs ) ); }
165
167 [[nodiscard]] MRMESH_API Vector3d dirArea( const FaceBitSet & fs ) const;
168
170 [[nodiscard]] Vector3d dirArea( const FaceBitSet * fs = nullptr ) const { return dirArea( topology.getFaceIds( fs ) ); }
171
173 [[nodiscard]] MRMESH_API double projArea( const Vector3f & dir, const FaceBitSet & fs ) const;
174
176 [[nodiscard]] double projArea( const Vector3f & dir, const FaceBitSet * fs = nullptr ) const { return projArea( dir, topology.getFaceIds( fs ) ); }
177
180 [[nodiscard]] MRMESH_API double volume( const FaceBitSet* region = nullptr ) const;
181
183 [[nodiscard]] MRMESH_API double holePerimiter( EdgeId e ) const;
184
187 [[nodiscard]] MRMESH_API Vector3d holeDirArea( EdgeId e ) const;
188
190 [[nodiscard]] Vector3f leftNormal( EdgeId e ) const { return leftDirDblArea( e ).normalized(); }
191
193 [[nodiscard]] Vector3f normal( FaceId f ) const { return dirDblArea( f ).normalized(); }
194
196 [[nodiscard]] MRMESH_API Vector3f dirDblArea( VertId v ) const;
197
199 [[nodiscard]] float dblArea( VertId v ) const { return dirDblArea( v ).length(); }
200
202 [[nodiscard]] Vector3f normal( VertId v ) const { return dirDblArea( v ).normalized(); }
203
206 [[nodiscard]] MRMESH_API Vector3f normal( const MeshTriPoint & p ) const;
207
210 [[nodiscard]] MRMESH_API Vector3f pseudonormal( VertId v, const FaceBitSet * region = nullptr ) const;
211
213 [[nodiscard]] MRMESH_API Vector3f pseudonormal( UndirectedEdgeId e, const FaceBitSet * region = nullptr ) const;
214
218 [[nodiscard]] MRMESH_API Vector3f pseudonormal( const MeshTriPoint & p, const FaceBitSet * region = nullptr ) const;
219
223 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
224 [[deprecated]] MRMESH_API float signedDistance( const Vector3f & pt, const MeshTriPoint & proj, const FaceBitSet * region = nullptr ) const;
225
229 [[nodiscard]] MRMESH_API float signedDistance( const Vector3f & pt ) const;
230
235 [[nodiscard]] MRMESH_API std::optional<float> signedDistance( const Vector3f & pt, float maxDistSq, const FaceBitSet * region = nullptr ) const;
236
242 [[nodiscard]] MRMESH_API float calcFastWindingNumber( const Vector3f & pt, float beta = 2 ) const;
243
246 [[nodiscard]] bool isOutside( const Vector3f & pt, float windingNumberThreshold = 0.5f, float beta = 2 ) const { return calcFastWindingNumber( pt, beta ) <= windingNumberThreshold; }
247
251 [[nodiscard]] MRMESH_API bool isOutsideByProjNorm( const Vector3f & pt, const MeshProjectionResult & proj, const FaceBitSet * region = nullptr ) const;
252
254 [[nodiscard]] MRMESH_API float sumAngles( VertId v, bool * outBoundaryVert = nullptr ) const;
255
257 [[nodiscard]] MRMESH_API Expected<VertBitSet> findSpikeVertices( float minSumAngle, const VertBitSet* region = nullptr, ProgressCallback cb = {} ) const;
258
263 [[nodiscard]] MRMESH_API float dihedralAngleSin( UndirectedEdgeId e ) const;
264
269 [[nodiscard]] MRMESH_API float dihedralAngleCos( UndirectedEdgeId e ) const;
270
276 [[nodiscard]] MRMESH_API float dihedralAngle( UndirectedEdgeId e ) const;
277
280 [[nodiscard]] MRMESH_API float discreteMeanCurvature( VertId v ) const;
281
284 [[nodiscard]] MRMESH_API float discreteMeanCurvature( UndirectedEdgeId e ) const;
285
289 [[nodiscard]] float discreteGaussianCurvature( VertId v, bool * outBoundaryVert = nullptr ) const { return 2 * PI_F - sumAngles( v, outBoundaryVert ); }
290
292 [[nodiscard]] MRMESH_API UndirectedEdgeBitSet findCreaseEdges( float angleFromPlanar ) const;
293
296 [[nodiscard]] MRMESH_API float leftCotan( EdgeId e ) const;
297
300 [[nodiscard]] float cotan( UndirectedEdgeId ue ) const { EdgeId e{ ue }; return leftCotan( e ) + leftCotan( e.sym() ); }
301
305 [[nodiscard]] MRMESH_API QuadraticForm3f quadraticForm( VertId v, const FaceBitSet * region = nullptr, const UndirectedEdgeBitSet * creases = nullptr ) const;
306
309 [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const AffineXf3f * toWorld = nullptr ) const;
310
313 [[nodiscard]] MRMESH_API Box3f getBoundingBox() const;
314
317 [[nodiscard]] MRMESH_API Box3f computeBoundingBox( const FaceBitSet* region, const AffineXf3f* toWorld = nullptr ) const;
318
320 [[nodiscard]] MRMESH_API float averageEdgeLength() const;
321
324
327
330
333
336 MRMESH_API void transform( const AffineXf3f& xf, const VertBitSet* region = nullptr );
337
340
343 MRMESH_API EdgeId addSeparateEdgeLoop(const std::vector<Vector3f>& contourPoints);
344
347 MRMESH_API EdgeId addSeparateContours( const Contours3f& contours, const AffineXf3f* xf = nullptr );
348
353 MRMESH_API void attachEdgeLoopPart( EdgeId first, EdgeId last, const std::vector<Vector3f>& contourPoints );
354
362 MRMESH_API EdgeId splitEdge( EdgeId e, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
363 // same, but split given edge on two equal parts
364 EdgeId splitEdge( EdgeId e, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitEdge( e, edgeCenter( e ), region, new2Old ); }
365
369 MRMESH_API VertId splitFace( FaceId f, const Vector3f & newVertPos, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr );
370 // same, putting new vertex in the centroid of original triangle
371 VertId splitFace( FaceId f, FaceBitSet * region = nullptr, FaceHashMap * new2Old = nullptr ) { return splitFace( f, triCenter( f ), region, new2Old ); }
372
374 MRMESH_API void addPart( const Mesh & from,
375 // optionally returns mappings: from.id -> this.id
376 FaceMap * outFmap = nullptr, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
377
379 MRMESH_API void addPartByMask( const Mesh & from, const FaceBitSet & fromFaces, const PartMapping & map );
380
383 MRMESH_API void addPartByMask( const Mesh & from, const FaceBitSet & fromFaces, bool flipOrientation = false,
384 const std::vector<EdgePath> & thisContours = {}, // contours on this mesh that have to be stitched with
385 const std::vector<EdgePath> & fromContours = {}, // contours on from mesh during addition
386 // optionally returns mappings: from.id -> this.id
387 const PartMapping & map = {} );
388
390 MRMESH_API void addPartByFaceMap( const Mesh & from, const FaceMap & fromFaces, bool flipOrientation = false,
391 const std::vector<EdgePath> & thisContours = {}, // contours on this mesh that have to be stitched with
392 const std::vector<EdgePath> & fromContours = {}, // contours on from mesh during addition
393 // optionally returns mappings: from.id -> this.id
394
395 const PartMapping & map = {} );
397 template<typename I>
398 MRMESH_API void addPartBy( const Mesh & from, I fbegin, I fend, size_t fcount, bool flipOrientation = false,
399 const std::vector<EdgePath> & thisContours = {},
400 const std::vector<EdgePath> & fromContours = {},
401 PartMapping map = {} );
402
404 MRMESH_API Mesh cloneRegion( const FaceBitSet & region, bool flipOrientation = false, const PartMapping & map = {} ) const;
405
408 MRMESH_API void pack( FaceMap * outFmap = nullptr, VertMap * outVmap = nullptr, WholeEdgeMap * outEmap = nullptr, bool rearrangeTriangles = false );
409
412 MRMESH_API PackMapping packOptimally( bool preserveAABBTree = true );
413
415 MRMESH_API void deleteFaces( const FaceBitSet & fs, const UndirectedEdgeBitSet * keepEdges = nullptr );
416
419 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, PointOnFace& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
420
423 [[nodiscard]] MRMESH_API bool projectPoint( const Vector3f& point, MeshProjectionResult& res, float maxDistSq = FLT_MAX, const FaceBitSet* region = nullptr, const AffineXf3f * xf = nullptr ) const;
424
426 [[nodiscard]] MRMESH_API std::optional<MeshProjectionResult> projectPoint( const Vector3f& point, float maxDistSq = FLT_MAX, const FaceBitSet * region = nullptr, const AffineXf3f * xf = nullptr ) const;
427
430
432 [[nodiscard]] const AABBTree * getAABBTreeNotCreate() const { return AABBTreeOwner_.get(); }
433
436
438 [[nodiscard]] const AABBTreePoints * getAABBTreePointsNotCreate() const { return AABBTreePointsOwner_.get(); }
439
441 MRMESH_API const Dipoles & getDipoles() const;
442
444 [[nodiscard]] const Dipoles * getDipolesNotCreate() const { return dipolesOwner_.get(); }
445
448 MRMESH_API void invalidateCaches( bool pointsChanged = true );
449
453 MRMESH_API void updateCaches( const VertBitSet & changedVerts );
454
455 // returns the amount of memory this object occupies on heap
456 [[nodiscard]] MRMESH_API size_t heapBytes() const;
457
460
462 MRMESH_API void mirror( const Plane3f& plane );
463
464private:
465 mutable UniqueThreadSafeOwner<AABBTree> AABBTreeOwner_;
466 mutable UniqueThreadSafeOwner<AABBTreePoints> AABBTreePointsOwner_;
467 mutable UniqueThreadSafeOwner<Dipoles> dipolesOwner_;
468};
469
470} //namespace MR
List< Vector3f^> VertCoords
Definition MRDotNet/MRMeshFwd.h:95
int VertId
Definition MRDotNet/MRMeshFwd.h:51
List< VertId > VertMap
Definition MRDotNet/MRMeshFwd.h:84
int FaceId
Definition MRDotNet/MRMeshFwd.h:53
int EdgeId
Definition MRDotNet/MRMeshFwd.h:52
List< FaceId > FaceMap
Definition MRDotNet/MRMeshFwd.h:87
constexpr bool operator==(ImVec2 a, ImVec2 b)
Definition MRImGuiVectorOperators.h:117
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
bounding volume hierarchy for point cloud structure
Definition MRAABBTreePoints.h:16
Definition MRAABBTree.h:16
Definition MRMesh/MRMeshTopology.h:18
FaceId left(EdgeId he) const
returns left face of half-edge
Definition MRMesh/MRMeshTopology.h:83
VertId dest(EdgeId he) const
returns destination vertex of half-edge
Definition MRMesh/MRMeshTopology.h:80
VertId org(EdgeId he) const
returns origin vertex of half-edge
Definition MRMesh/MRMeshTopology.h:77
EdgeId edgeWithLeft(FaceId a) const
returns valid edge if given vertex is present in the mesh
Definition MRMesh/MRMeshTopology.h:208
const FaceBitSet & getFaceIds(const FaceBitSet *region) const
if region pointer is not null then converts it in reference, otherwise returns all valid faces in the...
Definition MRMesh/MRMeshTopology.h:262
Definition MRUniqueThreadSafeOwner.h:20
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:589
Definition MRCameraOrientationPlugin.h:7
tl::expected< T, E > Expected
Definition MRExpected.h:49
T dblArea(const Vector3< T > &p, const Vector3< T > &q, const Vector3< T > &r)
computes twice the area of given triangle
Definition MRTriMath.h:153
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:454
MRMESH_API float calcFastWindingNumber(const Dipoles &dipoles, const AABBTree &tree, const Mesh &mesh, const Vector3f &q, float beta, FaceId skipFace)
Vector3< T > dirDblArea(const Triangle3< T > &t)
computes directed double area of given triangle
Definition MRTriMath.h:125
Triangle3< float > Triangle3f
Definition MRMesh/MRMeshFwd.h:327
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:284
Definition Triangulation.dox.py:1
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:11
SegmPointf a
a in [0,1], a=0 => point is in org( e ), a=1 => point is in dest( e )
Definition MREdgePoint.h:13
EdgeId e
Definition MREdgePoint.h:12
Definition MRMeshBuilderTypes.h:30
Definition MRMeshProject.h:18
Definition MRMesh/MRMeshTriPoint.h:23
EdgeId e
Definition MRMesh/MRMeshTriPoint.h:24
Definition MRMesh/MRMesh.h:23
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:170
float area(FaceId f) const
returns the area of given face
Definition MRMesh/MRMesh.h:158
MRMESH_API float dihedralAngleSin(UndirectedEdgeId e) const
VertId getClosestVertex(const MeshTriPoint &p) const
returns one of three face vertices, closest to given point
Definition MRMesh/MRMesh.h:134
MRMESH_API Box3f computeBoundingBox(const FaceBitSet *region, const AffineXf3f *toWorld=nullptr) const
MRMESH_API Vector3f normal(const MeshTriPoint &p) const
MRMESH_API double area(const FaceBitSet &fs) const
computes the area of given face-region
MRMESH_API float calcFastWindingNumber(const Vector3f &pt, float beta=2) const
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
MRMESH_API Vector3f findCenterFromFaces() const
computes center of mass considering that density of all triangles is the same
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:289
Vector3f edgeVector(EdgeId e) const
returns vector equal to edge destination point minus edge origin point
Definition MRMesh/MRMesh.h:68
MRMESH_API std::optional< MeshProjectionResult > projectPoint(const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
this version returns optional without value instead of false
MRMESH_API UndirectedEdgeId getClosestEdge(const PointOnFace &p) const
returns one of three face edges, closest to given point
MRMESH_API Vector3d dirArea(const FaceBitSet &fs) const
computes the sum of directed areas for faces from given region
float dblArea(FaceId f) const
returns twice the area of given face
Definition MRMesh/MRMesh.h:155
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 Vector3f triPoint(const MeshTriPoint &p) const
computes coordinates of point given as face and barycentric representation
MRMESH_API MeshTriPoint toTriPoint(VertId v) const
converts vertex into barycentric representation
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
MRMESH_API 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...
MRMESH_API UndirectedEdgeBitSet findCreaseEdges(float angleFromPlanar) const
finds all mesh edges where dihedral angle is distinct from planar PI angle on at least given value
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:432
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 Vector3f pseudonormal(VertId v, const FaceBitSet *region=nullptr) const
MRMESH_API std::optional< float > signedDistance(const Vector3f &pt, float maxDistSq, const FaceBitSet *region=nullptr) const
MRMESH_API Vector3f dirDblArea(VertId v) const
computes sum of directed double areas of all triangles around given vertex
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:164
MRMESH_API VertId splitFace(FaceId f, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
MRMESH_API 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...
MRMESH_API Vector3f findCenterFromPoints() const
computes average position of all valid mesh vertices
float edgeLengthSq(UndirectedEdgeId e) const
returns squared Euclidean length of the edge (faster to compute than length)
Definition MRMesh/MRMesh.h:146
MRMESH_API VertId getClosestVertex(const PointOnFace &p) const
returns one of three face vertices, closest to given point
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:98
MRMESH_API void addPartByMask(const Mesh &from, const FaceBitSet &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={})
EdgeId splitEdge(EdgeId e, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
Definition MRMesh/MRMesh.h:364
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:74
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:62
Vector3f destPnt(EdgeId e) const
returns coordinates of the edge destination
Definition MRMesh/MRMesh.h:65
MRMESH_API Expected< VertBitSet > findSpikeVertices(float minSumAngle, const VertBitSet *region=nullptr, ProgressCallback cb={}) const
returns vertices where the sum of triangle angles is below given threshold
MRMESH_API 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 ...
MRMESH_API Box3f getBoundingBox() const
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
Definition MRMesh/MRMesh.h:89
MRMESH_API bool projectPoint(const Vector3f &point, PointOnFace &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
MRMESH_API float circumcircleDiameterSq(FaceId f) const
returns squared circumcircle diameter of given mesh triangle
MRMESH_API EdgeId splitEdge(EdgeId e, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
Vector3f leftNormal(EdgeId e) const
computes triangular face normal from its vertices
Definition MRMesh/MRMesh.h:190
MRMESH_API void getLeftTriPoints(EdgeId e, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
returns three points of left face of e
MRMESH_API Vector3f findCenterFromBBox() const
computes bounding box and returns its center
bool isOutside(const Vector3f &pt, float windingNumberThreshold=0.5f, float beta=2) const
Definition MRMesh/MRMesh.h:246
LineSegm3f edgeSegment(EdgeId e) const
returns line segment of given edge
Definition MRMesh/MRMesh.h:71
MRMESH_API float signedDistance(const Vector3f &pt) const
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:438
VertId splitFace(FaceId f, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
Definition MRMesh/MRMesh.h:371
MRMESH_API void addPart(const Mesh &from, FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
appends mesh (from) in addition to this mesh: creates new edges, faces, verts and points
MRMESH_API void mirror(const Plane3f &plane)
reflects the mesh from a given plane
MRMESH_API 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...
MeshTopology topology
Definition MRMesh/MRMesh.h:24
UndirectedEdgeId getClosestEdge(const MeshTriPoint &p) const
returns one of three face edges, closest to given point
Definition MRMesh/MRMesh.h:140
MRMESH_API void transform(const AffineXf3f &xf, const VertBitSet *region=nullptr)
MRMESH_API float dihedralAngle(UndirectedEdgeId e) const
MRMESH_API double volume(const FaceBitSet *region=nullptr) const
MRMESH_API bool projectPoint(const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
MRMESH_API MeshTriPoint toTriPoint(const PointOnFace &p) const
converts face id and 3d point into barycentric representation
VertCoords points
Definition MRMesh/MRMesh.h:25
MRMESH_API float circumcircleDiameter(FaceId f) const
returns circumcircle diameter of given mesh triangle
MRMESH_API Vector3f triCenter(FaceId f) const
returns the centroid of given triangle
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:444
MRMESH_API QuadraticForm3f quadraticForm(VertId v, const FaceBitSet *region=nullptr, const UndirectedEdgeBitSet *creases=nullptr) const
MRMESH_API float leftCotan(EdgeId e) const
MRMESH_API MeshEdgePoint toEdgePoint(EdgeId e, const Vector3f &p) const
converts edge and 3d point into edge-point representation
float cotan(UndirectedEdgeId ue) const
Definition MRMesh/MRMesh.h:300
MRMESH_API MeshTriPoint toTriPoint(FaceId f, const Vector3f &p) const
converts face id and 3d point into barycentric representation
MRMESH_API float discreteMeanCurvature(VertId v) const
float dblArea(VertId v) const
computes the length of summed directed double areas of all triangles around given vertex
Definition MRMesh/MRMesh.h:199
MRMESH_API void attachEdgeLoopPart(EdgeId first, EdgeId last, const std::vector< Vector3f > &contourPoints)
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:77
void getTriPoints(FaceId f, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
returns three points of given face
Definition MRMesh/MRMesh.h:92
void getTriPoints(FaceId f, Vector3f(&v)[3]) const
returns three points of given face
Definition MRMesh/MRMesh.h:95
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
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:193
MRMESH_API float averageEdgeLength() const
computes average length of an edge in this mesh
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...
MRMESH_API Vector3f leftDirDblArea(EdgeId e) const
computes directed double area of left triangular face of given edge
Vector3f edgeCenter(UndirectedEdgeId e) const
computes the center of given edge
Definition MRMesh/MRMesh.h:80
MRMESH_API void updateCaches(const VertBitSet &changedVerts)
float edgeLength(UndirectedEdgeId e) const
returns Euclidean length of the edge
Definition MRMesh/MRMesh.h:143
MRMESH_API float discreteMeanCurvature(UndirectedEdgeId e) const
MRMESH_API Vector3f pseudonormal(const MeshTriPoint &p, const FaceBitSet *region=nullptr) const
MRMESH_API MeshEdgePoint toEdgePoint(VertId v) const
converts vertex into edge-point representation
MRMESH_API Vector3d holeDirArea(EdgeId e) const
MRMESH_API void addPartByMask(const Mesh &from, const FaceBitSet &fromFaces, const PartMapping &map)
the same but copies only portion of (from) specified by fromFaces
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
Definition MRMesh/MRMesh.h:86
MRMESH_API 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...
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:176
MRMESH_API float dihedralAngleCos(UndirectedEdgeId e) const
Vector3f dirDblArea(FaceId f) const
computes directed double area for a triangular face from its vertices
Definition MRMesh/MRMesh.h:152
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:202
Definition MRBuffer.h:151
Definition MRPartMapping.h:10
Definition MRPointOnFace.h:11
Definition MRTriMesh.h:13