MTK provides tools to generate polygonal meshes from B-Rep geometry. This is primarily used for visualization and basic geometric analysis such as bounding box computation, surface area approximation, or collision detection.
The ModelAlgo::MeshGenerator class is used to generate visualization meshes for an entire model, a subtree of a model element, or a particular B-Rep body/shape. By default, triangulation is recalculated every time Generate()
is called. To avoid regenerating existing meshes, set theEnforceGeneration
flag to false.
Meshing an entire model:
ModelAlgo::MeshGenerator generates triangulated meshes stored as ModelData::IndexedTriangleSet per B-Rep faces (ModelData::Face ). These meshes are optimized for rendering and simple computations, but are not suitable for simulation or FEA, as the triangles may be elongated or irregular.
Mesh quality can be controlled using ModelAlgo::MeshGeneratorParameters :
Finer precision results in more detailed meshes at the cost of increased computation time and memory usage. Default values are usually sufficient for most use cases.
The following images demonstrate coarser and finer meshes generated for the same B-Rep shape:
![]()
Mesh built with coarser precision | ![]()
Mesh built with finer precision |
The meshing algorithm supports Progress Status Support, including cancellation. The example below demonstrates how to add observers to a progress status object:
For details refer to Progress Status Support.