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

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.

Mesh Generator Overview

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:

using namespace cadex;
ModelData::Model aModel = ...;
aMesher.Generate (aModel);
Generates a polygonal mesh for a B-Rep body.
Definition MeshGenerator.hxx:39
Provides MTK data model.
Definition Model.hxx:40
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

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 Generator Parameters

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

Progress Status Support

The meshing algorithm supports Progress Status Support, including cancellation. The example below demonstrates how to add observers to a progress status object:

using namespace cadex;
//MyObserver is a subclass of ProgressStatus::Observer
MyObserver anObserver (...); //must have greater lifetime than progress status
aStatus.Register (anObserver);
{
aMesher.ProgressStatus() = aStatus;
{
ProgressScope aScope (aStatus); //80%
aMesher.Generate (aModel);
}
}
Represents a node in a hierarchy of progress scopes.
Definition ProgressScope.hxx:35
Provides progress status and notification mechanism.
Definition ProgressStatus.hxx:32
void Register(Observer &theObserver, double theValueThreshold=0.1f, unsigned int theTimeThreshold=20U)
Adds an observer that will be notified when the progress status has changed.
Definition ProgressStatus.cxx:257

For details refer to Progress Status Support.