Radius of edge.

How can you query the radius of an edge (like in Topology Analysis where you can query the properties such as length, center of mass, etc.)?

mbd's picture

Hi,

try this :

TopoDS_Shape S = BRepPrimAPI_MakeSphere(10);

Standard_Real Radius;

TopExp_Explorer exp;
for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next())
{
Standard_Real U1, U2;
Handle (Geom_Curve) GC1 = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), U1, U2);
if (! GC1.IsNull())
{
Handle (Geom_Circle) GCC1 = Handle (Geom_Circle)::DownCast(GC1);
if (! GCC1.IsNull())
{
Radius = GCC1->Circ().Radius();
Handle(AIS_Shape) S1 = new AIS_Shape(exp.Current());
myAISContext->Display(S1);
break;
}
}
}

In this code, I create a sphere and then try to get a circular edge (a seam edge, not a degenerated one).

When I have this edge, I get the underlying Geom_curve, downcast this curve into a Geom_Circle, test the validity of the handle, to check if the downcast operation succeeded.

When I have the Geom_Circle, I apply "Radius()" method.

Take care, Radius() method is defined in gp_Circ, not in Geom_Circle ! So ... don't forget to include gp_Circ.hxx ...

mbd

Howard's picture

Hi mbd,

I have tried your code, everything were fine until to the Handle (Geom_Circle) GCC1 = Handle (Geom_Circle)::DownCast(GC1); part.
the GCC1 is Null. Do you have any idea what teh problem might be?

Thanks