
Sun, 09/03/2023 - 17:04
Hi,
I want to load a solid from a step file, mesh/triangulate the shape and then I want to have the points of every triangle of this (surface) mesh.
I searched in the forum how to do this. I saw hints to use BRepMesh_IncrementalMesh or BRepMesh_FastDiscret, but it is not clear how to use it properly.
What I tried (with the help of OCCutils): I load the step file, I call BRepMesh_IncrementalMesh, I read all face and then all vertices of the single face
auto shape = reader.Shape(1);
BRepTools::Clean(shape);
BRepMesh_IncrementalMesh mesher(shape, 0.2);
for (auto& face : occutils::shape_components::AllFacesWithin(shape))
{
auto vertices = occutils::shape_components::AllVertexCoordinatesWithin(face);
}
If the mesher would have triangulated the soild, then every face in it should have 3 vertices. But the above small examploe doesn't work. I got much more vertices. So my thoughts seems to be wrong, obviously.
I also read about BRep_Tool::Triangulation. but I don't understand why I should use it. If BRepMesh_IncrementalMesh does the job, the solid should be triangulated anyway?!
So my question: how can I reach my goal? I need the triangles of the tesselated solid. The documentation of BRepMesh_IncrementalMesh is not really helpful. It doesn't really describe how it works.
Thanks and best regards
Pellaeon
Sun, 09/03/2023 - 23:55
BRepMesh_IncrementalMesh makes a new representation of each TopoDS_Face. After that, you have triangulation for each face in your shape. In order to get this representation, you need to get the result of BRep_Tool::Triangulation() of each face. I don't know what is the function occutils. It is not the part of OCCT.
Tue, 09/05/2023 - 23:15
OCCutils is a small 3rd party library to simplify some standard works in OCC (https://github.com/ulikoehler/OCCUtils). Quite handy for some tasks.
The documentation of BRepMesh_IncrementalMesh states "Builds the mesh of a shape with respect of their correctly triangulated parts.". But it doesn't triangulate the shape at all, as I understood you.
So what exactly is BRepMesh_IncrementalMesh doing when the result isn't the triangulated mesh?
Wed, 09/06/2023 - 00:38
It does indeed :)
TopoDS_Face is a complex object that can have several representations, as a surface (Geom_Surface) and as a triangulation (Poly_Triangulation). That triangulation contains all nodes and triangles built by BRepMesh_IncrementalMesh. And the method BRep_Tool::Triangulation() returns that triangulated representation. So, you need to explore your solid on faces, and for each face get triangulation, and get triangles from there. Triangle itself is not a TopoDS_Face, it is just a triple of nodes indices that are stored in the triangulation. I hope it became clearer for you now ;)
Wed, 09/06/2023 - 18:33
Yes! Thank you very much for the explanation!