How to get vertices coordinates of each triangulated face of a shape

Hello,

I tried getting feedback from another question I posted here, but I think it was with a wrong approach, and therefore I'm asking it in a different way:

For an application that I'm developing, I need to get the coordinates of all three vertices of each triangulated face of a shape. The steps that i'm taking so far to retrieve each part are:

1. Create document with TDocStd_Document;
2. Get shapeTool and colorTool via XCAFDoc_DocumentTool.ShapeTool and XCAFDoc_DocumentTool.ColorTool, respectively;
3. Read Step file with STEPCAFControl_Reader;
4. Browse through free shapes via TDF_LabelSequence and GetFreeShapes;
5. If part is simple shape -> get shape from respective label via GetShape(label).

In order to have a triangulation, I use BRepMesh_IncrementalMesh. But from here I'm very lost on where to go.

The output I need is a list of xyz (in global coordinates) values of each face of a shape.

I'll appreciate a lot if anyone could help me. I've cracking my head for weeks.

Thanks in advance.

Andreas Strauß's picture

PythonOcc comes with a ShapeTesellator class implemented in C++, this class takes a shape and provides different output formats for the mesh.
You can find it here:
https://github.com/tpaviot/pythonocc-core/tree/master/src/Tesselator

Hope it helps,
Andreas

Dmitrii Pasukhin's picture

Hello.

You need to find Handle(Poly_Triangulation)

For that you need to iterate for shape and extract that info. Could you please check the changes by that commit?

0033498: Data Exchange, Step Export - Meshed pretessellated geometry … · Open-Cascade-SAS/OCCT@ff15a5d (github.com)

Please do not forget about TopLoc_Location that you extract by extraction poly from Face

Best regards, Dmitrii.