Segmentation Fault using BRep_Tool::Surface

Hello,

i have a TopoDS_Shape generated with BRepOffsetAPI_MakePipe and i'd like to get the corresponding Surface. Here is my code :

//The profile is based on a bsplinecurve
Handle(TColgp_HArray1OfPnt) array2 = new TColgp_HArray1OfPnt (1,2);
array2->SetValue(1,P3);
array2->SetValue(2,P4);

GeomAPI_Interpolate algo2(array2, Standard_False, 1.0e-7);
gp_Vec Vin2(0,0,1); gp_Vec Vout2(0,-1,0);
algo2.Load(Vin2,Vout2);
algo2.Perform();
Handle(Geom_BSplineCurve) bsCurve2 = algo2.Curve();
TopoDS_Wire profile= BRepBuilderAPI_MakeWire(E2);

//The support for "sweeping"
TopoDS_Edge lon= BRepBuilderAPI_MakeEdge(P3,S1);
TopoDS_Wire Wlon= BRepBuilderAPI_MakeWire(lon);

TopoDS_Shape Pipe1 = BRepOffsetAPI_MakePipe(Wlon,profile);
TopoDS_Face Pipe1_face= TopoDS::Face(Pipe1);
Handle_Geom_Surface Pipe1_surface= BRep_Tool::Surface(Pipe1_face);

BRep_Tool::Surface causes a segmentation fault and gdb returns :

Program received signal SIGSEGV, Segmentation fault.
0xb71c963e in TopLoc_SListOfItemLocation::TopLoc_SListOfItemLocation ()
from /opt/OpenCASCADE5.2/ros/Linux/lib/libTKBRep.so

How can i get the other edges generated during the makepipe process in order to build other shapes using them ?

Torsten Sadowski's picture

Hi,
the problem is here:

TopoDS_Face Pipe1_face= TopoDS::Face(Pipe1);
Handle_Geom_Surface Pipe1_surface= BRep_Tool::Surface(Pipe1_face);

The pipe is not a face. It is a solid. Have a look at TopExp::MapShapes to get a map of all faces.

Torsten

Etienne LORRIAUX's picture

Hi Torsten,

thanks for replying and the tip. It works fine now inserting this code :

TopoDS_Shape Pipe1 = BRepOffsetAPI_MakePipe(Wlon,profile);
TopTools_IndexedMapOfShape ind;
TopExp::MapShapes(Pipe1, TopAbs_FACE, ind);
TopoDS_Shape tmp = ind.FindKey(1);
TopoDS_Face Pipe1_face= TopoDS::Face(tmp);
Handle_Geom_Surface Pipe1_surface= BRep_Tool::Surface(Pipe1_face);

Regards.