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

This chapter represents documentation about mesh decimation. More...

Classes

struct  MR::DecimateSettings
 Parameters structure for MR::decimateMesh. More...
 
struct  MR::DecimateResult
 Results of MR::decimateMesh. More...
 
struct  MR::DecimatePolylineSettings< V >
 Parameters structure for MR::decimatePolyline. More...
 

Functions

MRMESH_API DecimateResult MR::decimateMesh (Mesh &mesh, const DecimateSettings &settings={})
 Collapse edges in mesh region according to the settings.
 
MRMESH_API QuadraticForm3f MR::computeFormAtVertex (const MeshPart &mp, VertId v, float stabilizer, bool angleWeigted, const UndirectedEdgeBitSet *creases=nullptr)
 Computes quadratic form at given vertex of the initial surface before decimation.
 
MRMESH_API Vector< QuadraticForm3f, VertId > MR::computeFormsAtVertices (const MeshPart &mp, float stabilizer, bool angleWeigted, const UndirectedEdgeBitSet *creases=nullptr)
 Computes quadratic forms at every vertex of mesh part before decimation.
 
MRMESH_API FaceBitSet MR::getSubdividePart (const FaceBitSet &valids, size_t subdivideParts, size_t myPart)
 returns given subdivision part of all valid faces; parallel threads shall be able to safely modify these bits because they do not share any block with other parts
 
MRMESH_API bool MR::resolveMeshDegenerations (Mesh &mesh, const ResolveMeshDegenSettings &settings={})
 Resolves degenerate triangles in given mesh.
 
MRMESH_API DecimatePolylineResult MR::decimatePolyline (Polyline2 &polyline, const DecimatePolylineSettings2 &settings={})
 Collapse edges in the polyline according to the settings.
 
MRMESH_API DecimatePolylineResult MR::decimateContour (Contour2f &contour, const DecimatePolylineSettings2 &settings={})
 Collapse edges in the contour according to the settings.
 

Detailed Description

This chapter represents documentation about mesh decimation.

Function Documentation

◆ computeFormAtVertex()

MRMESH_API QuadraticForm3f MR::computeFormAtVertex ( const MeshPart & mp,
VertId v,
float stabilizer,
bool angleWeigted,
const UndirectedEdgeBitSet * creases = nullptr )
nodiscard

Computes quadratic form at given vertex of the initial surface before decimation.

◆ computeFormsAtVertices()

MRMESH_API Vector< QuadraticForm3f, VertId > MR::computeFormsAtVertices ( const MeshPart & mp,
float stabilizer,
bool angleWeigted,
const UndirectedEdgeBitSet * creases = nullptr )
nodiscard

Computes quadratic forms at every vertex of mesh part before decimation.

◆ decimateContour()

MRMESH_API DecimatePolylineResult MR::decimateContour ( Contour2f & contour,
const DecimatePolylineSettings2 & settings = {} )

Collapse edges in the contour according to the settings.

◆ decimateMesh()

MRMESH_API DecimateResult MR::decimateMesh ( Mesh & mesh,
const DecimateSettings & settings = {} )

Collapse edges in mesh region according to the settings.

// Repack mesh optimally.
// It's not necessary but highly recommended to achieve the best performance in parallel processing
mesh.packOptimally();
// Setup decimate parameters
// Decimation stop thresholds, you may specify one or both
settings.maxDeletedFaces = 1000; // Number of faces to be deleted
settings.maxError = 0.05f; // Maximum error when decimation stops
// Number of parts to simultaneous processing, greatly improves performance by cost of minor quality loss.
// Recommended to set to the number of available CPU cores or more for the best performance
settings.subdivideParts = 64;
// Decimate mesh
MR::decimateMesh( mesh, settings );
Before
After

◆ decimatePolyline()

MRMESH_API DecimatePolylineResult MR::decimatePolyline ( Polyline2 & polyline,
const DecimatePolylineSettings2 & settings = {} )

Collapse edges in the polyline according to the settings.

◆ getSubdividePart()

MRMESH_API FaceBitSet MR::getSubdividePart ( const FaceBitSet & valids,
size_t subdivideParts,
size_t myPart )
nodiscard

returns given subdivision part of all valid faces; parallel threads shall be able to safely modify these bits because they do not share any block with other parts

◆ resolveMeshDegenerations()

MRMESH_API bool MR::resolveMeshDegenerations ( Mesh & mesh,
const ResolveMeshDegenSettings & settings = {} )

Resolves degenerate triangles in given mesh.

This function performs decimation, so it can affect topology

Returns
true if the mesh has been changed
See also
decimateMesh