OpenCASCADE Ring Type Spring Modeling

eryar@163.com

Abstract. The general method to directly create an edge is to give a 3D curve as the support(geometric domain) of the edge. The curve maybe defined as a 2D curve in the parametric space of a surface: PCurve. When you understand the pcurve, you can modeling some interesting shapes, such as bottle neck thread, helix spring, ring type spring. Etc. The paper is focus on the Ring Type Spring Modeling in OpenCASCADE Draw Test Harness by Tcl script.

Key Words. Spring, Helix, Tcl/Tk, 环形弹簧

1. Introduction

在上网的时候不经意看到了ZWCAD论坛上的这么一个帖子:环形弹簧三维建模练习:http://www.zwcad.com/community/forum.php?mod=viewthread&tid=2302

Figure 1.1 Ring Type Spring

从上图可见,这个图形还是很有趣的,论坛中给出了在ZW中造型的一种方法,即先创建一个螺旋圆环,再用圆形陈列来得到这个环形弹簧。

如何在OpenCASCADE中来造型呢?我想的方法是利用扫掠,关键就是扫掠的路径环形螺放线的构造出来。因为原来使用过pcurve来生成过一个普通的弹簧,所以在想能不能在这个基础上进行扩展,来对这种环形弹簧来造型。

2.PCurve 

根据pcurve的定义:The curve may be defined as a 2d curve in the parametric space of a surface. 可以看出pcurve的两个特点:

v pcurve是一条二维曲线;

v 与曲面相关;

即pcurve就是曲面参数空间中一条二维曲线,pcurve上的点就是曲面参数空间中的点,其映射过程为:pcurve根据一个参数x计算得到一个二维点(u,v),将这个二维点(u,v)作为曲面的参数计算出曲面上的点S(u,v),即为pcurve对应到曲面上的曲线。因为是环形的,所以我联想到了Torus曲面,如下图所示:

Figure 2.1 Torus in OpenCASCADE Draw Test Harness

在Draw Test Harness中生成一个圆环面还是很简单的,只需要以下几条命令:

  1. pload ALL
  2. torus t 0.3
  3. mkface f t
  4. vdisplay f

根据利用圆柱面来对普通弹簧造型的方法“Make Helix Curve in OpenCASCADE”

http://www.cppblog.com/eryar/archive/2015/07/09/211212.html ,是否可以利用圆环面来生成圆环弹簧呢?实践是检验真理的唯一标准,随便尝试,反正失败了也没有什么损失。要利用pcurve就要找出曲面及其参数空间的一条二维曲线,现在初步确定了曲面为torus面,下面再来寻找pcurve。根据《OpenCASCADE BRep Format》中对于Torus的参数表示方程为:

由参数方程可知,torus面的参数空间为0到2PI的一个正方形区域,如下图所示:

Figure 2.2 PCurve of Torus Face

当u=0或v=0时,曲面的参数方程为:

Figure 2.3 Torus curves when u=0 and v=0

对应到参数空间分别为u轴上的直线和v轴上的直线。当u取几个固定值,v在参数空间任意变化时,即可以得到圆环面上几个圆形曲线。当u,v参数连续变化时,先用最简单的一次曲线直线来尝试下,Tcl脚本如下所示:

  1. #
  2. # make helix torus in OpenCASCADE.
  3. # Shing Liu(eryar@163.com)
  4. # 2016-02-20 21:00
  5. #
  6.  
  7. pload MODELING VISUALIZATION
  8.  
  9. # use torus surface.
  10. torus aTorus
  11.  
  12. set aSlope 0.05
  13. line aLine2d $aSlope
  14. trim aSegment aLine2d *pi
  15.  
  16. # make edge by the pcurve.
  17. mkedge aHelixEdge aSegment aTorus *pi/$aSlope
  18.  
  19. # there is no curve 3d in the pcurve edge.
  20. # so need this to approximate one.
  21. mkedgecurve aHelixEdge 0.01
  22.  
  23. # display the edge.
  24. vdisplay aHelixEdge

