XCAF - Getting GD&T in a visible form

Hi Team, I have been trying to get a visible representation of the GD&T data contained within a STEP(AP242) file by using XCAF
I am using the sample file 'nist_ctc_02_asme1_ap242-e2.stp' - attached in a .7z but also available from https://www.nist.gov/ctl/smart-connected-systems-division/smart-connected-manufacturing-systems-group/mbe-pmi-0

I can get the shape of the main 3D object, mesh it, and get the vertices and triangles. And I can see the GD&T information using the DimTol tool.. great!
But I'm quite stuck at the point of actually being able to see the labels. I have a screenshot attached from a different software that I am using as reference, so I know that the file contains the right information, but I'm hitting a wall here.

If someone knows how to get the tessellated presentation of the GD&T labels, that would be so wonderful. Thank you for your time!

Below I have pasted the C++ function I am using and the output when I run it:

C++

void testGDTFunction(const char* filePath) {
    Standard_CString sFilePath = Standard_CString(filePath);
    Handle(TDocStd_Document) document;

    // Setup app
    Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
    BinXCAFDrivers::DefineFormat(anApp);
    XmlXCAFDrivers::DefineFormat(anApp);
    anApp->NewDocument("BinXCAF", document);


    // Use reader to read file and transfer information (GD&T included) into document
    cout << "Reading " << sFilePath << "... " << endl;
    STEPCAFControl_Reader reader;
    try {
        reader.SetGDTMode(true);
        reader.ReadFile(sFilePath);
        reader.Transfer(document);
    }
    catch (exception ex) {
        cout << "Exception while reading file '" << sFilePath << "': " << ex.what() << endl;
    }


    // Let's just grab the first document node for now
    XCAFPrs_DocumentExplorer explorer(document, XCAFPrs_DocumentExplorerFlags_None);
    const XCAFPrs_DocumentNode& curDocNode = explorer.Current();


    // The shape tool gives us access to the incremental mesher so we can get the vertices, triangles and see our model
    Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
    TopoDS_Shape shape = shapeTool->GetShape(curDocNode.Label);


    // PROOF OF CONCEPT FOR VISIBLE 3D SHAPE
    if (!shape.IsNull()) {
        BRepMesh_IncrementalMesh mesher(shape, .1);
        mesher.Perform();

        Standard_Integer numFaces = 0;
        Standard_Integer numVertices = 0;
        Standard_Integer numTriangles = 0;
        for (TopExp_Explorer aExpFace(shape, TopAbs_FACE); aExpFace.More(); aExpFace.Next()) {
            numFaces++;
            TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());

            TopLoc_Location aLocation;
            Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation(aFace, aLocation);

            if (!aTr.IsNull()) {
                Standard_Integer vertexCount = aTr->NbNodes();
                numVertices += vertexCount;

                Standard_Integer triangleCount = aTr->NbTriangles();
                numTriangles += triangleCount;
            }
        }
        cout << "Face Count: " << numFaces << ", Vertex Count: " << numVertices << ", Triangle Count: " << numTriangles << endl;
    }
    cout << endl;


    //         -- Not complete --
    // PROOF OF CONCEPT FOR VISIBLE GD&T
    // Get the DimTol (GD&T) list from the document
    Handle(XCAFDoc_DimTolTool) dimTolTool = XCAFDoc_DocumentTool::DimTolTool(document->Main());

    cout << "Dimension List:" << endl;
    TDF_LabelSequence dimSeq;
    dimTolTool->GetDimensionLabels(dimSeq);
    for (Standard_Integer idx = dimSeq.Lower(); idx < dimSeq.Upper(); idx++) {
        TDF_Label lab = dimSeq.Value(idx);

        OutputLabelInfo(lab);
        cout << endl;

        Handle(XCAFDoc_Dimension) dim;
        if (lab.FindAttribute(XCAFDoc_Dimension::GetID(), dim)) {
            Handle(XCAFDimTolObjects_DimensionObject) dimObj = dim->GetObject();
            cout << "         [Presentation Name]: " << dimObj->GetPresentationName()->ToCString() << endl;
            cout << "         [Semantic Name]: " << dimObj->GetSemanticName()->ToCString() << endl;
            cout << "         [Type]: " << GetDimTolDimTypeFromEnum(dimObj->GetType()) << endl;
            cout << "         [Ref count]: " << dimObj->GetRefCount() << endl;
            if (dimObj->IsDimWithRange()) { cout << ", [Range]: " << dimObj->GetLowerBound() << ", " << dimObj->GetUpperBound(); }
            else if (dimObj->IsDimWithPlusMinusTolerance()) {
                auto one = dimObj->GetValues();
                auto two = dimObj->GetLowerTolValue();
                auto thr = dimObj->GetUpperTolValue();
                cout << "         [+/- Tolerance]: " << dimObj->GetValue() << ", " << dimObj->GetLowerTolValue() << "-" << dimObj->GetUpperTolValue() << endl;
            }
            else if (dimObj->IsDimWithClassOfTolerance()) { cout << ", Has Class of Tolerance (not displaying)"; }
            else { cout << "         [Value]: " << dimObj->GetValue(); }


            TopoDS_Shape presentationShape = dimObj->GetPresentation();
            BRepMesh_IncrementalMesh mesher(presentationShape, .01);
            mesher.Perform();
            Standard_Integer numFaces = 0;
            Standard_Integer numVertices = 0;
            Standard_Integer numTriangles = 0;
            for (TopExp_Explorer aExpFace(presentationShape, TopAbs_FACE); aExpFace.More(); aExpFace.Next()) {
                numFaces++;
                TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());

                TopLoc_Location aLocation;
                Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation(aFace, aLocation);

                if (!aTr.IsNull()) {
                    Standard_Integer vertexCount = aTr->NbNodes();
                    numVertices += vertexCount;

                    Standard_Integer triangleCount = aTr->NbTriangles();
                    numTriangles += triangleCount;
                }
            }
            cout << "         Face Count: " << numFaces << ", Vertex Count: " << numVertices << ", Triangle Count: " << numTriangles << endl;
        }
        cout << endl;
    }
}  

