CAD Exchanger 3.9.0 (released In October 2020) featured a new add-on — 3D Model Simplifier — which includes algorithms for both mesh and B-Rep simplification. When the original 3D model contains an excessive level of details, it is important to remove unnecessary items.

In this blog post, we are going to review polygonal geometry simplification, while B-Rep cases exploration will come out in the next one.

## What is Mesh Decimation?

*61952 triangles → 10688 triangles → 5406 triangles*

3D Model Simplifier allows CAD Exchanger SDK users to get lighter 3D CAD models. Mesh simplification or mesh decimation lies in the reduction of triangles quantity while preserving the visual appearance of a polygonal representation. Depending on the original mesh complexity, the simplifier is able to reduce the triangle count by 100x or even more. The algorithm also maintains normal, vertex color and texture coordinate data, if there was any in an original file. You can get more details about the tool’s capabilities in our documentation.

Here is a simple example of how the mesh decimation can be applied:

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

The common result consists in the reduction of the memory footprint and performance boost. But depending on the use case and initial model representation, the effect may vary from intellectual property protection to more accurate FEA calculations.

## Mesh Decimation Use Cases

CAD software is now able to generate incredibly complex models that include the complete design of the object. However, one does not always need it to a full extent. Here are the most common cases when the need for decimation arises:

### Visualization

Within the ambit of AR/VR or photorealistic rendering, tiny details or invisible parts are often not required. When visualizing the product prototype for marketing purposes, the triangle count reduction is a trade-off between the computational cost and the persuasive power of a render. In the case of game development, decimation reduces the scene complexity and accelerates real-time rendering. Here is an example of VRML mesh model simplification.

*VRML format mesh decimation: 22732 triangles → 18354 triangles → 6990 triangles*

### IP (Intellectual Property) protection

In case you need to share the 3D model with a third party outside your organization, it may be undesirable to disclose all the engineering details. Removing sensitive elements with the help of model simplification solves the problem.

### Reverse engineering

In order to improve or recreate a product, its 3D replica may be created. But a 3D scanned model very often contains too many triangles and needs to be reduced to simplify further transmission and processing.

# Mesh Decimation Features

Depending on the application, the desirable decimation level may vary. How much must the number of polygons be reduced? What is the maximum allowed deviation from the original mesh? CAD Exchanger allows to make simplification a user-controlled process

### Customizable degree of simplification

The degree of simplification may be set as Low, Medium, and High, defining how many triangles are going to be removed from the model. Low means less aggressive mode (when fewer triangles can be removed) and High means more aggressive mode (when a greater amount of triangles can be removed).

*Low (46683 triangles) → Medium (13565 triangles) → High (4259 triangles)*

### User-defined deviation

You can also specify 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.

### Forced simplification

When visual quality is less important (e.g., for very coarse LODs) and you need to remove even more triangles, it may be useful to enforce simplification. This option may cause a violation of the model's connectedness (holes, significant changes to mesh boundaries, etc.) and thus is not recommended for meshes representing sheet geometry or those that were generated without ensuring closedness.

### Quality loss prevention

While simplifying the model, there is a risk to push it over the edge and to distort the appearance of the objects. To preserve visual quality the algorithm applies special heuristics to keep the trade-off between the quality and polygon count reduction. A particularly striking example of keeping major geometric features intact is processing the mesh generated from a B-Rep. In this case, it is crucial to secure the sharp edges, which largely determines the shape’s look.

# CAD Exchanger Mesh Simplifier Benefits

*1868 triangles → 960 triangles → 492 triangles*

The key Mesh Simplifier benefits include:

- Preserving visual quality even while aggressively reducing the polygon count.
- Preserving mesh attributes (vertex normals, vertex colors, UV texture coordinates).
- Seamless integration of the mesh decimation add-on with CAD Exchanger SDK. Thus, the algorithm works with all 20+ 3D formats available in CAD Exchanger without complex data preparation. Mesh decimation algorithm is available in C++, C#, and Java programming languages.
- The add-on is easy to use thanks to a clear and structured API.
- In case you need to create a customized app and make the best of the provided algorithms, there are parameters to tweak them to your liking.

## More examples

*36438 triangles → 3286 triangles*

*59012 triangles → 4440 triangles*

*1780 triangles → 694 triangles → 400 triangles*

*313040 triangles → 164176 triangles → 55390 triangles*

*3150 triangles → 910 triangles → 416 triangles*

*7212 triangles → 5542 triangles → 3198 triangles*

## What are the Limitations of the Mesh Decimation?

CAD Exchanger 3D Model Simplifier only works on the triangle sets and ignores the rest of the polygonal shapes (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. That’s why in most cases this limitation wouldn’t prevent achieving the objectives of the decimation.

The algorithm works on connected meshes (when the vertices are shared by the adjacent triangles). Completely disconnected meshes, such as those coming from STL will not be simplified at all. If you find that your meshes aren't being simplified, you can check the relation below as a simple heuristic for disconnected mesh:

*N vertices = 3N triangles*# Conclusion

CAD Exchanger 3D Model Simplifier helps to reduce geometry complexity in order to work with 3D models faster without losing meaningful information. It grapples with the challenges of visualization optimization, intellectual property protection, and FEA precision.

As soon as the add-on is integrated into CAD Exchanger SDK, it is beneficial not only function-wise, but also in terms of usability. The algorithms work with CAD Exchanger data types, avoiding complex data preparation, and support all programming languages provided by CAD Exchanger (C++, C#, and Java).

If you are interested in trying the 3D Model Simplifier add-on, request CAD Exchanger 30-days trial version at our website. In case you currently use CAD Exchanger, please check the model simplification example in the ${install_dir}/examples subdirectory. You may insert its source code into your application and modify it as needed.