MeshLib C++ Docs
Loading...
Searching...
No Matches

#include <MRMesh/MRMesh.h>

Public Member Functions

bool operator== (const Mesh &b) const
 compare that two meshes are exactly the same
Vector3f orgPnt (EdgeId e) const
 returns coordinates of the edge origin
Vector3f destPnt (EdgeId e) const
 returns coordinates of the edge destination
Vector3f edgeVector (EdgeId e) const
 returns vector equal to edge destination point minus edge origin point
LineSegm3f edgeSegment (EdgeId e) const
 returns line segment of given edge
Vector3f edgePoint (EdgeId e, float f) const
 returns a point on the edge: origin point for f=0 and destination point for f=1
Vector3f edgePoint (const MeshEdgePoint &ep) const
 computes coordinates of point given as edge and relative position on it
Vector3f edgeCenter (UndirectedEdgeId e) const
 computes the center of given edge
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 )
MR_BIND_IGNORE void getLeftTriPoints (EdgeId e, Vector3f(&v)[3]) const
Triangle3f getLeftTriPoints (EdgeId e) const
 returns three points of left face of e: res[0] = orgPnt( e ), res[1] = destPnt( e )
void getTriPoints (FaceId f, Vector3f &v0, Vector3f &v1, Vector3f &v2) const
 returns three points of given face
MR_BIND_IGNORE void getTriPoints (FaceId f, Vector3f(&v)[3]) const
Triangle3f getTriPoints (FaceId f) const
 returns three points of given face
Vector3f triPoint (const MeshTriPoint &p) const
 computes coordinates of point given as face and barycentric representation
Vector3f triCenter (FaceId f) const
 returns the centroid of given triangle
float triangleAspectRatio (FaceId f) const
 returns aspect ratio of given mesh triangle equal to the ratio of the circum-radius to twice its in-radius
float circumcircleDiameterSq (FaceId f) const
 returns squared circumcircle diameter of given mesh triangle
float circumcircleDiameter (FaceId f) const
 returns circumcircle diameter of given mesh triangle
MeshTriPoint toTriPoint (VertId v) const
 converts vertex into barycentric representation
MeshTriPoint toTriPoint (FaceId f, const Vector3f &p) const
 converts face id and 3d point into barycentric representation
MeshTriPoint toTriPoint (const PointOnFace &p) const
 converts face id and 3d point into barycentric representation
MeshEdgePoint toEdgePoint (VertId v) const
 converts vertex into edge-point representation
MeshEdgePoint toEdgePoint (EdgeId e, const Vector3f &p) const
 converts edge and 3d point into edge-point representation
VertId getClosestVertex (const PointOnFace &p) const
 returns one of three face vertices, closest to given point
VertId getClosestVertex (const MeshTriPoint &p) const
 returns one of three face vertices, closest to given point
UndirectedEdgeId getClosestEdge (const PointOnFace &p) const
 returns one of three face edges, closest to given point
UndirectedEdgeId getClosestEdge (const MeshTriPoint &p) const
 returns one of three face edges, closest to given point
float edgeLength (UndirectedEdgeId e) const
 returns Euclidean length of the edge
UndirectedEdgeScalars edgeLengths () const
 computes and returns the lengths of all edges in the mesh
float edgeLengthSq (UndirectedEdgeId e) const
 returns squared Euclidean length of the edge (faster to compute than length)
Vector3f leftDirDblArea (EdgeId e) const
 computes directed double area of left triangular face of given edge
Vector3f dirDblArea (FaceId f) const
 computes directed double area for a triangular face from its vertices
float dblArea (FaceId f) const
 returns twice the area of given face
float area (FaceId f) const
 returns the area of given face
MR_BIND_IGNORE double area (const FaceBitSet &fs) const
double area (const FaceBitSet *fs=nullptr) const
 computes the area of given face-region (or whole mesh)
MR_BIND_IGNORE Vector3d dirArea (const FaceBitSet &fs) const
Vector3d dirArea (const FaceBitSet *fs=nullptr) const
 computes the sum of directed areas for faces from given region (or whole mesh)
MR_BIND_IGNORE double projArea (const Vector3f &dir, const FaceBitSet &fs) const
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 look from given direction
double volume (const FaceBitSet *region=nullptr) const
double holePerimeter (EdgeId e) const
 computes the perimeter of the hole specified by one of its edges with no valid left face (left is hole)
Vector3d holeDirArea (EdgeId e) const
Vector3f leftTangent (EdgeId e) const
 computes unit vector that is both orthogonal to given edge and to the normal of its left triangle, the vector is directed inside left triangle
Vector3f leftNormal (EdgeId e) const
 computes triangular face normal from its vertices
Vector3f normal (FaceId f) const
 computes triangular face normal from its vertices
Plane3f getPlane3f (FaceId f) const
 returns the plane containing given triangular face with normal looking outwards
Plane3d getPlane3d (FaceId f) const
Vector3f dirDblArea (VertId v) const
 computes sum of directed double areas of all triangles around given vertex
float dblArea (VertId v) const
 computes the length of summed directed double areas of all triangles around given vertex
Vector3f normal (VertId v) const
 computes normal in a vertex using sum of directed areas of neighboring triangles
Vector3f normal (const MeshTriPoint &p) const
Vector3f pseudonormal (VertId v, const FaceBitSet *region=nullptr) const
Vector3f pseudonormal (UndirectedEdgeId e, const FaceBitSet *region=nullptr) const
 computes normalized half sum of face normals sharing given edge (only (region) faces will be considered);