And the output. Notice the Face Count, Vertex Count, and Triangle Count of each dimension is 0:

Reading C:\data_path\nist_ctc_02_asme1_ap242-e2.stp...
Face Count: 637, Vertex Count: 33841, Triangle Count: 43920

Dimension List:
    Name: diameter, Entry ID: 0:1:4:110, Tag: 110
         [Presentation Name]: Linear Size.1
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 100, 0.15-0.15
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:111, Tag: 111
         [Presentation Name]: Linear Size.2
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 52, 0.15-0.15
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:112, Tag: 112
         [Presentation Name]: Linear Size.4
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 12, 0.05-0.05
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:113, Tag: 113
         [Presentation Name]: Linear Size.5
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 12, 0.05-0.05
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:114, Tag: 114
         [Presentation Name]: Linear Size.6
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 22, 0.1-0.1
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:115, Tag: 115
         [Presentation Name]: Linear Size.7
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 22, 0.1-0.1
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: diameter, Entry ID: 0:1:4:116, Tag: 116
         [Presentation Name]: Linear Size.3
         [Semantic Name]: diameter
         [Type]: Size_Diameter
         [Ref count]: 1
         [+/- Tolerance]: 40, 0.15-0.15
         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:117, Tag: 117
         [Presentation Name]: Simple Datum.7
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:118, Tag: 118
         [Presentation Name]: Simple Datum.8
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:119, Tag: 119
         [Presentation Name]: Simple Datum.10
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:120, Tag: 120
         [Presentation Name]: Simple Datum.11
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:121, Tag: 121
         [Presentation Name]: Text.2
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

    Name: DGT:Dimension, Entry ID: 0:1:4:122, Tag: 122
         [Presentation Name]: Simple Datum.5
         [Semantic Name]: DGT:Dimension
         [Type]: DimensionPresentation
         [Ref count]: 1
         [Value]: 0         Face Count: 0, Vertex Count: 0, Triangle Count: 0

Elapsed time: 14.5541 seconds
Dmitrii Pasukhin's picture

Hello,

If STEP file contains pre-tessellated representation of PMI - you be able to exctract them by XCAFDoc_DimTolTool::GetGDTPresentations(...). It method exctract shapes from PMI and bind with label. This type of PMI is not editable. For getting semantic(+AIS) PMI presentation you can buy PMIVis commercial component (PMI Visualization Component | PMI software (opencascade.com))

Best regards, Dmitrii.

王 冕's picture