生成结果如下图所示:

Figure 2.4 Torus Curve made by pcurve

其中螺距的调整可以通过调整pcurve的斜率来实现。

Figure 2.5 Torus Spring

由图可见,pcurve使用直线效果比较理想。曲线生成之后,只需要将一个轮廓沿着曲线扫掠即可。

3.Modeling in Draw Test Harness

将上述放在一起来实现一个环形弹簧的造型,为了便于测试,主要是在Draw Test Harness中使用Tcl脚本来测试效果。使用Tcl脚本来测试效果有很多好处,主要就是不需要编写C++代码,也不用编译,可以实时检验结果。而且OpenCASCADE的Tcl脚本也可以很方便地翻译成C++代码。所以学习一下Tcl脚本还是有很多好处的,如Tcl具有跨平台的特性,通过使用脚本,可以对参数化有更进一步的理解等。言归正传,下面给出环形弹簧造型的Tcl脚本:

  1. #
  2. # make helix torus(Ring Type Spring) in OpenCASCADE.
  3. # Shing Liu(eryar@163.com)
  4. # 2016-02-20 21:00
  5. #
  6.  
  7. pload MODELING VISUALIZATION
  8.  
  9. # use torus surface.
  10. torus aTorus
  11.  
  12. set aSlope 0.05
  13. line aLine2d $aSlope
  14. trim aSegment aLine2d *pi
  15.  
  16. # make edge by the pcurve.
  17. mkedge aHelixEdge aSegment aTorus *pi/$aSlope
  18.  
  19. # there is no curve 3d in the pcurve edge.
  20. # so need this to approximate one.
  21. mkedgecurve aHelixEdge 0.01
  22.  
  23. wire aHelixWire aHelixEdge
  24.  
  25. # make the profile.
  26. circle aProfile 0.3
  27. mkedge aProfile aProfile
  28. wire aProfile aProfile
  29. mkplane aProfile aProfile
  30.  
  31. # display the profile.
  32. vdisplay aProfile aHelixEdge
  33.  
  34. # loft the circle along the helix curve.
  35. pipe aSpring aHelixWire aProfile
  36.  
  37. # display the result.
  38. vdisplay aSpring
  39. #vsetmaterial aSpring steel
  40. vsetgradientbg
  41. vsetdispmode
  42. vzbufftrihedron
  43.  
  44. set ray tracing
  45. if { ! [catch {vrenderparams -raytrace -shadows -reflections -fsaa -rayDepth }] } {
  46. vtextureenv on
  47. }

生成结果如下图所示:

下图是使用Ray Tracing后显示的效果,感觉不错:

4. Conclusion

综上所述,理解了pcurve后可以对一些规则的有趣的曲线进行造型。另外学会在Draw Test Harness中使用Tcl脚本来尝试自己的想法,将会感觉到脚本的便利性。其实在OpenCASCADE的官网上也是提倡使用Tcl脚本来报告bug。

5. References

1. OpenCASCADE BRep Format

2. Shing Liu. Make Helix Curve in OpenCASCADE.

http://www.cppblog.com/eryar/archive/2015/07/09/211212.html

3. ZW3D community topic:

http://www.zwcad.com/community/forum.php?mod=viewthread&tid=2302

