# Make Helix Curve in OpenCASCADE

2015/07/09 22:16

### Make Helix Curve in OpenCASCADE

eryar@163.com

Abstract. OpenCASCADE does not provide helix curve directly, but you can build a helix curve by the pcurve of a surface(curve on surface). When you understand the pcurve of a surface, you can make a helix curve easily. The paper first make a helix by Tcl in Draw Test Harness, then translate the Tcl script to OpenCASCADE C++ code.

Key Words. OpenCASCADE, Helix Curve, PCurve, Sweep, Spring

1. Introduction

Figure 1.1 A Helix Curve

2.Make Helix Curve

 条件 参数方程 参数曲线 U=0 S(v)=P+r*cos(u)+vDz 与Z轴平行的直线 V=0 S(u)=P+r*(cos(u)*Dx+sin(u)*Dy) 与XOY面平行的圆 U!=0 && V != 0 S(u,v)=P+r(cos(u)*Dx+sin(u)*Dy)+vDz 螺旋线

``````#
# make helix curve in OpenCASCADE.
# Shing Liu(eryar@163.com)
# 2015-07-08 22:00
#

cylinder aCylinder 6

line aLine2d 0 0 1 1
trim aSegment aLine2d 0 2*pi

mkedge aHelixEdge aSegment aCylinder 0 6*pi

vdisplay aHelixEdge``````

Figure 2.1 Make a helix by Tcl script

``````#define WNT

#include <gp_Lin2d.hxx>

#include <GCE2d_MakeSegment.hxx>

#include <Geom_CylindricalSurface.hxx>

#include <BRepBuilderAPI_MakeEdge.hxx>

#include <TopoDS_Edge.hxx>

#include <BRepTools.hxx>

#pragma comment(lib, "TKernel.lib")
#pragma comment(lib, "TKMath.lib")
#pragma comment(lib, "TKG3d.lib")
#pragma comment(lib, "TKBRep.lib")
#pragma comment(lib, "TKGeomBase.lib")
#pragma comment(lib, "TKTopAlgo.lib")

void makeHelix(void)
{
Handle_Geom_CylindricalSurface aCylinder = new Geom_CylindricalSurface(gp::XOY(), 6.0);

gp_Lin2d aLine2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 1.0));

Handle_Geom2d_TrimmedCurve aSegment = GCE2d_MakeSegment(aLine2d, 0.0, M_PI * 2.0);

TopoDS_Edge aHelixEdge = BRepBuilderAPI_MakeEdge(aSegment, aCylinder, 0.0, 6.0 * M_PI).Edge();

BRepTools::Dump(aHelixEdge, std::cout);

BRepTools::Write(aHelixEdge, "d:/helix.brep");
}

int main(int argc, char* argv[])
{
makeHelix();

return 0;
}``````

Figure 2.2 Different Pitch by different K

line aLine2d 0 0 1 1

line aLine2d 0 0 5 1

line aLine2d 0 0 10 1

3.Spring: Sweep profile along helix

``````#
# make helix curve in OpenCASCADE.
# Shing Liu(eryar@163.com)
# 2015-07-08 22:00
#

cylinder aCylinder 6

line aLine2d 0 0 1 1
trim aSegment aLine2d 0 2*pi

mkedge aHelixEdge aSegment aCylinder 0 6*pi

# there is no curve 3d in the pcurve edge.
mkedgecurve aHelixEdge 0.001

wire aHelixWire aHelixEdge

circle profile 6 0 0 0 4 1 1
mkedge profile profile
wire profile profile
mkplane profile profile

pipe aSpring aHelixWire profile

vdisplay aSpring
vsetmaterial aSpring steel
vsetgradientbg 180 200 255 180 180 180 2
vsetdispmode 1
vzbufftrihedron

# set ray tracing
if { ! [catch {vrenderparams -raytrace -shadows -reflections -fsaa -rayDepth 5}] } {
vtextureenv on 1
}``````

Figure 3.1 Spring by sweep a circle along a helix path

Figure 3.2 Mosquito Coil

4.Conclusion

5. References

1. 同济大学数学教研室. 高等数学（上）. 高等教育出版社. 1978

3. OpenCASCADE Make Bottle Tutorial. 2015

5. 莫勇，常智勇. 计算机辅助几何造型技术. 科学出版社. 2009

0
0 收藏

0 评论
0 收藏
0