The main purpose is to go through all child elements of a STEP model and to make a tree view out of them using OpenCascade. Now I am downloading the STEP model according to a particular path to a TopoDS_Shape object and then I am passing this object to the AIS_Shape object in order to finally display the model in the viewport. So, I thought that there was a method that should get a model path or a model itself as a parameter, then recursively go through all its child and finaly prints them somewhere
void OcctGtkViewer::onSTEPLoad(std::string filename)
{
string tempFileName = "";
STEPControl_Reader reader;
TopoDS_Shape shape;
if (filename == "")
filename = tempFileName;
const char *encodename = filename.c_str();
if (reader.ReadFile(encodename) != IFSelect_RetDone)
{
cout << "Выбран не STEP файл!" << endl;
return;
}
Standard_Integer nbr = reader.NbRootsForTransfer();
for (Standard_Integer n = 1; n <= nbr; n++)
{
cout << "STEP: передаю корневой объект " << n << endl;
reader.TransferRoot(n);
}
Standard_Integer nbs = reader.NbShapes();
shape = reader.OneShape();
STEPShape = reader.OneShape();
cout << "STEP: файл загружен " << endl;
//TDocStd_Document document("/home/kirill/Desktop/1.STEP");
//traverseDocument(document);
return;
}
{
// dummy shape for testing
onSTEPLoad(pathToFile);
// TopoDS_Shape aBox = BRepPrimAPI_MakeBox(100.0, 50.0, 90.0).Shape();
Handle(AIS_Shape) aShape = new AIS_Shape(STEPShape);
myContext->Display(aShape, AIS_Shaded, 0, false);
}