OpenCASCADE Ring Type Spring Modeling的更多相关文章

  1. FW: How to use Hibernate Lazy Fetch and Eager Fetch Type – Spring Boot + MySQL

    原帖 https://grokonez.com/hibernate/use-hibernate-lazy-fetch-eager-fetch-type-spring-boot-mysql In the ...

  2. Spring.Net在Mvc4.0中应用的说明

    案例Demo:http://yunpan.cn/cJ5aZrm7Uybi3 访问密码 414b Spring.Net在Mvc4.0中应用的说明 1.引用dll 2.修改Global文件 (Spring ...

  3. OpenCASCADE Interpolations and Approximations

    OpenCASCADE Interpolations and Approximations eryar@163.com Abstract. In modeling, it is often requi ...

  4. spring.net 框架分析(三)ContextRegistry.GetContext()

    我们通过ContextRegistry.GetContext()建立了一个IApplicationContext得实例,那么这个实例具体是怎么建立的了. 我们来分析一下容器实例建立的过程: 我们在配置 ...

  5. Spring.net 配置说明

    Spring.net使用说明   使用方法: 1.在配置文件设置Spring.net 节点  在配置节中,声明Spring.net,配置 context,objects 标签,来源(type) < ...

  6. Overview of OpenCascade Library

    Overview of OpenCascade Library eryar@163.com 摘要Abstract:对OpenCascade库的功能及其实现做简要介绍. 关键字Key Words:Ope ...

  7. Spring.Net简单用法

    Spring.Net其实就是抽象工厂,只不过更加灵活强大,性能上并没有明显的区别. 它帮我们实现了控制反转. 其有两种依赖注入方式. 第一:属性注入 第二:构造函数注入 首先,我们去  Spring. ...

  8. 17、ASP.NET MVC入门到精通——Spring.net入门

    Spring.NET环境准备 pring.NET 1.3.2下载地址:http://down.51cto.com/data/861700 下载后解压 Spring.NET-1.3.2.7z:这个里面有 ...

  9. 25、ASP.NET MVC入门到精通——Spring.net-业务层仓储

    本系列目录:ASP.NET MVC4入门到精通系列目录汇总 上一节,我们已经把项目框架的雏形搭建好了,那么现在我来开始业务实现,在业务实现的过程当中,不断的来完善我们现有的框架. 1.假设我们来做一个 ...

随机推荐

  1. Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数

    上一篇:Angular2入门系列教程-服务 上一篇文章我们将Angular2的数据服务分离出来,学习了Angular2的依赖注入,这篇文章我们将要学习Angualr2的路由 为了编写样式方便,我们这篇 ...

  2. .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类

    .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类 0x00 为什么要引入扩展方法 有的中间件功能比较简单,有的则比较复杂,并且依赖其它组件.除 ...

  3. ABP文档 - 嵌入的资源文件

    文档目录 本节内容: 简介 创建嵌入的文件 暴露嵌入的文件 使用嵌入的文件 简介 一个web应用里,客户端包含javascript,css,xml等文件,这此文件被添加到一个web项目后,发布成独立的 ...

  4. Android 剪贴板详解

    版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Clipboard 如本文有助于你理解 Android 剪贴板,不妨给我一个 Star.对于码农而言, ...

  5. 一个诡异的COOKIE问题

    今天下午,发现本地的测试环境突然跑不动了,thinkphp直接跑到异常页面,按照正常的排错思路,直接看thinkphp的log 有一条 [ error ] [2]setcookie() expects ...

  6. 趣说游戏AI开发:曼哈顿街角的A*算法

    0x00 前言 请叫我标题党!请叫我标题党!请叫我标题党!因为下面的文字既不发生在美国曼哈顿,也不是一个讲述美国梦的故事.相反,这可能只是一篇没有那么枯燥的关于算法的文章.A星算法,这个在游戏寻路开发 ...

  7. Entity Framework 教程——Entity Framework中的实体类型

    Entity Framework中的实体类型 : 在之前的章节中我们介绍过从已有的数据库中创建EDM,它包含数据库中每个表所对应的实体.在EF 5.0/6.0中,存在POCO 实体和动态代理实体两种. ...

  8. Android中的flexboxlayout布局

    提到FlexboxLayout大家估计有点模糊,它是谷歌最近开源的一个android排版库,它的前身Flexbox是2009年W3C提出了一种新的布局,可以简便.完整.响应式的实现页面布局,Flexb ...

  9. java I/O流

    输入流(读取数据的流) BufferedInputStream---继承--->FileInputStream--继承--->InputStream------> (1)字节流操作中 ...

  10. Selenium-java-获取当前时间

    1 获取当前时间 // 获取当前时分秒 Calendar now = Calendar.getInstance(); int is = now.get(Calendar.HOUR_OF_DAY); i ...