MeshLib
 
Loading...
Searching...
No Matches
MR::MeshBuilder Namespace Reference

Building topologies by triangles. More...

Classes

struct  BuildSettings
 
struct  equalVector3f
 this makes bit-wise comparison of two Vector3f's thus making two NaNs equal More...
 
struct  MeshPiece
 
struct  Triangle
 mesh triangle represented by its three vertices and by its face ID More...
 
struct  VertDuplication
 
class  VertexIdentifier
 
struct  VertSpan
 

Functions

MRMESH_API MeshTopology fromTriangles (const Triangulation &t, const BuildSettings &settings={}, ProgressCallback progressCb={})
 
MRMESH_API size_t duplicateNonManifoldVertices (Triangulation &t, FaceBitSet *region=nullptr, std::vector< VertDuplication > *dups=nullptr)
 
MRMESH_API MeshTopology fromTrianglesDuplicatingNonManifoldVertices (Triangulation &t, std::vector< VertDuplication > *dups=nullptr, const BuildSettings &settings={})
 
MRMESH_API Mesh fromPointTriples (const std::vector< Triangle3f > &posTriples)
 
MRMESH_API MeshTopology fromDisjointMeshPieces (const Triangulation &t, VertId maxVertId, const std::vector< MeshPiece > &pieces, const BuildSettings &settings={})
 
MRMESH_API void addTriangles (MeshTopology &res, const Triangulation &t, const BuildSettings &settings={})
 
MRMESH_API void addTriangles (MeshTopology &res, std::vector< VertId > &vertTriples, FaceBitSet *createdFaces=nullptr)
 
MRMESH_API MeshTopology fromFaceSoup (const std::vector< VertId > &verts, const Vector< VertSpan, FaceId > &faces, const BuildSettings &settings={}, ProgressCallback progressCb={})
 construct mesh topology from face soup, where each face can have arbitrary degree (not only triangles)
 
MRMESH_API int uniteCloseVertices (Mesh &mesh, float closeDist, bool uniteOnlyBd=true, VertMap *optionalVertOldToNew=nullptr)
 

Detailed Description

Building topologies by triangles.

This namespace provides API for building meshes.

Simple example with key steps

// add simple plane triangles
t.push_back({0_v,1_v,2_v}); // face #0
t.push_back({2_v,1_v,3_v}); // face #1
// make topology
auto topology = MR::MeshBuilder::fromTriangles(t);
void push_back(const T &t)
Definition MRVector.h:108
MRMESH_API MeshTopology fromTriangles(const Triangulation &t, const BuildSettings &settings={}, ProgressCallback progressCb={})
Warning
Vertices of triangles should have consistent bypass direction
Note
It is better to store topology directly in mesh
See also
MeshTopology

Function Documentation

◆ addTriangles() [1/2]

MRMESH_API void MR::MeshBuilder::addTriangles ( MeshTopology & res,
const Triangulation & t,
const BuildSettings & settings = {} )

◆ addTriangles() [2/2]

MRMESH_API void MR::MeshBuilder::addTriangles ( MeshTopology & res,
std::vector< VertId > & vertTriples,
FaceBitSet * createdFaces = nullptr )

◆ duplicateNonManifoldVertices()

MRMESH_API size_t MR::MeshBuilder::duplicateNonManifoldVertices ( Triangulation & t,
FaceBitSet * region = nullptr,
std::vector< VertDuplication > * dups = nullptr )

◆ fromDisjointMeshPieces()

MRMESH_API MeshTopology MR::MeshBuilder::fromDisjointMeshPieces ( const Triangulation & t,
VertId maxVertId,
const std::vector< MeshPiece > & pieces,
const BuildSettings & settings = {} )

◆ fromFaceSoup()

MRMESH_API MeshTopology MR::MeshBuilder::fromFaceSoup ( const std::vector< VertId > & verts,
const Vector< VertSpan, FaceId > & faces,
const BuildSettings & settings = {},
ProgressCallback progressCb = {} )

construct mesh topology from face soup, where each face can have arbitrary degree (not only triangles)

◆ fromPointTriples()

MRMESH_API Mesh MR::MeshBuilder::fromPointTriples ( const std::vector< Triangle3f > & posTriples)

◆ fromTriangles()

MRMESH_API MeshTopology MR::MeshBuilder::fromTriangles ( const Triangulation & t,
const BuildSettings & settings = {},
ProgressCallback progressCb = {} )

construct mesh topology from a set of triangles with given ids; if skippedTris is given then it receives all input triangles not added in the resulting topology

◆ fromTrianglesDuplicatingNonManifoldVertices()

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

◆ uniteCloseVertices()

MRMESH_API int MR::MeshBuilder::uniteCloseVertices ( Mesh & mesh,
float closeDist,
bool uniteOnlyBd = true,
VertMap * optionalVertOldToNew = nullptr )

the function finds groups of mesh vertices located closer to each other than

Parameters
closeDist,andunites such vertices in one; then the mesh is rebuilt from the remaining triangles
optionalVertOldToNewis the mapping of vertices: before -> after
uniteOnlyBdif true then only boundary vertices can be united, all internal vertices (even close ones) will remain
Returns
the number of vertices united, 0 means no change in the mesh