Hi,Dimtrii.
When you say "It method exctract shapes from PMI and bind with label ",did you mean that this method is used to extract graphic PMI presentations?
I`ve tried to exctract PMI by these functions below
Handle(XCAFDoc_DimTolTool) gdtTool = XCAFDoc_DocumentTool::DimTolTool(doc->Main());
TDF_LabelSequence labels_datums, label_geoms, label_dims, label_dimTols;
gdtTool->GetDatumLabels(labels_datums);
gdtTool->GetDimensionLabels(label_dims);
gdtTool->GetGeomToleranceLabels(label_geoms);
I just got some label_dims from my stp file,and I`ve atached the screenshot below.
Then, I get the types of those label_dims, the types turns out to be of XCAFDimTolObjects_DimensionType_CommonLabel and XCAFDimTolObjects_DimensionType_DimensionPresentation.
Disappointingly,I got no numerical values by methods like GetLowerBound() or GetValue().Would you give me a hand please?
Best regards,Ji.

Aaron Lau's picture

Thank you Dmitrii for your time, I've tried the approach you suggested

XCAFDoc_DimTolTool::GetGDTPresentations(...)

in the following code:

    cout << "Dimension Presentation List:" << endl;
    NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher> theGDTLabelToShape;
    dimTolTool->GetGDTPresentations(theGDTLabelToShape);

    NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>::Iterator iterator(theGDTLabelToShape);
    while (iterator.More())
    {
        TopoDS_Shape aShape = iterator.ChangeValue();
        Standard_Integer numFaces = 0;
        Standard_Integer numVertices = 0;
        Standard_Integer numTriangles = 0;
        for (TopExp_Explorer aExpFace(aShape, TopAbs_FACE); aExpFace.More(); aExpFace.Next()) {
            numFaces++;
            TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());

            TopLoc_Location aLocation;
            Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation(aFace, aLocation);

            if (!aTr.IsNull()) {
                Standard_Integer vertexCount = aTr->NbNodes();
                numVertices += vertexCount;

                Standard_Integer triangleCount = aTr->NbTriangles();
                numTriangles += triangleCount;
            }
        }
        cout << "         Face Count: " << numFaces << ", Vertex Count: " << numVertices << ", Triangle Count: " << numTriangles << endl;
        iterator.Next();

I think I am getting stuck on the part where I need to extract the vertices and triangles out from the shape. Is there a way to do this? Thank you again

Dmitrii Pasukhin's picture

Why you try to extract this?

There only wires (poly_polylines)

Best regards, Dmitrii.

Aaron Lau's picture

The overall project is to create a plugin for Unity

I am triangulating everything and then marshalling it over to C#. I have the BRep data working well already. I just need to get the GD&T information, which appears to already be tessellated but I don't know how to access it

Dmitrii Pasukhin's picture

TopExp_Explorer aExpFace(aShape, TopAbs_EDGE) could help you, there no faces.

Best regards, Dmitrii.

Aaron Lau's picture

Sorry, I think I'm a little confused

In the STEP file, I have tracked the GD&T down to a couple of entities:

#672=COMPLEX_TRIANGULATED_SURFACE_SET('diameter dimension',#744,226,((1.,0.,0.)),(),(),((1,2,3),(1,3,4),(1,4,5),(1,5,6),(1,6,7),(1,7,8),(9,4,3),(9,3,10),(11,12,13),(11,13,14),(11,14,15),(11,15,16),(17,18,15),(15,18,19),(15,19,16),(16,19,20),(16,20,21),(22,23,24),(24,23,25),(24,25,26),(26,25,17),(26,17,15),(27,28,29),(27,29,30),(27,30,22),(27,22,24),(28,31,32),(28,32,33),(28,33,34),(28,34,29),(35,16,21),...
#744=COORDINATES_LIST('diameter dimension',226,((-622.278686523438,-78.116943359375,0.),(-622.278686523438,-85.5910034179688,0.),(-620.90185546875,-85.5910034179688,0.),(-622.203002929688,-75.9382629394531,0.),...

