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中生成一个圆环面还是很简单的,只需要以下几条命令:

pload ALL
torus t 0.3
mkface f t
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脚本如下所示:

#
# make helix torus in OpenCASCADE.
# Shing Liu(eryar@163.com)
# 2016-02-20 21:00
# pload MODELING VISUALIZATION # use torus surface.
torus aTorus set aSlope 0.05
line aLine2d $aSlope
trim aSegment aLine2d *pi # make edge by the pcurve.
mkedge aHelixEdge aSegment aTorus *pi/$aSlope # there is no curve 3d in the pcurve edge.
# so need this to approximate one.
mkedgecurve aHelixEdge 0.01 # display the edge.
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脚本:

#
# make helix torus(Ring Type Spring) in OpenCASCADE.
# Shing Liu(eryar@163.com)
# 2016-02-20 21:00
# pload MODELING VISUALIZATION # use torus surface.
torus aTorus set aSlope 0.05
line aLine2d $aSlope
trim aSegment aLine2d *pi # make edge by the pcurve.
mkedge aHelixEdge aSegment aTorus *pi/$aSlope # there is no curve 3d in the pcurve edge.
# so need this to approximate one.
mkedgecurve aHelixEdge 0.01 wire aHelixWire aHelixEdge # make the profile.
circle aProfile 0.3
mkedge aProfile aProfile
wire aProfile aProfile
mkplane aProfile aProfile # display the profile.
vdisplay aProfile aHelixEdge # loft the circle along the helix curve.
pipe aSpring aHelixWire aProfile # display the result.
vdisplay aSpring
#vsetmaterial aSpring steel
vsetgradientbg
vsetdispmode
vzbufftrihedron set ray tracing
if { ! [catch {vrenderparams -raytrace -shadows -reflections -fsaa -rayDepth }] } {
vtextureenv on
}

生成结果如下图所示:

下图是使用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. javascript中的事件冒泡和事件捕获

    1.事件冒泡 IE 的事件流叫做事件冒泡(event bubbling),即事件开始时由最具体的元素(文档中嵌套层次最深的那个节点)接收,然后逐级向上传播到较为不具体的节点(文档).以下面的HTML ...

  2. angular2系列教程(八)In-memory web api、HTTP服务、依赖注入、Observable

    大家好,今天我们要讲是angular2的http功能模块,这个功能模块的代码不在angular2里面,需要我们另外引入: index.html <script src="lib/htt ...

  3. 数据图表插件Echarts(一)

    一.引言 最近做一个智慧城市项目,项目中需要图表和报表进行数据分析,从网上找了很多,最后找到了百度开放的echarts,一个很强大的插件. 二.介绍 ECharts,缩写来自Enterprise Ch ...

  4. JavaScript基础知识总结(一)

    当我们接触一种新语言时,首先要先了解它,对它有一定的理论认识. 那么,什么是JavaScript呢? JavaScript是一种脚本语言,由web浏览器进行解释和执行.它包括ECMAScript.DO ...

  5. WebApi返回Json格式字符串

    WebApi返回json格式字符串, 在网上能找到好几种方法, 其中有三种普遍的方法, 但是感觉都不怎么好. 先贴一下, 网上给的常用方法吧. 方法一:(改配置法) 找到Global.asax文件,在 ...

  6. SAP CRM 树视图(TREE VIEW)

    树视图可以用于表示数据的层次. 例如:SAP CRM中的组织结构数据可以表示为树视图. 在SAP CRM Web UI的术语当中,没有像表视图(table view)或者表单视图(form view) ...

  7. 数据库备份并分离日志表(按月)sh 脚本

    #!/bin/sh year=`date +%Y` month=`date +%m` day=`date +%d` hour=`date +%H` dir="/data/dbbackup/f ...

  8. 【python之路3】if 语句

    1.if语句用法(if....else....) #!/usr/bin/env python # -*- coding:utf-8 -*- my_name = raw_input("plea ...

  9. EF里Guid类型数据的自增长、时间戳和复杂类型的用法

    通过前两章Lodging和Destination类的演示,大家肯定基本了解Code First是怎么玩的了,本章继续演示一些很实用的东西.文章的开头提示下:提供的demo为了后面演示效果,前面代码有些 ...

  10. Vue.js——60分钟快速入门

    Vue.js介绍 Vue.js是当下很火的一个JavaScript MVVM库,它是以数据驱动和组件化的思想构建的.相比于Angular.js,Vue.js提供了更加简洁.更易于理解的API,使得我们 ...