Tue, 10/11/2011 - 21:45
Forums:
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.
Wed, 10/12/2011 - 21:11
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.
Thu, 10/13/2011 - 00:53
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.
Thu, 10/13/2011 - 01:06
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!
Fri, 01/20/2023 - 13:40
Sharjith:
I have same question is,if I got a edge,it is type of circle,then,how could I get the coordinate of center point and Radius?Is it need transfer Edge to gp_Cir?and how?
thansk
Jason