Mesher Module
Triangular mesh generation and quality analysis.
LightOcct::LMesher
Light OCCT Incremental Mesh wrapper class.
Provides a clean interface to OCCT's BRepMesh_IncrementalMesh algorithm for generating triangular tessellations of TopoDS_Shape objects. Features: Enum + Handle pattern for OCCT BRepMesh_IncrementalMesh management POD parameter structures for cross-language compatibility Comprehensive mesh statistics and quality analysis Optional XCAF document integration for assembly meshes Error handling and result reporting The mesher operates on objects and generates triangulations that are stored within the shape's internal data structure, accessible via wrappers. LShape LTriangulation Example usage: //Createshapeandmesher auto shape=LShape::CreateBox(Point(0,0,0),Point(10,10,10)); auto mesher=(); LMesher::CreateIncMesh //Setparameters IncrementalMeshParamsparams(0.1,0.5); //linearandangulardeflection params.InParallel= true ; params.InternalVerticesMode= true ; //Generatemesh MeshResultInforesult=mesher.GenerateMesh(shape,params); if (result.Result==){ MESHER_SUCCESS std::cout<< "Generated" <<result.Statistics.TotalTriangles<< "triangles" <<std::endl; }
#include <light-occt/mesher/LMesher.hxx>Quick Reference
Fields: myType
Factory Methods: CreateIncMesh(), CreateIncMesh(), ValidateParameters(), SuggestParameters(), EstimateTriangleCount()
Methods: GetType(), IsValid(), GenerateMesh(), GenerateMesh(), SetParameters(), GetParameters(), ResetParameters(), AnalyzeMeshQuality(), GetMeshStatistics(), HasMesh(), ClearMesh(), LMesher(), ~LMesher(), LMesher(), operator=()
Enums: MesherType
Fields
myType
MesherType myType;Methods
Factory Methods
CreateIncMesh
Create an incremental mesh generator with default parameters.
static LMesher CreateIncMesh();instance configured for incremental meshing LMesher
CreateIncMesh
Create an incremental mesh generator with specified parameters.
static LMesher CreateIncMesh(const & IncrementalMeshParams params);params Mesh generation parameters instance configured with given parameters LMesher
Parameters:
params- Mesh generation parameters instance configured with given parameters LMesher
ValidateParameters
Validate meshing parameters.
static bool ValidateParameters(const & IncrementalMeshParams params);Checks parameter values for validity and consistency. params Parameters to validate True if parameters are valid for meshing
Parameters:
params- Parameters to validate True if parameters are valid for meshing
SuggestParameters
Suggest optimal parameters for a given shape.
static IncrementalMeshParams SuggestParameters(const & LShape shape, int targetTriangleCount);Analyzes shape characteristics and suggests appropriate meshing parameters based on shape size, complexity, and feature size. shape Shape to analyze for parameter suggestion targetTriangleCount Approximate desired triangle count (0 for automatic) optimized for the input shape IncrementalMeshParams
Parameters:
shape- characteristics and suggests appropriate meshing parameters based on shape size, complexity, and feature size.targetTriangleCount- Approximate desired triangle count (0 for automatic) optimized for the input shape IncrementalMeshParams
EstimateTriangleCount
Estimate triangle count for given parameters.
static int EstimateTriangleCount(const & LShape shape, const & IncrementalMeshParams params);Provides an approximate triangle count estimate without performing actual meshing. Useful for parameter tuning and memory planning. shape Shape to estimate mesh size for params Proposed meshing parameters Estimated triangle count
Parameters:
shape- Shape to estimate mesh size for params Proposed meshing parameters Estimated triangle countparams- Proposed meshing parameters Estimated triangle count
Instance Methods
GetType
Get the mesher algorithm type.
MesherType GetType() const;Always returns MESHER_INCREMENTAL for this implementation
IsValid
Check if the mesher is valid and ready for use.
bool IsValid() const;True if mesher is properly initialized
GenerateMesh
Generate triangular mesh for a single shape.
MeshResultInfo GenerateMesh(& LShape shape, const & IncrementalMeshParams params) const;This is the primary mesh generation method. It applies the incremental meshing algorithm to the input shape and stores the resulting triangulation within the shape's internal data structure. shape Input shape to be meshed params Meshing parameters controlling quality and behavior containing result status, statistics, and timing MeshResultInfo
Parameters:
shape- and stores the resulting triangulation within the shape's internal data structure.params- Meshing parameters controlling quality and behavior containing result status, statistics, and timing MeshResultInfo
GenerateMesh
Generate mesh using current internal parameters.
MeshResultInfo GenerateMesh(& LShape shape) const;Uses parameters set during construction or via . SetParameters() shape Input shape to be meshed containing result status and statistics MeshResultInfo
Parameters:
shape- Input shape to be meshed containing result status and statistics MeshResultInfo
SetParameters
Set meshing parameters for subsequent operations.
void SetParameters(const & IncrementalMeshParams params) const;params New meshing parameters
Parameters:
params- New meshing parameters
GetParameters
Get current meshing parameters.
IncrementalMeshParams GetParameters() const;Current being used IncrementalMeshParams
ResetParameters
Reset parameters to default values.
void ResetParameters() const;AnalyzeMeshQuality
Analyze mesh quality for a specific shape.
MeshStatistics AnalyzeMeshQuality(const & LShape shape) const;Computes quality metrics for all triangles in the shape's mesh. Shape must already be meshed via . GenerateMesh() shape Shape with existing triangulation to analyze containing quality analysis results MeshStatistics
GetMeshStatistics
Get basic mesh statistics for a shape.
MeshStatistics GetMeshStatistics(const & LShape shape) const;Returns triangle and node counts without detailed quality analysis. Faster than for simple queries. AnalyzeMeshQuality() shape Shape with existing triangulation with basic count information MeshStatistics
Parameters:
shape- Shape with existing triangulation with basic count information MeshStatistics
HasMesh
Check if a shape has been successfully meshed.
bool HasMesh(const & LShape shape) const;shape Shape to check for mesh data True if shape contains triangulation data
Parameters:
shape- Shape to check for mesh data True if shape contains triangulation data
ClearMesh
Clear mesh data from a shape.
void ClearMesh(& LShape shape) const;Removes all triangulation data from the shape, freeing memory. Shape geometric data is preserved. shape Shape to clear mesh data from
Parameters:
shape- freeing memory.
LMesher
Default constructor - creates undefined mesher. Use factory methods for proper initialization. CreateIncMesh()
LMesher() const;~LMesher
Destructor - automatically releases OCCT resources.
~LMesher() const;LMesher
Copy constructor - creates independent copy.
LMesher(const & LMesher other) const;other Source mesher to copy from
Parameters:
other- Source mesher to copy from
operator=
Assignment operator - creates independent copy.
& LMesher operator=(const & LMesher other) const;other Source mesher to copy from Reference to this mesher
Parameters:
other- Source mesher to copy from Reference to this mesher
Enumerations
MesherType
Mesher type enumeration for this class. Always returns MESHER_INCREMENTAL for this implementation.
enum MesherType {
MESHER_INCREMENTAL, // OCCT BRepMesh_IncrementalMesh algorithm.
MESHER_UNDEFINED, // Invalid/undefined mesher type.
};