How to make a solid helix ?

I've tried the following code, but unfortunately the application crashes (memory protection) at the indicated step - the problem is the spine and I don't know why. Does anybody know an alternative solution ?

Kind regards

And here is the code:

Note, that the spine ( a helix) and the circle are displayed correctly. If I use another spine(e.g. a simple line) everything is ok ... it seems that MakePipe does not like edges produced on a cylindrical surface.

Handle(Geom2d_Line) lin1 = new Geom2d_Line(
gp_Pnt2d( 0.0, 0.0),
gp_Dir2d( 1.0, 1.0));

Handle(Geom_CylindricalSurface) surf =
new Geom_CylindricalSurface(gp::XOY(), 3.0);

TopoDS_Edge E1;

E1 = BRepBuilderAPI_MakeEdge(lin1, surf, 0, 20.0);

TopoDS_Wire W1 = BRepBuilderAPI_MakeWire(E1);

Handle(AIS_Shape) S1 = new AIS_Shape(W1);

GetContext()->Display(S1);

gp_Circ c = gp_Circ(gp_Ax2(
gp_Pnt(3.0, 0., 0.),
gp_Dir(0., 1., 0.)), 2.0);

TopoDS_Edge Ec = BRepBuilderAPI_MakeEdge(c);
TopoDS_Wire Wc = BRepBuilderAPI_MakeWire(Ec);

TopoDS_Face F = BRepBuilderAPI_MakeFace(gp_Pln( gp::ZOX() ),Wc);

Handle(AIS_Shape) Face = new AIS_Shape(F);
GetContext()->Display(Face);

// Make a pipe

// ****
// it crashes here !
// ****
TopoDS_Shape TS1 = BRepOffsetAPI_MakePipe(W1, F);

Handle(AIS_Shape) S = new AIS_Shape(TS1);
GetContext()->Display(S);

bhimesh's picture

have you found out the solution for this problem??
if yes can you please tell me how you have done it..

varad's picture

some thing more i found much simple and tried it....

say u have n no of turns
write a function that will create one turn
in map the point on helix using formula

x=r*cos(th)
y=r*sin(th)
z=a*th (if u r using diffnt funt then also add pitch*current turn in z)

where a= pitch/2*pi

change the value of th from 0 to 360 so u will get accurate curve
call this func in a loop so u get req no of turns. add all those turns to create a single wire.
n u have a complete helix...........

u simmilar logic to create any kind of spring(it may be conical, var pitch, curved spring... u can get that)

ZuNien's picture

before using BRepOffsetAPI_MakePipe, you should use BRepLib::BuildCurves3d(W1) to build the 3d curve