Creating lines, arcs, curves from Edges

Hi,

I am new to OCC, so go easy on me.

I am using TopExp_Explorer to iterate through the Edges of my shape(s) and what I need to know is what is the best way to obtain the geometry for each edge. In other words, the best way to convert the Edge to an appropriate segment, line, arc, circle, etc.

Any help or related links are appreciated.

Sharjith Naramparambath's picture

First get the edge from the Explorer...

TopoDS_Edge anEdge = TopoDS::Edge(theShape); // theShape is what you get from iterator

Then..

First option:

Get the underlying Geom_Gurve from the edge using...

Standard_Real first, last;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, first, last);

Then using RTTI find out the type of the curve using...

if(aCurve->IsKind(STANDARD_TYPE (Geom_Line)))
{
// do something with line
}
else if(aCurve->IsKind(STANDARD_TYPE (Geom_Circle)))
{
// do something with circle
}
and so on...

Second option:
Use BRepAdaptor_Curve...

BRepAdaptor_Curve theCrv(anEdge);
GeomAbs_CurveType theTyp = theCrv.GetType();

if(theTyp == GeomAbs_Line)
{
// do something with line
}
else if(theTyp == GeomAbs_Circle)
{
// do something with circle
}
and so on...

Here, the choice of the option depends on whether you need to use the Geom_Curve or just the edge as-is for further processing.

Hope this is what you are looking for.

bendtech's picture

Thanks Sharjith,

I am pretty much using your first example. The second example is useful to know as well though.

Another quick question: How do I get the center point of a geom_circle / gp_circ?

Thanks. It's slow going learning OCC, but I am definitely getting somewhere.

Sharjith Naramparambath's picture

gp_Circ has method Location() that returns the center gp_Pnt.

OCC has method names that are not sometimes intuitive -- like anyone would expect a method named Center() instead of Location(). The documentation is good though.

Good Luck!