Conversion Geom_Curve and TopoDS_Edge

Hi all,

I have quite a stupid problem.
Here is what I do:

I get the intersection curve between 2 Shapes

TopoDS_Shape myShape = BRepAlgo_Section(...);

=> I check myShape graphically and it looks quite well.

Now I need to convert myShape into a Geom_Curve.

Handle(Geom_Curve) my Curve = BRep_Tool::Curve( TopoDS::Edge( myTopoDS_Shape), First, Last);

Result: Segmentation Fault

What the heck is going on with BRep_Tool ?
Maybe shall I trim myShape ? But how ? It should first be a Geom_Curve.

Later on I wanted to convert it into a spline, to read out all pole-information.

Handle(Geom_BSplineCurve) myBSplCurve = Handle(Geom_BSplineCurve)::DownCast( myCurve);

Any other way to get the "poles" from myShape ?

Some other conversion ?

Please reply soon, any hint is welcome !

MCV

Rob Bachrach's picture

The section is not an edge. It is a compound of edges. You need to use an explorer to go through the edges and get the curve from each one.

MCV's picture

This sounds like the real solution.

Do you have an example or some OCC-code example from the distribution or so ?
Any hint how to explore the compound ?

Best Regards and thanks

MCV

MCV's picture

This sounds like the real solution.

Do you have an example or some OCC-code example from the distribution or so ?
Any hint how to explore the compound ?

Best Regards and thanks

MCV

MCV's picture

Thank you very much again.
I solved it with this code.
You were absolutely right. A TopoDS_Compound is being returned actually ! Therefore an explorer is needed, otherwise you receive a null-handle and so all programmers´ beloved "segmentation fault".
Pew !

Thank God, now the weekend is rescued !

Thanks again, wonderful hint Rob.

Best Regards

MCV

TopExp_Explorer myEdgeExplorer (cut, TopAbs_EDGE);
while (myEdgeExplorer.More())
{
anEdge = TopoDS::Edge( myEdgeExplorer.Current());
cutCurve = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve( anEdge, First, Last));
myEdgeExplorer.Next();
}