The GD&T is already triangulated, is it getting converted into edges? Maybe I'm not accessing the right structures? Here's what my code outputs for this particular dimension:

         [# Attribs] 5
         [Dimension] Linear Size.1
         Compound Count: 1
         Compsolid Count: 0
         Edge Count: 5
         Face Count: 0
         Shape Count: 0
         Shell Count: 0
         Solid Count: 0
         Vertex Count: 10
         Wire Count: 3

And here is my code if it helps:

cout << "Dimension Presentation List:" << endl;
    NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher> theGDTLabelToShape;
    dimTolTool->GetGDTPresentations(theGDTLabelToShape);

    NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>::Iterator iterator(theGDTLabelToShape);
    for (;iterator.More(); iterator.Next())
    {
        const TDF_Label& label = iterator.Key();
        const TopoDS_Shape& aShape = iterator.Value();
        cout << "         [# Attribs] " << label.NbAttributes() << endl;

        // Attribs
        Handle(XCAFDoc_Dimension) dimAttribute;
        if (label.FindAttribute(XCAFDoc_Dimension::GetID(), dimAttribute)) {
            cout << "         [Dimension] " << dimAttribute->GetObject()->GetPresentationName()->ToCString() << endl;
        }

        Handle(XCAFDoc_GeomTolerance) geomTolAttribute;
        if (label.FindAttribute(XCAFDoc_GeomTolerance::GetID(), geomTolAttribute)) {
            cout << "         [GeomTol] " << geomTolAttribute->GetObject()->GetPresentationName()->ToCString() << endl;
        }

        Handle(XCAFDoc_Datum) datumAttribute;
        if (label.FindAttribute(XCAFDoc_Datum::GetID(), datumAttribute)) {
            cout << "         [Datum] " << datumAttribute->GetObject()->GetPresentationName()->ToCString() << endl;
        }

        // TopExp Exploration
        Standard_Integer numCompounds = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_COMPOUND); exp.More(); exp.Next()) {
            numCompounds++;
        }
        cout << "         Compound Count: " << numCompounds << endl;

        Standard_Integer numCompSolids = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_COMPSOLID); exp.More(); exp.Next()) {
            numCompSolids++;
        }
        cout << "         Compsolid Count: " << numCompSolids << endl;

        Standard_Integer numEdges = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
            numEdges++;
        }
        cout << "         Edge Count: " << numEdges << endl;

        Standard_Integer numFaces = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
            numFaces++;
        }
        cout << "         Face Count: " << numFaces << endl;

        Standard_Integer numShapes = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_SHAPE); exp.More(); exp.Next()) {
            numShapes++;
        }
        cout << "         Shape Count: " << numShapes << endl;

        Standard_Integer numShells = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_SHELL); exp.More(); exp.Next()) {
            numShells++;
        }
        cout << "         Shell Count: " << numShells << endl;

        Standard_Integer numSolids = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_SOLID); exp.More(); exp.Next()) {
            numSolids++;
        }
        cout << "         Solid Count: " << numSolids << endl;

        Standard_Integer numVertices = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_VERTEX); exp.More(); exp.Next()) {
            numVertices++;
        }
        cout << "         Vertex Count: " << numVertices << endl;

        Standard_Integer numWires = 0;
        for (TopExp_Explorer exp(aShape, TopAbs_WIRE); exp.More(); exp.Next()) {
            numWires++;
        }
        cout << "         Wire Count: " << numWires << endl;
        cout << endl << endl;
    }
Dmitrii Pasukhin's picture

