How to test that two Geom_Curve-s are the same?

Hi All,

Would you help me to find the way how to test that two Geom_Curve-s are the same?

Thanks.

Best regards,
Adrian

mbd_forever's picture

Hi Adrian,

I think you can use "==" operator.

Look at this example : I build two spheres, I explode them into edges and I choose the seam edge of each sphere.
Then, I get the two underlying curves and i compare them thanks to "==" ...

TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(10);
TopoDS_Edge E1;
Handle (Geom_Curve) C1;
Standard_Real C1min, C1max;
TopExp_Explorer Exp1;
for (Exp1.Init(S1, TopAbs_EDGE); Exp1.More(); Exp1.Next())
{
E1 = TopoDS::Edge(Exp1.Current());
/* I choose the seam edge of the sphere */
if (! BRep_Tool::Degenerated(E1))
C1 = BRep_Tool::Curve(E1, C1min, C1max);
}

TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(10);
TopoDS_Edge E2;
Handle (Geom_Curve) C2;
Standard_Real C2min, C2max;
TopExp_Explorer Exp2;
for (Exp2.Init(S1, TopAbs_EDGE); Exp2.More(); Exp2.Next())
{
E2 = TopoDS::Edge(Exp2.Current());
if (! BRep_Tool::Degenerated(E2))
C2 = BRep_Tool::Curve(E2, C2min, C2max);
}

if (C1 == C2)
AfxMessageBox ("Same Curves");

Handle(AIS_Shape) AIS1 = new AIS_Shape(E1);
myAISContext->Display(AIS1);

Handle(AIS_Shape) AIS2 = new AIS_Shape(E2);
myAISContext->Display(AIS2);

It works ... !

mbd_forever

a-helcman's picture

Hi mbd_forever,

I found a bug in your code. The topo explorer for the second sphere uses the S1 (sphere 1) topo object!!

for (Exp2.Init(S1, TopAbs_EDGE); Exp2.More();

Greetings,
Adrian

mbd_forever's picture

Oh Oh ...!

Sorry !

Copy-paste ... copy paste ...

I doens't work any more ... and I don't see any other solution !

Sorry !

mbd_forever