Hide menu
Loading...
Searching...
No Matches
Mesh Decimation

Overview

Mesh decimation is a feature of Advanced Geometry Processing add-on that allows one to process the polygonal representations of the model to reduce their triangle count while maintaining the visual appearance. This process is also known as mesh simplification.

It is available both as a stand-alone tool and as a tool for ModelSimplifier_Simplifier which allows to include mesh decimation in the general process of model simplification.

Capabilities

The algorithm is based on the edge collapse approach with quadric error metric. This approach ensures the preservation of major geometric features of the mesh. E.g. when the mesh is produced from a B-Rep representation of a CAD file, sharp edges are arguably among the most important features. The example below illustrates their preservation after mesh decimation procedure.

In our tests on a range of models the tool achieves triangle count reduction of up to 70% on the majority of fine source meshes. On specific meshes with an abundance of triangles an even greater reduction can be achieved.

Mesh desimation preserves normal, vertex color and texture coordinate information if it was originally present in the mesh.

Scope of accepted geometries

It's important to note that CAD Exchanger's data model permits polygonal representations to have not only triangle sets, but also polyline sets and polypoint sets. Normally, polygonal representations consist mostly of the triangle sets and they provide by far the biggest impact on memory footprint and performance. Hence, this tool only works on the triangle sets and ignores the rest of the polygonal shapes.

API overview

ModelSimplifier_MeshSimplifier is the class that performs mesh decimation. It allows decimation of all the meshes in the ModelData_Model instance, which is useful for straightforward import-process-export workflows. Basic usage looks like this:

ModelData_Model aModel = /* fill model */;
ModelSimplifier_MeshSimplifierParameters aParams;
aParams.SetDegreeOfSimplification (ModelSimplifier_MeshSimplifierParameters::Medium);
ModelSimplifier_MeshSimplifier aSimplifier (aParams);
ModelData_Model aSimplifiedModel = aSimplifier.Perform (aModel);

A complete example of such workflow is available in the example section.

For more nuanced workflows an overload of ModelSimplifier_MeshSimplifier::Perform accepting ModelData_PolyRepresentation is available. Combining this overload with ModelData_Model::ElementVisitor enables implementation of a workflow where only specific portions of the model are decimated, or where different portions of the model are decimated with different settings. It's also possible to use the second overload in a scenario where there's no ModelData_Model instance at all - then ModelData_PolyRepresentation is used as a temporary storage for the source and target meshes which may come from and be subsequently converted to some custom format.

Additionally, for mesh decimation within the ModelSimplifier_Simplifier pipeline there's a ModelSimplifier_MeshSimplifierTool class. It's included into an instance of ModelSimplifier_Simplifier created with ModelSimplifier_SimplifierBuilder, and can also be instanced when assembling the pipeline manually.

Parameters

ModelSimplifier_MeshSimplifierParameters is the class that provides the ability to parameterize the mesh decimation process. It offers 2 modes of control:

  • Setting a preset DegreeOfSimplification. Similarly to the ModelAlgo_BRepMesherParameters::Granularity it has 3 values: Low, Medium and High. Unlike the mesher these preset values represent the aggressiveness of decimation (i.e. how many triangles are going to be removed from the model). Low means fewer triangles will be removed and High means more triangles will be removed.
  • Providing an exact value of deviation in millimeters. This value represents an upper limit on the distance between points on the original mesh and corresponding points on the resulting mesh. Larger value means that the resulting mesh can differ from the source one more and vice versa.

Forced decimation option allows the user to ignore certain mesh integrity checks to remove even more triangles. Those checks mostly relate to the preservation of the boundary for unclosed meshes (e.g. those representing sheet geometry or those that were generated without ensuring closedness). Enabling this option for such meshes is not advised in most cases, as the shape of the mesh will most likely be severely modified (especially with aggressive preset/deviation value). However, when visual quality is less important (e.g. for very coarse LODs) this option may be useful.

Limitations

Mesh decimation depends on meshes being connected, i.e. neighboring triangles sharing pairs of vertices. The fewer disjoint pieces there are in a triangle set, the better the decimation effectiveness. Completely disconnected meshes, such as those coming from STL will not be decimated at all. If you find that your meshes aren't being decimated, you can check the relation below as a simple heuristic for disconnected mesh:

\[ N_{vertices}=3N_{triangles} \]

Additional information