MeshLib
 
Loading...
Searching...
No Matches
Stitching holes

Example of stitching holes (connect two holes with a cylinder)

#include <MRMesh/MRMesh.h>
int main()
{
// Load meshes
auto meshARes = MR::MeshLoad::fromAnySupportedFormat( "meshAwithHole.stl" );
auto meshBRes = MR::MeshLoad::fromAnySupportedFormat( "meshBwithHole.stl" );
// Unite meshes
MR::Mesh mesh = std::move( meshARes.value() );
mesh.addPart( meshBRes.value() );
// Find holes (expect that there are exactly 2 holes)
std::vector<MR::EdgeId> edges = mesh.topology.findHoleRepresentiveEdges();
if ( edges.size() != 2 )
return 1;
// Connect two holes
params.metric = MR::getUniversalMetric( mesh );
MR::buildCylinderBetweenTwoHoles( mesh, edges.front(), edges.back(), params );
// Save result
auto saveRes = MR::MeshSave::toAnySupportedFormat( mesh, "stitchedMesh.stl" );
return 0;
}
MRMESH_API std::vector< EdgeId > findHoleRepresentiveEdges() const
returns one edge with no valid left face for every boundary in the mesh
MRMESH_API FillHoleMetric getUniversalMetric(const Mesh &mesh)
MRMESH_API void buildCylinderBetweenTwoHoles(Mesh &mesh, EdgeId a, EdgeId b, const StitchHolesParams &params={})
Stitches two holes in Mesh .
MRMESH_API Expected< Mesh > fromAnySupportedFormat(const std::filesystem::path &file, const MeshLoadSettings &settings={})
detects the format from file extension and loads mesh from it
MRMESH_API VoidOrErrStr toAnySupportedFormat(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
detects the format from file extension and save mesh to it
Definition MRMesh/MRMesh.h:23
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
MeshTopology topology
Definition MRMesh/MRMesh.h:24
Parameters structure for MR::buildCylinderBetweenTwoHoles Structure has some options to control MR::b...
FillHoleMetric metric
Definition MRMesh/MRMeshFillHole.h:79