Bug in Geom2dGcc_Circ2d2TanRadGeo & Geom2dGcc_Circ2d2TanRad

Dear Sirs,

I am trying to compute a circle which is tangent to two curves. For this, I have thought of using the class Geom2dGcc_Circ2d2TanRad and try the Geom2dGcc_Circ2d2TanRadGeo one as well. However, both classes seem to be affected by a bug (which I have not observed in OCC 6.7.1). The bug seems to be caught is the application is run from Visual Studio (I am using VS2010).

The bug is the following: when exiting the function (and destroying the Geom2dGcc_Circ2d2TanRad objects) I get the error "File: ..\..\..\dbgdel.cpp"

Line 52

Espression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse).

With the help of Sergey Zaritchny, I understood it has something to do with memory management.

My example which shows the problem is the following:

void GetLocationFillets( void )
{

// Constructing parabola.
gp_Pnt2d origin(0.0,0.0);
gp_Pnt origin3D(0.0,0.0, 0.0);
gp_Dir planeDir( 0.0,0.0,1.0);
gp_Dir2d Vx( 1.0,0.0 );
gp_Dir2d Vy(0.0, 1.0);

Handle(Geom_Plane) plane = new Geom_Plane( origin3D, planeDir);

Handle(Geom2d_Line) lineOne = new Geom2d_Line( origin, Vx );
Handle(Geom2d_Line) lineTwo = new Geom2d_Line( origin, Vy );

assert( lineOne && lineTwo );

Handle(Geom2d_Curve) trimOne = new Geom2d_TrimmedCurve( lineOne, 0.0, 200.0, Standard_True);
Handle(Geom2d_Curve) trimTwo = new Geom2d_TrimmedCurve( lineTwo, 0.0, 200.0, Standard_True);

BRepBuilderAPI_MakeEdge e1( trimOne, plane );BRepBuilderAPI_MakeEdge e2( trimTwo, plane );
BRepTools::Write( e1.Edge(), "e1.brep");
BRepTools::Write( e2.Edge(), "e2.brep");
Geom2dAdaptor_Curve AC1(trimOne);
Geom2dAdaptor_Curve AC2(trimTwo);

// Create qualified adaptors according to the desired solution
Geom2dGcc_QualifiedCurve QC1(AC1,GccEnt_outside);
Geom2dGcc_QualifiedCurve QC2(AC2,GccEnt_outside);

Geom2dGcc_QCurve Qn1(AC1,GccEnt_outside);
Geom2dGcc_QCurve Qn2(AC2,GccEnt_outside);

Geom2dGcc_Circ2d2TanRadGeo circle( Qn1, Qn2, 10.0, Precision::Confusion() );
assert( circle.IsDone() );

std::cout

}

My questions are the following:

- Is there a workaround for this bug?
- Is there an alternative way I could use to create a circle tangent to two curves in OCC without using the classes I have mentioned?
- Is there any plan regarding this bug fix? I would like to use OCC 6.9 for my application.

I sincerely thank you for your help,

Kind regards,

Paolo

Paolo Tricerri's picture

Dear Sirs,

a small update. The problem seems to disappear if I use the libraries and DLLs compiled by myself.

Kind regards,

Paolo

Sébastien Raymond's picture

Hi Paolo,

I'm experiencing this bug too. The class Geom2dGcc_Circ2dTanOn is used in a loop.

The application crash in the destructor of this class while calling TColStd_Array1OfReal::~TColStd_Array1OfReal .

If I use openCascade compiled with debug option to investigate, this issue won't appear.

May I ask you wich conpile options did you used to fix this?

Thanks,

Sébastien