For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

BRepMesh_Incremental Mesh - Algorithm

David Neu's picture
Forums: 

Hi Forum,

i actually try to do some basic research. In other cad software there are some libraries which are doing the tesselation part. For example cad exchanger has the possibilty to use either Netgen or Mefisto to create the triangle mesh out of the CAD boundary representation.

Does someone know, which algorithm is used by the BRepMesh_IncrementalMesh function? I did only find this information page: https://www.opencascade.com/content/mesh-framework

Would be very happy for some more information!

Kirill's picture

Does someone know, which algorithm is used by the BRepMesh_IncrementalMesh function?

BRepMesh computes Delaunay's triangulation with the algorithm of Watson, see docs:
https://dev.opencascade.org/doc/refman/html/class_b_rep_mesh___delaun.ht...

Basically, it is incremental algorithm (hence, incremental in it's name), which splits triangles until result triangulation satisfies deflection criteria.
The mesh is suitable for visualization and for many algorithms with controlled precision:
https://www.opencascade.com/doc/occt-7.0.0/overview/html/occt_user_guide...

I did only find this information page: https://www.opencascade.com/content/mesh-framework

Mesh Framework (OMF) is dedicated component for working with mesh structures (like Boolean operations, modification, etc.), so it is unrelated to BRepMesh.
There is also Express Mesh component implementing different algorithm (producing more structured mesh with desired element size, and, optionally, quad-only mesh):
https://www.opencascade.com/content/express-mesh

has the possibilty to use either Netgen

Netgen is interesting library, but, unfortunately, looks incomplete - it is too slow, unstable (when tested on complex geometry imported from STEP)
and has different control parameters (so that it is difficult comparing it to BRepMesh or replacing it in existing algorithms).

David Neu's picture

Hi Kirill,

I came across another question about the meshing algorithms. Is it true that every meshed step solid is always a watertight mesh, because the step solid itstelf is watertight? Or do I have to do some postprocessing to be sure that it is watertight?

What be really nice if I can get another answer!

Kirill's picture

BRepMesh algorithm (and Express Mesh) takes into account closeness of the shell, so that generated triangulation should have no holes in valid case.
Based on this assumption, OCCT 3D Viewer automatically enables back face culling in this case, improving rendering performance and eliminating extra visual artifacts on boundaries.
Otherwise, enabling back-face culling for non-closed triangulation will produce visual artifacts where holes would take place.
You can also read description of my pull request to glTF specification about watertight mesh flag:
https://github.com/KhronosGroup/glTF/pull/922

So, in general, mesh generated by OCCT for valid closed shell can be considered watertight if meshing algorithm succeeded (e.g. there are no face with NULL triangulation).
But apart from this assumption, there is no guarantee that result triangulation is actually watertight - so if this property is critical for your algorithm to provide correct results, it might be better verifying watertightness.

Note that this considers only closeness of mesh for a given solid only - in general case (model consisting of multiple solids, overlapping solids) more sophisticated analysis/processing might be required.

David Neu's picture

Hi Kirill,

thanks for the reply. For now I did not recover any not watertight mesh, which was calculated by brep incremental mesh. But good to know that it in some cases can happen.

Because I am no expert in working with triangle meshes, can you give me a hint, how to check if a mesh is watertight. I actually know, what watertight means. Do I have to check if every triangle has at least two neighbouring triangles?

Kirill's picture

Sorry, I have expected that you know better about mesh properties important for your case.
I haven't wrote any watertight triangulation checks before.
Though it does not look like checking each triangle having >=2 neighbours is enough...
 

David Neu's picture

.

Kirill's picture

On each sub shape I did a triangulation using the BRepMesh function.

First of all, it is better calling BRepMesh for all shapes at once rather then calling it for each sub-shape, to ensure that shared parts will be tessellated in consistent way.
Another point is that BRep defines Solid as a set of Faces (TopoDS_Face), not necessarily one face - e.g. simple Box has 6 Faces.
Each Face has its own triangulation (Poly_Triangulation), which might be open - only aggregation of triangulations for all Faces within Solid can be considered as closed mesh.