[# Attribs] 5 [Dimension] Linear Size.1 Compound Count: 1 Compsolid Count: 0 Edge Count: 5 Face Count: 0 Shape Count: 0 Shell Count: 0 Solid Count: 0 Vertex Count: 10 Wire Count: 3

Looks correct. Whats wrong? Wires with edges. It is correct and valid.

Best regards, Dmtrii.

Aaron Lau's picture

I am stuck at the part where I can turn those edges into visible 3D information
The dimension should look like this:

I don't think 10 vertices and 5 edges is enough to capture this geometry. And in the STEP file, the dimension is pre-tessellated and contains hundreds of vertices

Dmitrii Pasukhin's picture

You are free to visualize them using DRAW. They are just a TopoDS_Shape.

edge - poly_polylines. That means that they are complex lines.

Best regards, Dmitrii.

Aaron Lau's picture

I am creating a plugin for Unity, and Unity is going to handle the drawing. But unfortunately, Unity needs triangles.

Is there any way to get the pre-tessellated information?

#672=COMPLEX_TRIANGULATED_SURFACE_SET('diameter dimension',#744,226,((1.,0.,0.)),(),(),((1,2,3),(1,3,4),(1,4,5),(1,5,6),(1,6,7),(1,7,8),(9,4,3),(9,3,10),(11,12,13),(11,13,14),(11,14,15),(11,15,16),(17,18,15),(15,18,19),(15,19,16),(16,19,20),(16,20,21),(22,23,24),(24,23,25),(24,25,26),(26,25,17),(26,17,15),(27,28,29),(27,29,30),(27,30,22),(27,22,24),(28,31,32),(28,32,33),(28,33,34),(28,34,29),(35,16,21),(35,21,36),(35,36,37),(35,37,38),(39,40,41),(39,41,38),(39,38,37),(33,32,41),(33,41,40),(31,42,43),(31,43,32),(44,45,46),(44,46,47),(44,47,48),(44,48,49),(50,51,48),(48,51,52),(48,52,49),(49,52,53),(49,53,54),(55,56,57),(57,56,58),(57,58,59),(59,58,50),(59,50,48),(60,61,62),(60,62,63),(60,63,55),(60,55,57),(61,64,65),(61,65,66),(61,66,67),(61,67,62),(68,49,54),(68,54,69),(68,69,70),(68,70,71),(72,73,74),(72,74,71),(72,71,70),(66,65,74),(66,74,73),(64,75,76),(64,76,65),(77,78,79),(77,79,80),(81,82,83),(83,82,84),(83,84,85),(85,84,86),(85,86,87),(88,89,90),(88,90,81),(88,81,83),(90,89,91),(83,85,92),(93,94,95),(93,95,96),(93,96,97),(93,97,98),(99,100,97),(97,100,101),(97,101,98),(98,101,102),(98,102,103),(104,105,106),(106,105,107),(106,107,108),(108,107,99),(108,99,97),(109,110,111),(109,111,112),(109,112,104),(109,104,106),(110,113,114),(110,114,115),(110,115,116),(110,116,111),(117,98,103),(117,103,118),(117,118,119),(117,119,120),(121,122,123),(121,123,120),(121,120,119),(115,114,123),(115,123,122),(113,124,125),(113,125,114),(126,127,128),(126,128,129),(130,131,132),(130,132,133),(130,133,134),(130,134,135),(130,135,136),(130,136,137),(138,133,132),(138,132,139),(140,141,142),(142,141,143),(142,143,144),(144,143,145),(144,145,146),(147,148,149),(149,148,150),(149,150,151),(151,150,152),(151,152,153),(144,146,154),(154,146,155),(154,155,156),(156,155,157),(156,157,158),(158,157,159),(158,159,150),(150,159,160),(150,160,152),(161,162,163),(163,162,164),(163,164,165),(165,164,151),(165,151,153),(166,167,168),(166,168,162),(166,162,161),(169,170,171),(171,170,168),(171,168,172),(172,168,167),(169,171,173),(145,143,174),(175,176,177),(177,176,178),(177,178,179),(179,178,180),(179,180,181),(182,183,184),(184,183,185),(184,185,186),(186,185,187),(186,187,177),(177,187,188),(177,188,175),(189,190,191),(189,191,192),(189,192,182),(189,182,184),(190,193,194),(190,194,195),(190,195,191),(196,197,194),(196,194,193),(175,198,176),(176,198,199),(176,199,200),(200,199,201),(200,201,202),(203,204,205),(205,204,206),(205,206,207),(207,206,208),(207,208,202),(202,208,200),(205,209,203),(203,209,210),(203,210,211),(211,210,212),(211,212,213),(203,211,214),(215,216,217),(215,217,218),(215,218,219),(215,219,220),(221,222,223),(223,222,224),(223,224,218),(218,224,219),(225,226,223),(225,223,218)));
#744=COORDINATES_LIST('diameter dimension',226,((-622.278686523438,-78.116943359375,0.),(-622.278686523438,-85.5910034179688,0.),(-620.90185546875,-85.5910034179688,0.),(-622.203002929688,-75.9382629394531,0.),(-622.747680664063,-76.5585861206055,0.),(-623.579833984375,-76.9216918945313,0.),(-624.729675292969,-77.0427322387695,0.),(-624.729675292969,-78.116943359375,0.),(-621.9306640625,-75.0153579711914,0.),(-620.90185546875,-75.0153579711914,0.),(-607.409240722656,-82.83740234375,0.),(-607.167114257813,-80.462043762207,0.),(-607.409240722656,-78.101806640625,0.),(-607.696655273438,-77.1637725830078,0.),(-608.105163574219,-76.3921585083008,0.),(-608.105163574219,-84.5319290161133,0.),(-609.118835449219,-77.3150634765625,0.),(-608.740600585938,-78.63134765625,0.),(-608.619567871094,-80.462043762207,0.),(-608.740600585938,-82.307861328125,0.),(-609.118835449219,-83.6241455078125,0.),(-611.811950683594,-76.54345703125,0.),(-610.798278808594,-76.2711181640625,0.),(-610.798278808594,-75.0153579711914,0.),(-609.799682617188,-76.54345703125,0.),(-609.239929199219,-75.3633346557617,0.),(-612.371765136719,-75.3633346557617,0.),(-613.506469726563,-76.4072875976563,0.),(-612.871032714844,-78.63134765625,0.),(-612.492797851563,-77.3150634765625,0.),(-614.217590332031,-78.101806640625,0.),(-613.506469726563,-84.5319290161133,0.),(-612.871032714844,-82.307861328125,0.),(-612.992065429688,-80.462043762207,0.),(-609.239929199219,-85.5607452392578,0.),(-609.799682617188,-84.3957595825195,0.),(-610.798278808594,-84.652961730957,0.),(-610.798278808594,-85.8936004638672,0.),(-611.811950683594,-84.3957595825195,0.),(-612.492797851563,-83.6241455078125,0.),(-612.371765136719,-85.5607452392578,0.),(-614.444519042969,-80.462043762207,0.),(-614.217590332031,-82.83740234375,0.),(-596.201171875,-82.83740234375,0.),(-595.959045410156,-80.462043762207,0.),(-596.201171875,-78.101806640625,0.),(-596.488586425781,-77.1637725830078,0.),(-596.897094726563,-76.3921585083008,0.),(-596.897094726563,-84.5319290161133,0.),(-597.910766601563,-77.3150634765625,0.),(-597.532531738281,-78.63134765625,0.),(-597.411499023438,-80.462043762207,0.),(-597.532531738281,-82.307861328125,0.),(-597.910766601563,-83.6241455078125,0.),(-600.603881835938,-76.54345703125,0.),(-599.590209960938,-76.2711181640625,0.),(-599.590209960938,-75.0153579711914,0.),(-598.591613769531,-76.54345703125,0.),(-598.031860351563,-75.3633346557617,0.),(-601.163696289063,-75.3633346557617,0.),(-602.298400878906,-76.4072875976563,0.),(-601.662963867188,-78.63134765625,0.),(-601.284729003906,-77.3150634765625,0.),(-603.009521484375,-78.101806640625,0.),(-602.298400878906,-84.5319290161133,0.),(-601.662963867188,-82.307861328125,0.),(-601.783996582031,-80.462043762207,0.),(-598.031860351563,-85.5607452392578,0.),(-598.591613769531,-84.3957595825195,0.),(-599.590209960938,-84.652961730957,0.),(-599.590209960938,-85.8936004638672,0.),(-600.603881835938,-84.3957595825195,0.),(-601.284729003906,-83.6241455078125,0.),(-601.163696289063,-85.5607452392578,0.),(-603.236450195313,-80.462043762207,0.),(-603.009521484375,-82.83740234375,0.),(-587.707397460938,-83.3215484619141,0.),(-587.707397460938,-84.3655014038086,0.),(-580.672058105469,-84.3655014038086,0.),(-580.672058105469,-83.3215484619141,0.),(-583.667785644531,-76.0441741943359,0.),(-584.711730957031,-76.0441741943359,0.),(-583.667785644531,-82.2927322387695,0.),(-584.711730957031,-78.6464767456055,0.),(-584.711730957031,-79.6753005981445,0.),(-587.707397460938,-78.6464767456055,0.),(-587.707397460938,-79.6753005981445,0.),(-583.667785644531,-79.6753005981445,0.),(-580.672058105469,-79.6753005981445,0.),(-583.667785644531,-78.6464767456055,0.),(-580.672058105469,-78.6464767456055,0.),(-584.711730957031,-82.2927322387695,0.),(-569.585083007813,-82.83740234375,0.),(-569.342956542969,-80.462043762207,0.),(-569.585083007813,-78.101806640625,0.),(-569.872497558594,-77.1637725830078,0.),(-570.281005859375,-76.3921585083008,0.),(-570.281005859375,-84.5319290161133,0.),(-571.294677734375,-77.3150634765625,0.),(-570.916442871094,-78.63134765625,0.),(-570.79541015625,-80.462043762207,0.),(-570.916442871094,-82.307861328125,0.),(-571.294677734375,-83.6241455078125,0.),(-573.98779296875,-76.54345703125,0.),(-572.97412109375,-76.2711181640625,0.),(-572.97412109375,-75.0153579711914,0.),(-571.975524902344,-76.54345703125,0.),(-571.415771484375,-75.3633346557617,0.),(-574.547607421875,-75.3633346557617,0.),(-575.682312011719,-76.4072875976563,0.),(-575.046875,-78.63134765625,0.),(-574.668640136719,-77.3150634765625,0.),(-576.393432617188,-78.101806640625,0.),(-575.682312011719,-84.5319290161133,0.),(-575.046875,-82.307861328125,0.),(-575.167907714844,-80.462043762207,0.),(-571.415771484375,-85.5607452392578,0.),(-571.975524902344,-84.3957595825195,0.),(-572.97412109375,-84.652961730957,0.),(-572.97412109375,-85.8936004638672,0.),(-573.98779296875,-84.3957595825195,0.),(-574.668640136719,-83.6241455078125,0.),(-574.547607421875,-85.5607452392578,0.),(-576.620361328125,-80.462043762207,0.),(-576.393432617188,-82.83740234375,0.),(-562.809997558594,-85.5910034179688,0.),(-560.722106933594,-85.5910034179688,0.),(-560.722106933594,-83.3366775512695,0.),(-562.809997558594,-83.3366775512695,0.),(-550.830322265625,-78.116943359375,0.),(-550.830322265625,-85.5910034179688,0.),(-549.453491210938,-85.5910034179688,0.),(-550.754638671875,-75.9382629394531,0.),(-551.29931640625,-76.5585861206055,0.),(-552.131469726563,-76.9216918945313,0.),(-553.281311035156,-77.0427322387695,0.),(-553.281311035156,-78.116943359375,0.),(-550.482299804688,-75.0153579711914,0.),(-549.453491210938,-75.0153579711914,0.),(-536.354248046875,-76.5585861206055,0.),(-536.354248046875,-75.3179473876953,0.),(-540.95361328125,-76.5585861206055,0.),(-541.967346191406,-75.3179473876953,0.),(-541.377258300781,-79.3878326416016,0.),(-541.589111328125,-80.8856735229492,0.),(-540.711547851563,-80.1745758056641,0.),(-535.779296875,-82.1868286132813,0.),(-536.036499023438,-80.7797622680664,0.),(-536.066772460938,-83.6997909545898,0.),(-536.7626953125,-79.6753005981445,0.),(-536.8232421875,-84.8799057006836,0.),(-537.246887207031,-82.2624740600586,0.),(-537.413269042969,-83.2156448364258,0.),(-540.499755859375,-78.888557434082,0.),(-539.591979980469,-79.9173736572266,0.),(-539.365051269531,-78.7070007324219,0.),(-538.623657226563,-80.0838012695313,0.),(-537.8974609375,-78.9642028808594,0.),(-537.88232421875,-80.5679473876953,0.),(-537.413269042969,-81.3093032836914,0.),(-539.591979980469,-84.5924453735352,0.),(-539.546569824219,-85.8936004638672,0.),(-538.638793945313,-84.4260177612305,0.),(-538.018493652344,-85.6212615966797,0.),(-537.8974609375,-83.9570007324219,0.),(-540.393859863281,-84.4865341186523,0.),(-541.01416015625,-84.138557434082,0.),(-540.938537597656,-85.6666488647461,0.),(-542.769226074219,-84.0931625366211,0.),(-542.02783203125,-85.0614624023438,0.),(-541.695007324219,-82.8525314331055,0.),(-541.468078613281,-83.5938873291016,0.),(-543.10205078125,-82.8525314331055,0.),(-542.799438476563,-80.8856735229492,0.),(-673.594665527344,-78.1320724487305,0.),(-673.42822265625,-80.8100204467773,0.),(-673.125610351563,-75.8777465820313,0.),(-672.717102050781,-80.0535430908203,0.),(-672.41455078125,-76.8763046264648,0.),(-672.30859375,-79.160888671875,0.),(-672.157348632813,-78.1472015380859,0.),(-676.56005859375,-76.4375457763672,0.),(-675.697692871094,-76.2711181640625,0.),(-675.622009277344,-75.0153579711914,0.),(-674.820129394531,-76.4224166870117,0.),(-674.214965820313,-75.242301940918,0.),(-674.169555664063,-76.8006591796875,0.),(-673.745910644531,-77.3907165527344,0.),(-677.074462890625,-75.2725601196289,0.),(-678.178955078125,-75.9836578369141,0.),(-677.619140625,-77.6781768798828,0.),(-677.210632324219,-76.9216918945313,0.),(-678.890014648438,-77.1183776855469,0.),(-677.755310058594,-78.8280334472656,0.),(-677.755310058594,-78.7070007324219,0.),(-679.132080078125,-78.6162185668945,0.),(-679.132080078125,-78.8280334472656,0.),(-673.700561523438,-78.8280334472656,0.),(-673.988037109375,-79.4180908203125,0.),(-674.4267578125,-81.4606018066406,0.),(-674.47216796875,-79.932502746582,0.),(-675.137878417969,-80.3863906860352,0.),(-677.861206054688,-84.2898483276367,0.),(-677.543518066406,-83.5787582397461,0.),(-677.513244628906,-81.8085861206055,0.),(-676.998840332031,-82.9887008666992,0.),(-676.030517578125,-80.8705444335938,0.),(-675.319396972656,-81.9144897460938,0.),(-678.557189941406,-82.8071441650391,0.),(-679.177490234375,-84.0175170898438,0.),(-672.157348632813,-85.5910034179688,0.),(-679.374206542969,-85.5456161499023,0.),(-679.374206542969,-85.5910034179688,0.),(-672.157348632813,-84.2898483276367,0.),(-663.717956542969,-80.1897048950195,0.),(-660.601257324219,-75.0758743286133,0.),(-662.12939453125,-75.0758743286133,0.),(-664.444213867188,-78.9642028808594,0.),(-662.03857421875,-85.5910034179688,0.),(-660.434814453125,-85.5910034179688,0.),(-668.483825683594,-85.5910034179688,0.),(-666.895202636719,-85.5910034179688,0.),(-665.20068359375,-80.204833984375,0.),(-664.489624023438,-81.3395614624023,0.),(-666.713684082031,-75.0758743286133,0.),(-668.302307128906,-75.0758743286133,0.)));

Or is there a way to calculate the triangles from the shape?

Dmitrii Pasukhin's picture

TopoDS_Shape is a pre-tessellated presentation.

I'm a little confused. How you present PMI as a triangulation? It is not possible.

Red - TopoDS_Shapes as an Edge from your iteration. This file is public, you can share it.

Best regards, Dmitrii.

Aaron Lau's picture

I am using a third-party program called CADExchanger as a reference, here is a screenshot from CADExchanger

Perhaps we are talking about different things when we say 'pre-tessellated'?
I am thinking of PMI that is represented as triangles in the STEP file itself. In the screenshot, you can see that the '1' in '100' is distorted. This is because I changed some of the coordinates that form the triangles:

#744=COORDINATES_LIST('diameter dimension',226,((-624.278686523438,-78.116943359375,0.),(-620.278686523438,-85.5910034179688,0.),(-620.90185546875,-85.5910034179688,0.),(-622.203002929688,-75.9382629394531,0.),(-622.747680664063,-76.5585861206055,0.),(-623.579833984375,-76.9216918945313,0.),(-624.729675292969,-77.0427322387695,0.),(-624.729675292969,-78.116943359375,0.),(-621.9306640625,-75.0153579711914,0.),(-620.90185546875,-75.0153579711914,0.),(-607.409240722656,-82.83740234375,0.),(-607.167114257813,-80.462043762207,0.),(-607.409240722656,-78.101806640625,0.),(-607.696655273438,-77.1637725830078,0.),(-608.105163574219,-76.3921585083008,0.),(-608.105163574219,-84.5319290161133,0.),(-609.118835449219,-77.3150634765625,0.),(-608.740600585938,-78.63134765625,0.),(-608.619567871094,-80.462043762207,0.),(-608.740600585938,-82.307861328125,0.),(-609.118835449219,-83.6241455078125,0.)...

I was able to change the coordinates and distort the '1'

There is a lot of text here, so I'm confused too
How is the TopoDS_Shape containing all of this information in only 10 vertices, 5 edges, and 3 wires?

Dimension Presentation List:
         [# Attribs] 5
         [Dimension] Linear Size.1
         Compound Count: 1
         Compsolid Count: 0
         Edge Count: 5
         Face Count: 0
         Shape Count: 0
         Shell Count: 0
         Solid Count: 0
         Vertex Count: 10
         Wire Count: 3
Aaron Lau's picture

Bumping this:

I've been trying to use the BRep_Tool class and the BRep_Tools class to try and get some geometric data from the edges, vertices, and wires. Not much luck so far. What is the correct approach to turn the edges, vertices, and wires into geometric information that can be visualized?

Dmitrii Pasukhin's picture

You need to handle type of Handle(Geom_Curve) checking ->IsKind(STANDARD_TYPE(Geom_Circle)) and then DownCast and getting data.

Or other option - convert curves to BSlines, and getting only BSpline. But probable the most part of edges contains only Geom_Lines or something simple.

Best regards, Dmitrii.

Aaron Lau's picture

When you say convert curves to BSplines, are you referring to the Edges? What are Wires?