-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathMeshDecimate.dox.cpp
37 lines (29 loc) · 1.13 KB
/
MeshDecimate.dox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <MRMesh/MRMeshFwd.h>
#include <MRMesh/MRMeshLoad.h>
#include <MRMesh/MRMeshSave.h>
#include <MRMesh/MRMesh.h>
#include <MRMesh/MRMeshDecimate.h>
#include <MRMesh/MRBuffer.h>
int main()
{
// Load mesh
MR::Mesh mesh = *MR::MeshLoad::fromAnySupportedFormat( "mesh.stl" );
//! [0]
// Repack mesh optimally.
// It's not necessary but highly recommended to achieve the best performance in parallel processing
mesh.packOptimally();
// Setup decimate parameters
MR::DecimateSettings settings;
// 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 );
//! [0]
// Save result
MR::MeshSave::toAnySupportedFormat( mesh, "decimated_mesh.stl" );
return 0;
}