Vector3f pseudonormal (const MeshTriPoint &p, const FaceBitSet *region=nullptr) const
float signedDistance (const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
MR_BIND_IGNORE float signedDistance (const Vector3f &pt, const MeshTriPoint &proj, const FaceBitSet *region=nullptr) const
float signedDistance (const Vector3f &pt) const
std::optional< float > signedDistance (const Vector3f &pt, float maxDistSq, const FaceBitSet *region=nullptr) const
float calcFastWindingNumber (const Vector3f &pt, float beta=2) const
bool isOutside (const Vector3f &pt, float windingNumberThreshold=0.5f, float beta=2) const
bool isOutsideByProjNorm (const Vector3f &pt, const MeshProjectionResult &proj, const FaceBitSet *region=nullptr) const
float sumAngles (VertId v, bool *outBoundaryVert=nullptr) const
 computes the sum of triangle angles at given vertex; optionally returns whether the vertex is on boundary
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
float dihedralAngleSin (UndirectedEdgeId e) const
float dihedralAngleCos (UndirectedEdgeId e) const
float dihedralAngle (UndirectedEdgeId e) const
float discreteMeanCurvature (VertId v) const
float discreteMeanCurvature (UndirectedEdgeId e) const
float discreteGaussianCurvature (VertId v, bool *outBoundaryVert=nullptr) const
UndirectedEdgeBitSet findCreaseEdges (float angleFromPlanar) const
 finds all mesh edges where dihedral angle is distinct from planar PI angle on at least given value
float leftCotan (EdgeId e) const
float cotan (UndirectedEdgeId ue) const
QuadraticForm3f quadraticForm (VertId v, bool angleWeigted, const FaceBitSet *region=nullptr, const UndirectedEdgeBitSet *creases=nullptr) const
Box3f getBoundingBox () const
Box3f computeBoundingBox (const AffineXf3f *toWorld=nullptr) const
Box3f computeBoundingBox (const FaceBitSet *region, const AffineXf3f *toWorld=nullptr) const
float averageEdgeLength () const
 computes average length of an edge in this mesh
Vector3f findCenterFromPoints () const
 computes average position of all valid mesh vertices
Vector3f findCenterFromFaces () const
 computes center of mass considering that density of all triangles is the same
Vector3f findCenterFromBBox () const
 computes bounding box and returns its center
void zeroUnusedPoints ()
 for all points not in topology.getValidVerts() sets coordinates to (0,0,0)
void transform (const AffineXf3f &xf, const VertBitSet *region=nullptr)
VertId addPoint (const Vector3f &pos)
 creates new point and assigns given position to it
EdgeId addSeparateEdgeLoop (const std::vector< Vector3f > &contourPoints)
EdgeId addSeparateContours (const Contours3f &contours, const AffineXf3f *xf=nullptr)
void attachEdgeLoopPart (EdgeId first, EdgeId last, const std::vector< Vector3f > &contourPoints)
EdgeId splitEdge (EdgeId e, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
EdgeId splitEdge (EdgeId e, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
 same, but split given edge on two equal parts
VertId splitFace (FaceId f, const Vector3f &newVertPos, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
VertId splitFace (FaceId f, FaceBitSet *region=nullptr, FaceHashMap *new2Old=nullptr)
 same, putting new vertex in the centroid of original triangle
void addMesh (const Mesh &from, PartMapping map={}, bool rearrangeTriangles=false)
 appends another mesh as separate connected component(s) to this
void addMesh (const Mesh &from, FaceMap *outFmap, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
MR_BIND_IGNORE void addPart (const Mesh &from, FaceMap *outFmap=nullptr, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
void addMeshPart (const MeshPart &from, const PartMapping &map)
 appends whole or part of another mesh as separate connected component(s) to this
MR_BIND_IGNORE void addPartByMask (const Mesh &from, const FaceBitSet &fromFaces, const PartMapping &map)
void addMeshPart (const MeshPart &from, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, PartMapping map={})
MR_BIND_IGNORE void addPartByMask (const Mesh &from, const FaceBitSet &fromFaces, bool flipOrientation=false, const std::vector< EdgePath > &thisContours={}, const std::vector< EdgePath > &fromContours={}, const PartMapping &map={})
Mesh cloneRegion (const FaceBitSet &region, bool flipOrientation=false, const PartMapping &map={}) const
 creates new mesh from given triangles of this mesh
void pack (const PartMapping &map={}, bool rearrangeTriangles=false)
 tightly packs all arrays eliminating lone edges and invalid faces, vertices and points
void pack (FaceMap *outFmap, VertMap *outVmap=nullptr, WholeEdgeMap *outEmap=nullptr, bool rearrangeTriangles=false)
Expected< void > pack (const PackMapping &map, ProgressCallback cb={})
PackMapping packOptimally (bool preserveAABBTree=true)
Expected< PackMappingpackOptimally (bool preserveAABBTree, ProgressCallback cb)
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 remaining faces and not in
bool projectPoint (const Vector3f &point, PointOnFace &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
bool projectPoint (const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
bool findClosestPoint (const Vector3f &point, MeshProjectionResult &res, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
MeshProjectionResult projectPoint (const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
MeshProjectionResult findClosestPoint (const Vector3f &point, float maxDistSq=FLT_MAX, const FaceBitSet *region=nullptr, const AffineXf3f *xf=nullptr) const
const AABBTreegetAABBTree () const
 returns cached aabb-tree for this mesh, creating it if it did not exist in a thread-safe manner
const AABBTreegetAABBTreeNotCreate () const
 returns cached aabb-tree for this mesh, but does not create it if it did not exist
const AABBTreePointsgetAABBTreePoints () const
 returns cached aabb-tree for points of this mesh, creating it if it did not exist in a thread-safe manner
const AABBTreePointsgetAABBTreePointsNotCreate () const
 returns cached aabb-tree for points of this mesh, but does not create it if it did not exist
const Dipoles & getDipoles () const
 returns cached dipoles of aabb-tree nodes for this mesh, creating it if it did not exist in a thread-safe manner
const Dipoles * getDipolesNotCreate () const
 returns cached dipoles of aabb-tree nodes for this mesh, but does not create it if it did not exist
void invalidateCaches (bool pointsChanged=true)
void updateCaches (const VertBitSet &changedVerts)
size_t heapBytes () const
 returns the amount of memory this object occupies on heap
void shrinkToFit ()
 requests the removal of unused capacity
void mirror (const Plane3f &plane)
 reflects the mesh from a given plane

Static Public Member Functions

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
static Mesh fromTriMesh (TriMesh &&triMesh, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
 construct mesh from TriMesh representation
static Mesh fromTrianglesDuplicatingNonManifoldVertices (VertCoords vertexCoordinates, Triangulation &t, std::vector< MeshBuilder::VertDuplication > *dups=nullptr, const MeshBuilder::BuildSettings &settings={})
static Mesh fromFaceSoup (VertCoords vertexCoordinates, const std::vector< VertId > &verts, const Vector< MeshBuilder::VertSpan, FaceId > &faces, const MeshBuilder::BuildSettings &settings={}, ProgressCallback cb={})
static Mesh fromPointTriples (const std::vector< Triangle3f > &posTriples, bool duplicateNonManifoldVertices)

Public Attributes

MeshTopology topology
VertCoords points

Detailed Description

This class represents a mesh, including topology (connectivity) information and point coordinates, as well as some caches to accelerate search algorithms

Member Function Documentation

◆ addMesh() [1/2]

void MR::Mesh::addMesh ( const Mesh & from,
FaceMap * outFmap,
VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr,
bool rearrangeTriangles = false )
Parameters
outFmapoptionally returns mappings: from.id -> this.id

◆ addMesh() [2/2]

void MR::Mesh::addMesh ( const Mesh & from,
PartMapping map = {},
bool rearrangeTriangles = false )

appends another mesh as separate connected component(s) to this

◆ addMeshPart() [1/2]

void MR::Mesh::addMeshPart ( const MeshPart & from,
bool flipOrientation = false,
const std::vector< EdgePath > & thisContours = {},
const std::vector< EdgePath > & fromContours = {},
PartMapping map = {} )

appends whole or part of another mesh to this joining added faces with existed ones along given contours

Parameters
flipOrientationtrue means that every (from) triangle is inverted before adding
Parameters
fromContourscontours on this mesh that have to be stitched with
mapcontours on from mesh during addition optionally returns mappings: from.id -> this.id

◆ addMeshPart() [2/2]

void MR::Mesh::addMeshPart ( const MeshPart & from,
const PartMapping & map )

appends whole or part of another mesh as separate connected component(s) to this

◆ addPart()

MR_BIND_IGNORE void MR::Mesh::addPart ( const Mesh & from,
FaceMap * outFmap = nullptr,
VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr,
bool rearrangeTriangles = false )
inline

◆ addPartByMask() [1/2]

MR_BIND_IGNORE void MR::Mesh::addPartByMask ( const Mesh & from,
const FaceBitSet & fromFaces,
bool flipOrientation = false,
const std::vector< EdgePath > & thisContours = {},
const std::vector< EdgePath > & fromContours = {},
const PartMapping & map = {} )
inline

◆ addPartByMask() [2/2]

MR_BIND_IGNORE void MR::Mesh::addPartByMask ( const Mesh & from,
const FaceBitSet & fromFaces,
const PartMapping & map )
inline

◆ addPoint()

VertId MR::Mesh::addPoint ( const Vector3f & pos)

creates new point and assigns given position to it

◆ addSeparateContours()

EdgeId MR::Mesh::addSeparateContours ( const Contours3f & contours,
const AffineXf3f * xf = nullptr )

append points to mesh and connect them returns first EdgeId of new edges

◆ addSeparateEdgeLoop()

EdgeId MR::Mesh::addSeparateEdgeLoop ( const std::vector< Vector3f > & contourPoints)

append points to mesh and connect them as closed edge loop returns first EdgeId of new edges

◆ area() [1/3]

MR_BIND_IGNORE double MR::Mesh::area ( const FaceBitSet & fs) const
inlinenodiscard

computes the area of given face-region This is skipped in the bindings because it conflicts with the overload taking a pointer in C#. Since that overload is strictly more useful, we're keeping that one.

◆ area() [2/3]

double MR::Mesh::area ( const FaceBitSet * fs = nullptr) const
inlinenodiscard

computes the area of given face-region (or whole mesh)

◆ area() [3/3]

float MR::Mesh::area ( FaceId f) const
inlinenodiscard

returns the area of given face

◆ attachEdgeLoopPart()

void MR::Mesh::attachEdgeLoopPart ( EdgeId first,
EdgeId last,
const std::vector< Vector3f > & contourPoints )

append points to mesh and connect them to given edges making edge loop first point connects with first edge dest last point connects with last edge org note that first and last edge should have no left face

◆ averageEdgeLength()

float MR::Mesh::averageEdgeLength ( ) const
inlinenodiscard

computes average length of an edge in this mesh

◆ calcFastWindingNumber()

float MR::Mesh::calcFastWindingNumber ( const Vector3f & pt,
float beta = 2 ) const
nodiscard

computes generalized winding number in a point (pt), which is

  • for closed mesh with normals outside: 1 inside, 0 outside;
  • for planar mesh: 0.5 inside, -0.5 outside; and in general is equal to (portion of solid angle where inside part of mesh is observable) minus (portion of solid angle where outside part of mesh is observable)
    Parameters
    betadetermines the precision of fast approximation: the more the better, recommended value 2 or more

◆ circumcircleDiameter()

float MR::Mesh::circumcircleDiameter ( FaceId f) const
inlinenodiscard

returns circumcircle diameter of given mesh triangle

◆ circumcircleDiameterSq()

float MR::Mesh::circumcircleDiameterSq ( FaceId f) const
inlinenodiscard

returns squared circumcircle diameter of given mesh triangle

◆ cloneRegion()

Mesh MR::Mesh::cloneRegion ( const FaceBitSet & region,
bool flipOrientation = false,
const PartMapping & map = {} ) const

creates new mesh from given triangles of this mesh

◆ computeBoundingBox() [1/2]

Box3f MR::Mesh::computeBoundingBox ( const AffineXf3f * toWorld = nullptr) const
nodiscard

passes through all valid vertices and finds the minimal bounding box containing all of them; if toWorld transformation is given then returns minimal bounding box in world space

◆ computeBoundingBox() [2/2]

Box3f MR::Mesh::computeBoundingBox ( const FaceBitSet * region,
const AffineXf3f * toWorld = nullptr ) const
nodiscard

passes through all given faces (or whole mesh if region == null) and finds the minimal bounding box containing all of them if toWorld transformation is given then returns minimal bounding box in world space

◆ cotan()

float MR::Mesh::cotan ( UndirectedEdgeId ue) const
inlinenodiscard

computes sum of cotangents of the angle in the left and right triangles opposite to given edge, consider cotangents zero for not existing triangles

◆ dblArea() [1/2]

float MR::Mesh::dblArea ( FaceId f) const
inlinenodiscard

returns twice the area of given face

◆ dblArea() [2/2]

float MR::Mesh::dblArea ( VertId v) const
inlinenodiscard

computes the length of summed directed double areas of all triangles around given vertex

◆ deleteFaces()

void MR::Mesh::deleteFaces ( const FaceBitSet & fs,
const UndirectedEdgeBitSet * keepEdges = nullptr )

deletes multiple given faces, also deletes adjacent edges and vertices if they were not shared by remaining faces and not in

Parameters
keepEdges

◆ destPnt()

Vector3f MR::Mesh::destPnt ( EdgeId e) const
inlinenodiscard

returns coordinates of the edge destination

◆ dihedralAngle()

float MR::Mesh::dihedralAngle ( UndirectedEdgeId e) const
inlinenodiscard

given an edge between two triangular faces, computes the dihedral angle between them: 0 if both faces are in the same plane, positive if the faces form convex surface, negative if the faces form concave surface; please consider the usage of faster dihedralAngleSin(e) and dihedralAngleCos(e)

◆ dihedralAngleCos()

float MR::Mesh::dihedralAngleCos ( UndirectedEdgeId e) const
inlinenodiscard

given an edge between two triangular faces, computes cosine of dihedral angle between them: 1 if both faces are in the same plane, 0 if the surface makes right angle turn at the edge, -1 if the faces overlap one another

◆ dihedralAngleSin()

float MR::Mesh::dihedralAngleSin ( UndirectedEdgeId e) const
inlinenodiscard

given an edge between two triangular faces, computes sine of dihedral angle between them: 0 if both faces are in the same plane, positive if the faces form convex surface, negative if the faces form concave surface

◆ dirArea() [1/2]

MR_BIND_IGNORE Vector3d MR::Mesh::dirArea ( const FaceBitSet & fs) const
inlinenodiscard

computes the sum of directed areas for faces from given region This is skipped in the bindings because it conflicts with the overload taking a pointer in C#. Since that overload is strictly more useful, we're keeping that one.

◆ dirArea() [2/2]

Vector3d MR::Mesh::dirArea ( const FaceBitSet * fs = nullptr) const
inlinenodiscard

computes the sum of directed areas for faces from given region (or whole mesh)

◆ dirDblArea() [1/2]

Vector3f MR::Mesh::dirDblArea ( FaceId f) const
inlinenodiscard

computes directed double area for a triangular face from its vertices

◆ dirDblArea() [2/2]

Vector3f MR::Mesh::dirDblArea ( VertId v) const
inlinenodiscard

computes sum of directed double areas of all triangles around given vertex

◆ discreteGaussianCurvature()

float MR::Mesh::discreteGaussianCurvature ( VertId v,
bool * outBoundaryVert = nullptr ) const
inlinenodiscard

computes discrete Gaussian curvature (or angle defect) at given vertex, which 0 in inner vertices on planar mesh parts and reaches 2*pi on needle's tip, see http:/// math.uchicago.edu/~may/REU2015/REUPapers/Upadhyay.pdf optionally returns whether the vertex is on boundary

◆ discreteMeanCurvature() [1/2]

float MR::Mesh::discreteMeanCurvature ( UndirectedEdgeId e) const
inlinenodiscard

computes discrete mean curvature in given edge, measures in length^-1; 0 for planar regions, positive for convex surface, negative for concave surface

◆ discreteMeanCurvature() [2/2]

float MR::Mesh::discreteMeanCurvature ( VertId v) const
inlinenodiscard

computes discrete mean curvature in given vertex, measures in length^-1; 0 for planar regions, positive for convex surface, negative for concave surface

◆ edgeCenter()

Vector3f MR::Mesh::edgeCenter ( UndirectedEdgeId e) const
inlinenodiscard

computes the center of given edge

◆ edgeLength()

float MR::Mesh::edgeLength ( UndirectedEdgeId e) const
inlinenodiscard

returns Euclidean length of the edge

◆ edgeLengths()

UndirectedEdgeScalars MR::Mesh::edgeLengths ( ) const
inlinenodiscard

computes and returns the lengths of all edges in the mesh

◆ edgeLengthSq()

float MR::Mesh::edgeLengthSq ( UndirectedEdgeId e) const
inlinenodiscard

returns squared Euclidean length of the edge (faster to compute than length)

◆ edgePoint() [1/2]

Vector3f MR::Mesh::edgePoint ( const MeshEdgePoint & ep) const
inlinenodiscard

computes coordinates of point given as edge and relative position on it

◆ edgePoint() [2/2]

Vector3f MR::Mesh::edgePoint ( EdgeId e,
float f ) const
inlinenodiscard

returns a point on the edge: origin point for f=0 and destination point for f=1

◆ edgeSegment()

LineSegm3f MR::Mesh::edgeSegment ( EdgeId e) const
nodiscard

returns line segment of given edge

◆ edgeVector()

Vector3f MR::Mesh::edgeVector ( EdgeId e) const
inlinenodiscard

returns vector equal to edge destination point minus edge origin point

◆ findCenterFromBBox()

Vector3f MR::Mesh::findCenterFromBBox ( ) const
inlinenodiscard

computes bounding box and returns its center

◆ findCenterFromFaces()

Vector3f MR::Mesh::findCenterFromFaces ( ) const
inlinenodiscard

computes center of mass considering that density of all triangles is the same

◆ findCenterFromPoints()

Vector3f MR::Mesh::findCenterFromPoints ( ) const
inlinenodiscard

computes average position of all valid mesh vertices

◆ findClosestPoint() [1/2]

MeshProjectionResult MR::Mesh::findClosestPoint ( const Vector3f & point,
float maxDistSq = FLT_MAX,
const FaceBitSet * region = nullptr,
const AffineXf3f * xf = nullptr ) const
inlinenodiscard

◆ findClosestPoint() [2/2]

bool MR::Mesh::findClosestPoint ( const Vector3f & point,
MeshProjectionResult & res,
float maxDistSq = FLT_MAX,
const FaceBitSet * region = nullptr,
const AffineXf3f * xf = nullptr ) const
inlinenodiscard

◆ findCreaseEdges()

UndirectedEdgeBitSet MR::Mesh::findCreaseEdges ( float angleFromPlanar) const
inlinenodiscard

finds all mesh edges where dihedral angle is distinct from planar PI angle on at least given value

◆ findSpikeVertices()

Expected< VertBitSet > MR::Mesh::findSpikeVertices ( float minSumAngle,
const VertBitSet * region = nullptr,
const ProgressCallback & cb = {} ) const
inlinenodiscard

returns vertices where the sum of triangle angles is below given threshold

◆ fromFaceSoup()

Mesh MR::Mesh::fromFaceSoup ( VertCoords vertexCoordinates,
const std::vector< VertId > & verts,
const Vector< MeshBuilder::VertSpan, FaceId > & faces,
const MeshBuilder::BuildSettings & settings = {},
ProgressCallback cb = {} )
staticnodiscard

construct mesh from vertex coordinates and construct mesh topology from face soup, where each face can have arbitrary degree (not only triangles); all non-triangular faces will be automatically subdivided on triangles

◆ fromPointTriples()

Mesh MR::Mesh::fromPointTriples ( const std::vector< Triangle3f > & posTriples,
bool duplicateNonManifoldVertices )
staticnodiscard

construct mesh from point triples;

Parameters
duplicateNonManifoldVertices= false, all coinciding points are given the same VertId in the result; duplicateNonManifoldVertices = true, it tries to avoid non-manifold vertices by creating duplicate vertices with same coordinates

◆ fromTriangles()

Mesh MR::Mesh::fromTriangles ( VertCoords vertexCoordinates,
const Triangulation & t,
const MeshBuilder::BuildSettings & settings = {},
ProgressCallback cb = {} )
staticnodiscard

construct mesh from vertex coordinates and a set of triangles with given ids

◆ fromTrianglesDuplicatingNonManifoldVertices()

Mesh MR::Mesh::fromTrianglesDuplicatingNonManifoldVertices ( VertCoords vertexCoordinates,
Triangulation & t,
std::vector< MeshBuilder::VertDuplication > * dups = nullptr,
const MeshBuilder::BuildSettings & settings = {} )
staticnodiscard

construct mesh from vertex coordinates and a set of triangles with given ids; unlike simple fromTriangles() it tries to resolve non-manifold vertices by creating duplicate vertices

◆ fromTriMesh()

Mesh MR::Mesh::fromTriMesh ( TriMesh && triMesh,
const MeshBuilder::BuildSettings & settings = {},
ProgressCallback cb = {} )
staticnodiscard

construct mesh from TriMesh representation

Parameters
triMeshpoints of triMesh will be moves in the result

◆ getAABBTree()

const AABBTree & MR::Mesh::getAABBTree ( ) const

returns cached aabb-tree for this mesh, creating it if it did not exist in a thread-safe manner

◆ getAABBTreeNotCreate()

const AABBTree * MR::Mesh::getAABBTreeNotCreate ( ) const
inlinenodiscard

returns cached aabb-tree for this mesh, but does not create it if it did not exist

◆ getAABBTreePoints()

const AABBTreePoints & MR::Mesh::getAABBTreePoints ( ) const

returns cached aabb-tree for points of this mesh, creating it if it did not exist in a thread-safe manner

◆ getAABBTreePointsNotCreate()

const AABBTreePoints * MR::Mesh::getAABBTreePointsNotCreate ( ) const
inlinenodiscard

returns cached aabb-tree for points of this mesh, but does not create it if it did not exist

◆ getBoundingBox()

Box3f MR::Mesh::getBoundingBox ( ) const
nodiscard

returns the bounding box containing all valid vertices (implemented via getAABBTree()) this bounding box is insignificantly bigger that minimal box due to AABB algorithms precision

◆ getClosestEdge() [1/2]

UndirectedEdgeId MR::Mesh::getClosestEdge ( const MeshTriPoint & p) const
inlinenodiscard

returns one of three face edges, closest to given point

◆ getClosestEdge() [2/2]

UndirectedEdgeId MR::Mesh::getClosestEdge ( const PointOnFace & p) const
inlinenodiscard

returns one of three face edges, closest to given point

◆ getClosestVertex() [1/2]

VertId MR::Mesh::getClosestVertex ( const MeshTriPoint & p) const
inlinenodiscard

returns one of three face vertices, closest to given point

◆ getClosestVertex() [2/2]

VertId MR::Mesh::getClosestVertex ( const PointOnFace & p) const
inlinenodiscard

returns one of three face vertices, closest to given point

◆ getDipoles()

const Dipoles & MR::Mesh::getDipoles ( ) const

returns cached dipoles of aabb-tree nodes for this mesh, creating it if it did not exist in a thread-safe manner

◆ getDipolesNotCreate()

const Dipoles * MR::Mesh::getDipolesNotCreate ( ) const
inlinenodiscard

returns cached dipoles of aabb-tree nodes for this mesh, but does not create it if it did not exist

◆ getLeftTriPoints() [1/3]

Triangle3f MR::Mesh::getLeftTriPoints ( EdgeId e) const
inlinenodiscard

returns three points of left face of e: res[0] = orgPnt( e ), res[1] = destPnt( e )

◆ getLeftTriPoints() [2/3]

void MR::Mesh::getLeftTriPoints ( EdgeId e,
Vector3f & v0,
Vector3f & v1,
Vector3f & v2 ) const
inline

returns three points of left face of e: v0 = orgPnt( e ), v1 = destPnt( e )

◆ getLeftTriPoints() [3/3]

MR_BIND_IGNORE void MR::Mesh::getLeftTriPoints ( EdgeId e,
Vector3f(&) v[3] ) const
inline

returns three points of left face of e: v[0] = orgPnt( e ), v[1] = destPnt( e ) This one is not in the bindings because of the reference-to-array parameter.

◆ getPlane3d()

Plane3d MR::Mesh::getPlane3d ( FaceId f) const
nodiscard

◆ getPlane3f()

Plane3f MR::Mesh::getPlane3f ( FaceId f) const
nodiscard

returns the plane containing given triangular face with normal looking outwards

◆ getTriPoints() [1/3]

Triangle3f MR::Mesh::getTriPoints ( FaceId f) const
inlinenodiscard

returns three points of given face

◆ getTriPoints() [2/3]

void MR::Mesh::getTriPoints ( FaceId f,
Vector3f & v0,
Vector3f & v1,
Vector3f & v2 ) const
inline

returns three points of given face

◆ getTriPoints() [3/3]

MR_BIND_IGNORE void MR::Mesh::getTriPoints ( FaceId f,
Vector3f(&) v[3] ) const
inline

returns three points of given face This one is not in the bindings because of the reference-to-array parameter.

◆ heapBytes()

size_t MR::Mesh::heapBytes ( ) const
nodiscard

returns the amount of memory this object occupies on heap

◆ holeDirArea()

Vector3d MR::Mesh::holeDirArea ( EdgeId e) const
inlinenodiscard

computes directed area of the hole specified by one of its edges with no valid left face (left is hole); if the hole is planar then returned vector is orthogonal to the plane pointing outside and its magnitude is equal to hole area

◆ holePerimeter()

double MR::Mesh::holePerimeter ( EdgeId e) const
inlinenodiscard

computes the perimeter of the hole specified by one of its edges with no valid left face (left is hole)

◆ invalidateCaches()

void MR::Mesh::invalidateCaches ( bool pointsChanged = true)

invalidates caches (aabb-trees) after any change in mesh geometry or topology

Parameters
pointsChangedspecifies whether points have changed (otherwise only topology has changed)

◆ isOutside()

bool MR::Mesh::isOutside ( const Vector3f & pt,
float windingNumberThreshold = 0.5f,
float beta = 2 ) const
inlinenodiscard

computes whether a point (pt) is located outside the object surrounded by this mesh using generalized winding number

Parameters
betadetermines the precision of winding number computation: the more the better, recommended value 2 or more

◆ isOutsideByProjNorm()

bool MR::Mesh::isOutsideByProjNorm ( const Vector3f & pt,
const MeshProjectionResult & proj,
const FaceBitSet * region = nullptr ) const
nodiscard

computes whether a point (pt) is located outside the object surrounded by this mesh using pseudonormal at the closest point to in on mesh (proj); this method works much faster than isOutside but can return wrong sign if the closest point is located on self-intersecting part of the mesh

◆ leftCotan()

float MR::Mesh::leftCotan ( EdgeId e) const
inlinenodiscard

computes cotangent of the angle in the left( e ) triangle opposite to e, and returns 0 if left face does not exist

◆ leftDirDblArea()

Vector3f MR::Mesh::leftDirDblArea ( EdgeId e) const
inlinenodiscard

computes directed double area of left triangular face of given edge

◆ leftNormal()

Vector3f MR::Mesh::leftNormal ( EdgeId e) const
inlinenodiscard

computes triangular face normal from its vertices

◆ leftTangent()

Vector3f MR::Mesh::leftTangent ( EdgeId e) const
inlinenodiscard

computes unit vector that is both orthogonal to given edge and to the normal of its left triangle, the vector is directed inside left triangle

◆ mirror()

void MR::Mesh::mirror ( const Plane3f & plane)

reflects the mesh from a given plane

◆ normal() [1/3]

Vector3f MR::Mesh::normal ( const MeshTriPoint & p) const
inlinenodiscard

computes normal in three vertices of p's triangle, then interpolates them using barycentric coordinates and normalizes again; this is the same normal as in rendering with smooth shading

◆ normal() [2/3]

Vector3f MR::Mesh::normal ( FaceId f) const
inlinenodiscard

computes triangular face normal from its vertices

◆ normal() [3/3]

Vector3f MR::Mesh::normal ( VertId v) const
inlinenodiscard

computes normal in a vertex using sum of directed areas of neighboring triangles

◆ operator==()

bool MR::Mesh::operator== ( const Mesh & b) const
nodiscard

compare that two meshes are exactly the same

◆ orgPnt()

Vector3f MR::Mesh::orgPnt ( EdgeId e) const
inlinenodiscard

returns coordinates of the edge origin

◆ pack() [1/3]

Expected< void > MR::Mesh::pack ( const PackMapping & map,
ProgressCallback cb = {} )

tightly packs all arrays eliminating lone edges and invalid faces, vertices and points, reorder all faces, vertices and edges according to given maps, each containing old id -> new id mapping

◆ pack() [2/3]

void MR::Mesh::pack ( const PartMapping & map = {},
bool rearrangeTriangles = false )

tightly packs all arrays eliminating lone edges and invalid faces, vertices and points

◆ pack() [3/3]

void MR::Mesh::pack ( FaceMap * outFmap,
VertMap * outVmap = nullptr,
WholeEdgeMap * outEmap = nullptr,
bool rearrangeTriangles = false )
Parameters
outFmapoptionally returns mappings: old.id -> new.id

◆ packOptimally() [1/2]

Expected< PackMapping > MR::Mesh::packOptimally ( bool preserveAABBTree,
ProgressCallback cb )

◆ packOptimally() [2/2]

PackMapping MR::Mesh::packOptimally ( bool preserveAABBTree = true)

packs tightly and rearranges vertices, triangles and edges to put close in space elements in close indices

Parameters
preserveAABBTreewhether to keep valid mesh's AABB tree after return (it will take longer to compute and it will occupy more memory)

◆ projArea() [1/2]

MR_BIND_IGNORE double MR::Mesh::projArea ( const Vector3f & dir,
const FaceBitSet & fs ) const
inlinenodiscard

computes the sum of absolute projected area of faces from given region as visible if look from given direction This is skipped in the bindings because it conflicts with the overload taking a pointer in C#. Since that overload is strictly more useful, we're keeping that one.

◆ projArea() [2/2]

double MR::Mesh::projArea ( const Vector3f & dir,
const FaceBitSet * fs = nullptr ) const
inlinenodiscard

computes the sum of absolute projected area of faces from given region (or whole mesh) as visible if look from given direction

◆ projectPoint() [1/3]

MeshProjectionResult MR::Mesh::projectPoint ( const Vector3f & point,
float maxDistSq = FLT_MAX,
const FaceBitSet * region = nullptr,
const AffineXf3f * xf = nullptr ) const
nodiscard

finds the closest mesh point on this mesh (or its region) to given point;

Parameters
pointsource location to look the closest to
maxDistSqsearch only in the ball with sqrt(maxDistSq) radius around given point, smaller value here increases performance
xfis mesh-to-point transformation, if not specified then identity transformation is assumed and works much faster;
Returns
found closest point including Euclidean coordinates, barycentric coordinates, FaceId and squared distance to point or std::nullopt if no mesh point is found in the ball with sqrt(maxDistSq) radius around given point

◆ projectPoint() [2/3]

bool MR::Mesh::projectPoint ( const Vector3f & point,
MeshProjectionResult & res,
float maxDistSq = FLT_MAX,
const FaceBitSet * region = nullptr,
const AffineXf3f * xf = nullptr ) const
nodiscard

finds the closest mesh point on this mesh (or its region) to given point;

Parameters
pointsource location to look the closest to
resfound closest point including Euclidean coordinates, barycentric coordinates, FaceId and squared distance to point
maxDistSqsearch only in the ball with sqrt(maxDistSq) radius around given point, smaller value here increases performance
xfis mesh-to-point transformation, if not specified then identity transformation is assumed and works much faster;
Returns
false if no mesh point is found in the ball with sqrt(maxDistSq) radius around given point

◆ projectPoint() [3/3]

bool MR::Mesh::projectPoint ( const Vector3f & point,
PointOnFace & res,
float maxDistSq = FLT_MAX,
const FaceBitSet * region = nullptr,
const AffineXf3f * xf = nullptr ) const
nodiscard

finds the closest mesh point on this mesh (or its region) to given point;

Parameters
pointsource location to look the closest to
resfound closest point including Euclidean coordinates and FaceId
maxDistSqsearch only in the ball with sqrt(maxDistSq) radius around given point, smaller value here increases performance
xfis mesh-to-point transformation, if not specified then identity transformation is assumed and works much faster;
Returns
false if no mesh point is found in the ball with sqrt(maxDistSq) radius around given point

◆ pseudonormal() [1/3]

Vector3f MR::Mesh::pseudonormal ( const MeshTriPoint & p,
const FaceBitSet * region = nullptr ) const
inlinenodiscard

returns pseudonormal in corresponding face/edge/vertex for signed distance calculation as suggested in the article "Signed Distance Computation Using the Angle Weighted Pseudonormal" by J. Andreas Baerentzen and Henrik Aanaes, https:/// backend.orbit.dtu.dk/ws/portalfiles/portal/3977815/B_rentzen.pdf unlike normal( const MeshTriPoint & p ), this is not a smooth function

◆ pseudonormal() [2/3]

Vector3f MR::Mesh::pseudonormal ( UndirectedEdgeId e,
const FaceBitSet * region = nullptr ) const
inlinenodiscard

computes normalized half sum of face normals sharing given edge (only (region) faces will be considered);

◆ pseudonormal() [3/3]

Vector3f MR::Mesh::pseudonormal ( VertId v,
const FaceBitSet * region = nullptr ) const
inlinenodiscard

computes angle-weighted sum of normals of incident faces of given vertex (only (region) faces will be considered); the sum is normalized before returning

◆ quadraticForm()

QuadraticForm3f MR::Mesh::quadraticForm ( VertId v,
bool angleWeigted,
const FaceBitSet * region = nullptr,
const UndirectedEdgeBitSet * creases = nullptr ) const
nodiscard

computes quadratic form in the vertex as the sum of squared distances from 1) planes of adjacent triangles, with the weight equal to the angle of adjacent triangle at this vertex divided on PI in case of angleWeigted=true; 2) lines of adjacent boundary and crease edges

◆ shrinkToFit()

void MR::Mesh::shrinkToFit ( )

requests the removal of unused capacity

◆ signedDistance() [1/4]

float MR::Mesh::signedDistance ( const Vector3f & pt) const
nodiscard

given a point (pt) in 3D, computes the closest point on mesh, and

Returns
signed distance from pt to mesh: positive value - outside mesh, negative - inside mesh; this method can return wrong sign if the closest point is located on self-intersecting part of the mesh

◆ signedDistance() [2/4]

float MR::Mesh::signedDistance ( const Vector3f & pt,
const MeshProjectionResult & proj,
const FaceBitSet * region = nullptr ) const
nodiscard

given a point (pt) in 3D and the closest point to in on mesh (proj),

Returns
signed distance from pt to mesh: positive value - outside mesh, negative - inside mesh; this method can return wrong sign if the closest point is located on self-intersecting part of the mesh

◆ signedDistance() [3/4]

MR_BIND_IGNORE float MR::Mesh::signedDistance ( const Vector3f & pt,
const MeshTriPoint & proj,
const FaceBitSet * region = nullptr ) const

◆ signedDistance() [4/4]

std::optional< float > MR::Mesh::signedDistance ( const Vector3f & pt,
float maxDistSq,
const FaceBitSet * region = nullptr ) const
nodiscard

given a point (pt) in 3D, computes the closest point on mesh, and

Returns
signed distance from pt to mesh: positive value - outside mesh, negative - inside mesh; or std::nullopt if the projection point is not within maxDist; this method can return wrong sign if the closest point is located on self-intersecting part of the mesh

◆ splitEdge() [1/2]

EdgeId MR::Mesh::splitEdge ( EdgeId e,
const Vector3f & newVertPos,
FaceBitSet * region = nullptr,
FaceHashMap * new2Old = nullptr )

split given edge on two parts: dest(returned-edge) = org(e) - newly created vertex, org(returned-edge) = org(e-before-split), dest(e) = dest(e-before-split)

left and right faces of given edge if valid are also subdivided on two parts each; the split edge will keep both face IDs and their degrees, and the new edge will have new face IDs and new faces are triangular; if left or right faces of the original edge were in the region, then include new parts of these faces in the region

Parameters
new2Oldreceive mapping from newly appeared triangle to its original triangle (part to full)

◆ splitEdge() [2/2]

EdgeId MR::Mesh::splitEdge ( EdgeId e,
FaceBitSet * region = nullptr,
FaceHashMap * new2Old = nullptr )
inline

same, but split given edge on two equal parts

◆ splitFace() [1/2]

VertId MR::Mesh::splitFace ( FaceId f,
const Vector3f & newVertPos,
FaceBitSet * region = nullptr,
FaceHashMap * new2Old = nullptr )

split given triangle on three triangles, introducing new vertex with given coordinates and connecting it to original triangle vertices; if region is given, then it must include (f) and new faces will be added there as well

Parameters
new2Oldreceive mapping from newly appeared triangle to its original triangle (part to full)

◆ splitFace() [2/2]

VertId MR::Mesh::splitFace ( FaceId f,
FaceBitSet * region = nullptr,
FaceHashMap * new2Old = nullptr )
inline

same, putting new vertex in the centroid of original triangle

◆ sumAngles()

float MR::Mesh::sumAngles ( VertId v,
bool * outBoundaryVert = nullptr ) const
inlinenodiscard

computes the sum of triangle angles at given vertex; optionally returns whether the vertex is on boundary

◆ toEdgePoint() [1/2]

MeshEdgePoint MR::Mesh::toEdgePoint ( EdgeId e,
const Vector3f & p ) const
inlinenodiscard

converts edge and 3d point into edge-point representation

◆ toEdgePoint() [2/2]

MeshEdgePoint MR::Mesh::toEdgePoint ( VertId v) const
nodiscard

converts vertex into edge-point representation

◆ toTriPoint() [1/3]

MeshTriPoint MR::Mesh::toTriPoint ( const PointOnFace & p) const
inlinenodiscard

converts face id and 3d point into barycentric representation

◆ toTriPoint() [2/3]

MeshTriPoint MR::Mesh::toTriPoint ( FaceId f,
const Vector3f & p ) const
inlinenodiscard

converts face id and 3d point into barycentric representation

◆ toTriPoint() [3/3]

MeshTriPoint MR::Mesh::toTriPoint ( VertId v) const
nodiscard

converts vertex into barycentric representation

◆ transform()

void MR::Mesh::transform ( const AffineXf3f & xf,
const VertBitSet * region = nullptr )

applies given transformation to specified vertices if region is nullptr, all valid mesh vertices are used

◆ triangleAspectRatio()

float MR::Mesh::triangleAspectRatio ( FaceId f) const
inlinenodiscard

returns aspect ratio of given mesh triangle equal to the ratio of the circum-radius to twice its in-radius

◆ triCenter()

Vector3f MR::Mesh::triCenter ( FaceId f) const
inlinenodiscard

returns the centroid of given triangle

◆ triPoint()

Vector3f MR::Mesh::triPoint ( const MeshTriPoint & p) const
inlinenodiscard

computes coordinates of point given as face and barycentric representation

◆ updateCaches()

void MR::Mesh::updateCaches ( const VertBitSet & changedVerts)

updates existing caches in case of few vertices were changed insignificantly, and topology remained unchanged; it shall be considered as a faster alternative to invalidateCaches() and following rebuild of trees

◆ volume()

double MR::Mesh::volume ( const FaceBitSet * region = nullptr) const
inlinenodiscard

returns volume of the object surrounded by given region (or whole mesh if (region) is nullptr); if the region has holes then each hole will be virtually filled by adding triangles for each edge and the hole's geometrical center

◆ zeroUnusedPoints()

void MR::Mesh::zeroUnusedPoints ( )

for all points not in topology.getValidVerts() sets coordinates to (0,0,0)

Member Data Documentation

◆ points

VertCoords MR::Mesh::points

◆ topology

MeshTopology MR::Mesh::topology

The documentation for this struct was generated from the following file: