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

BRepAlgoAPI_Section stopped working when upgrading from OC4 to OC5

Dr Tony Aldhous's picture


I have been using BRepAlgoAPI_Section to take a horizontal cross section of a shape loaded from an IGES file. All worked fine in OpenCascade V4.0.

I am now trying to upgrade to V5.2. I have made few changes, mostly removing redundant #includes. The only significant change was to change Reader.Clear() to Reader.ClearShapes() in the IGES loader code.

The shape appears to be loaded properly - at least, it seems to draw as expected. But the section returned by BRepAlgoAPI_Section comes out as a single straight line.

Can anyone suggest how to make it work?

Many Thanks

Tony Aldhous.


The loader code looks like this:

Standard_Integer status = Reader.ReadFile((char *const)(LPCSTR)filename);
Reader.PrintCheckLoad(Standard_False, IFSelect_ItemsByEntity);

Handle(TColStd_HSequenceOfTransient) myAllFace;
myAllFace = Reader.GiveList("iges-faces");
Standard_Integer i, nb = myAllFace->Length();

TopoDS_Compound C;
BRep_Builder B;
for (i=1; i Handle(IGESData_IGESEntity) igesEntity =

Reader.ClearShapes(); // Was Reader.Clear();
if (Reader.TransferEntity(igesEntity)) {
B.Add (C,Reader.OneShape());

TopoDS_Shape rotatedIgesShape = C;

The section code looks like this:

gp_Pln pl(gp_Pnt(0, 0, zMin+offset), gp_Dir(0, 0, 1));
BRepAlgoAPI_Section s(rotatedIgesShape, pl);
TopoDS_Shape section = s.Shape();
TopExp_Explorer exp(section, TopAbs_EDGE);
Standard_Real first, last;
Standard_Real fp = xMin;
Handle(Geom_Curve) c =
BRep_Tool::Curve(TopoDS::Edge(exp.Current()), first, last);
gp_Pnt p1 = c->Value(first);
gp_Pnt p2 = c->Value(last);

if (p1.X() > fp)
fp = p1.X();
if (p2.X() > fp)
fp = p2.X();


// fp should contain the max x coordinate.
// In V4.0 this works, but in V5.2 it does not.