DownCast to find Geom_TrimmedCurve

Hi All,

I have a small problem !. I create an arc using,

Handle(Geom_TrimmedCurve) curve = GC_MakeArcOfCircle(...)

however, when I examine the type of this curve later on using downcasting.....

Handle(Geom_TrimmedCurve)::DownCast(curve).IsNull()

returns true but.....

Handle(Geom_Circle)::DownCast(curve).IsNull()

return false.

Is this the correct behaviour for the down cast to return the basis curve type or am I doing something stupid. ?

Thanks in advance.

Simon

Sergey KHROMOV's picture

Hello, Simon!

Your results seem to be strange. In this case DownCast() method must return not null curve only for Geom_TrimmedCurve type.

You can not downcast Geom_TrimmedCurve to Geom_Circle. Because these classes have no inheritable links.

To obtain basis curve of an arc (Geom_Circle in this case) you can use BasisCurve() method. For example:

Handle(Geom_TrimmedCurve) aTrimmedCurve = GC_MakeArcOfCircle(...);

Handle(Geom_Curve) aCurve = aTrimmedCurve->BasisCurve();

Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve);

The circle obtained by this way is not null.

Best regards, Sergey.

Yang TZU-CHUAN's picture

I've faced the same problem as Simon mentioned above.

First, I create Geom_TrimmedCurve with Geom_Circle, startAngle and endAngle. 

Got True when downcast using Geom_TrimmedCurve.DownCast(curve).INull

Got False when downcast using Geom_Circle.DownCast(curve).IsNull, means it is a circle.

When I draw this curve on the canvas, I got a circle even I've made it as arc.

Dose anyone has some idea about this?

Thanks a lot

Joba