# eryar

PipeCAD - Plant Piping Design Software.
RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
posts - 603, comments - 590, trackbacks - 0, articles - 0

### Make Helix Curve in OpenCASCADE

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.00.0), gp_Dir2d(1.01.0));

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

TopoDS_Edge aHelixEdge
= BRepBuilderAPI_MakeEdge(aSegment, aCylinder, 0.06.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
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

### Feedback

@谷粒OO

@五只羊

@远离颠倒梦想

@远离颠倒梦想

@liyunzhou

@eryar
OCC里面能对任意给定的参数方程构造曲线吗？比如：
x=a*(2*cos(t)-cos(2*t))
y=a*(2*sin(t)-sin(2*t))
@liyunzhou
OCC目前Geom_Curve中支持Bezier和B样条曲线，以及二次曲线，像圆，椭圆，抛物线，双曲线。

1.可以参考二次曲线的类实现，从Geom_Curve派生，实现相关虚函数；
2.将你的参数曲线转换成B样条曲线；

Best Regards,
Shing Liu

@eryar

@liyunzhou

@eryar