For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Reading STEP file c++ Crash

Yousif Hashisho's picture

#include "BRepTools_ReShape.hxx"
#include "BRepTools.hxx"
#include "TopTools.hxx"
#include "STEPControl_Writer.hxx"

#include "BRepBuilderAPI_Transform.hxx"
#include "gp_Trsf.hxx"
#include "TopoDS.hxx"
#include "TopoDS_Solid.hxx"
#include "TopExp.hxx"
#include "TopTools_IndexedMapOfShape.hxx"
#include "TopExp_Explorer.hxx"
#include "TopoDS_Compound.hxx"
#include "STEPControl_Reader.hxx"

#include <XSControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_HSequenceOfShape.hxx>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

    if (argc < 2)
        cout << "Usage: Extract Information" << endl;
        cout << "InputFile: a file in STP format" << endl;
        return 1;

//    Handle(TopTools_HSequenceOfShape) aSequence;

    //read the STEP file
    STEPControl_Reader reader;

    //check step file --> invalid or incomplete entities
    IFSelect_PrintCount mode = IFSelect_ItemsByEntity;
    reader.PrintCheckLoad(false, mode);

    //Loads file
    int NbRoots = reader.NbRootsForTransfer();

    return 0;


I tried to load two step files. It was able to read a step file I downloaded from the internet but it is crashing during reading the STEP file (23.1 MB) I'm working on (The program has unexpectedly finished). The error is in this line:


Does opencascade read only specific STEP files or is it because of the STEP file I have?

Furthermore, is there a sample code where I can extract the information (bounding box and position of objects and faces..) of the CAD using STEP file and opencascade?

Thanks in advance.