Error writing STEP file

Hello,

I believe I have found a bug in OpenCascade 6.2. I am able to load a large STEP model into memory without errors, but when I try to write it back out to disk, the following happens:

This is my code:

STEPControl_Writer writer;
writer.Model( Standard_True );
...
TopoDS_Shape shape = cascadeShape->getShapeImpl();

writer.Transfer( shape, STEPControl_AsIs );

And here is where the crash occurs deep inside of the OpenCascade library:

void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& aFace,
TopoDSToStep_Tool& aTool,
const Handle(Transfer_FinderProcess)& FP)
{

...
for (;Ex.More(); Ex.Next()) {
TopoDS_Edge E = TopoDS::Edge(Ex.Current());
Standard_Real cf, cl;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, ForwardFace, cf, cl);

//CA = BRepAdaptor_Curve(E, ForwardFace);
//GeomAbs_CurveType typCOnS = CA.CurveOnSurface().GetCurve().GetType();

//if (typCOnS == GeomAbs_Line && BRep_Tool::Degenerated(E) ) {
if ( //:abv 26Jan00, CAX-IF TRJ3: C2d->IsKind(STANDARD_TYPE(Geom2d_Line)) &&
BRep_Tool::Degenerated(E)) {
// The edge 2D Geometry degenerates in 3D
// The edge 2D geometry is not mapped onto any Step entity
// (ProStep agreement)
continue;
}
else { // Copy the Curve2d which might be changed
//C2d = CA.CurveOnSurface().GetCurve().Curve();
//C2d = Handle(Geom2d_Curve)::DownCast(C2d->Copy());
C2d = Handle(Geom2d_Curve)::DownCast(C2d->Copy()); }
...

It appears that edge E is not degenerated, but C2d is a null curve. I don't believe that this is supposed to happen. Very likely the bug is not actually at this line of code, but is in the STEP model reading code somewhere. Has anyone else seen this or does anyone know how to fix it?

-- Thanks, Shaun

sb@stellarscience.com's picture

It appears that this was due to the fact that the stack size in my main program was not large enough. I increased it to 15 MB and the problem appears to be resolved.

renyu_teng's picture

hi ShaunBloom,

could you please tell us how to increase the stack?

thanks a lot.
Eric

m-aronsson's picture

If OCC needs a 15MB stack I would consider that a bug ;o)