MeshLib
 
Loading...
Searching...
No Matches
Mesh offset

Example of mesh offset

#include <MRMesh/MRBox.h>
#include <MRMesh/MRMesh.h>
int main()
{
// Load mesh
// Setup parameters
params.voxelSize = mesh.computeBoundingBox().diagonal() * 5e-3f; // offset grid precision (algorithm is voxel based)
if ( !MR::findRightBoundary( mesh.topology ).empty() )
params.signDetectionMode = MR::SignDetectionMode::HoleWindingRule; // use if you have holes in mesh
// Make offset mesh
float offset = mesh.computeBoundingBox().diagonal() * 0.05f;
auto meshRes = MR::generalOffsetMesh( mesh, offset, params );
if ( !meshRes.has_value() )
{
// log meshRes.error()
return 1;
}
// Save result
MR::MeshSave::toAnySupportedFormat( *meshRes, "mesh_offset.stl" );
return 0;
}
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
@ HoleWindingRule
computes winding number generalization with support of holes in mesh, slower than WindingRule
MRMESH_API std::vector< EdgeLoop > findRightBoundary(const MeshTopology &topology, const FaceBitSet *region=nullptr)
MRMESH_API Expected< Mesh > generalOffsetMesh(const MeshPart &mp, float offset, const GeneralOffsetParameters &params)
Offsets mesh by converting it to voxels and back using one of three modes specified in the parameters...
float voxelSize
Definition MRMesh/MROffset.h:17
T diagonal() const
computes length from min to max
Definition MRMesh/MRBox.h:59
allows the user to select in the parameters which offset algorithm to call
Definition MRMesh/MROffset.h:98
Definition MRMesh/MRMesh.h:23
MRMESH_API Box3f computeBoundingBox(const AffineXf3f *toWorld=nullptr) const
MeshTopology topology
Definition MRMesh/MRMesh.h:24
SignDetectionMode signDetectionMode
determines the method to compute distance sign
Definition MRMesh/MROffset.h:29