I'm trying to read GD&T entities from a STEP file using the standard StepControl_Reader in OpenCascade. The file that I'm trying to read the GD&T information from conforms to the AP242 standard, although I believe that most of the things that I'm trying to extract from the file are actually from AP214 (e.g. geometric tolerances with datum ref.)
I'm able to load the file successfully, but the STEP reader complains about "unknown entities" and I'm unable to read the GD&T entities after I've loaded the file. The strange thing is that if I poke around in Interface_FileReaderTool::LoadModel, I can see instances of e.g. StepDimTol_GeoTolAndGeoTolWthDatRef being created, but I'm unable to recover them later after that function is done doing its thing.
Here is the code that I'm using, it's just cobbled together from some similar code that I found somewhere. Does anyone know what else I should be doing to read GD&T entities from STEP files?
auto reader_success = occt_read_CAD(stepreader, path, progress_callback); // reads file, transfers roots...
// Read GD&T / PMI information from file, spam on console (testing)
handle<XSControl_WorkSession> ws = stepreader.WS();
handle<XSControl_TransferReader> tr = ws->TransferReader();
handle<Transfer_TransientProcess> tp = tr->TransientProcess();
handle<Interface_InterfaceModel> model = ws->Model();
Standard_Integer num_entities = model->NbEntities();
const Interface_Graph & graph = tp->Graph();
for (Standard_Integer i = 1 ; i <= num_entities ; i++)
handle<Standard_Transient> entity = model->Value(i);
auto shape_aspect = handle<StepRepr_ShapeAspect>::DownCast(entity);
// Find representation item for current shape aspect
Interface_EntityIterator ei = graph.Sharings(shape_aspect);
for (ei.Start() ; ei.More() && prop_def.IsNull() ; ei.Next())
prop_def = handle<StepRepr_PropertyDefinition>::DownCast(ei.Value());
Interface_EntityIterator prop_def_ei = graph.Sharings(prop_def);
for (prop_def_ei.Start() ; prop_def_ei.More() ; prop_def_ei.Next())
auto shape_def_repr = handle<StepShape_ShapeDefinitionRepresentation>::DownCast(prop_def_ei.Value());
handle<StepRepr_Representation> repr = shape_def_repr->UsedRepresentation();
if (!repr.IsNull() && repr->NbItems() > 0)
ri = repr->ItemsValue(1); // break?
// Read DG&T entities
ei = graph.Sharings(shape_aspect);
for (ei.Start() ; ei.More() ; ei.Next())
auto gtol = handle<StepDimTol_GeometricTolerance>::DownCast(ei.Value());
handle<StepBasic_MeasureWithUnit> magnitude = gtol->Magnitude();
Standard_Real mag_val = magnitude->ValueComponent();
std::cout << "Got StepDimTol_GeometricTolerance magnitude: " << mag_val << endl;