OpenCASCADE Ring Type Spring Modeling
OpenCASCADE Ring Type Spring Modeling
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
PDF Version: OpenCASCADE Ring Type Spring Modeling
OpenCASCADE Ring Type Spring Modeling的更多相关文章
- 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 ...
- Spring.Net在Mvc4.0中应用的说明
案例Demo:http://yunpan.cn/cJ5aZrm7Uybi3 访问密码 414b Spring.Net在Mvc4.0中应用的说明 1.引用dll 2.修改Global文件 (Spring ...
- OpenCASCADE Interpolations and Approximations
OpenCASCADE Interpolations and Approximations eryar@163.com Abstract. In modeling, it is often requi ...
- spring.net 框架分析(三)ContextRegistry.GetContext()
我们通过ContextRegistry.GetContext()建立了一个IApplicationContext得实例,那么这个实例具体是怎么建立的了. 我们来分析一下容器实例建立的过程: 我们在配置 ...
- Spring.net 配置说明
Spring.net使用说明 使用方法: 1.在配置文件设置Spring.net 节点 在配置节中,声明Spring.net,配置 context,objects 标签,来源(type) < ...
- Overview of OpenCascade Library
Overview of OpenCascade Library eryar@163.com 摘要Abstract:对OpenCascade库的功能及其实现做简要介绍. 关键字Key Words:Ope ...
- Spring.Net简单用法
Spring.Net其实就是抽象工厂,只不过更加灵活强大,性能上并没有明显的区别. 它帮我们实现了控制反转. 其有两种依赖注入方式. 第一:属性注入 第二:构造函数注入 首先,我们去 Spring. ...
- 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:这个里面有 ...
- 25、ASP.NET MVC入门到精通——Spring.net-业务层仓储
本系列目录:ASP.NET MVC4入门到精通系列目录汇总 上一节,我们已经把项目框架的雏形搭建好了,那么现在我来开始业务实现,在业务实现的过程当中,不断的来完善我们现有的框架. 1.假设我们来做一个 ...
随机推荐
- 闰秒导致MySQL服务器的CPU sys过高
今天,有个哥们碰到一个问题,他有一个从库,只要是启动MySQL,CPU使用率就非常高,其中sys占比也比较高,具体可见下图. 注意:他的生产环境是物理机,单个CPU,4个Core. 于是,他抓取了CP ...
- 在Linux虚拟机下配置tomcat
1.到Apache官网下载tomcat http://tomcat.apache.org/download-80.cgi 博主我下载的是tomcat8 博主的jdk是1.8 如果你们的jdk是1.7或 ...
- 谈谈一些有趣的CSS题目(九)-- 巧妙的实现 CSS 斜线
开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...
- ASP.NET MVC学习之母版页和自定义控件的使用
一.母板页_Layout.cshtml类似于传统WebForm中的.master文件,起到页面整体框架重用的目地1.母板页代码预览 <!DOCTYPE html> <html> ...
- 如何理解DT将是未来IT的转型之路?
如今的IT面临着内忧外患的挑战. 一方面,企业多多少少都建立了信息化,有些企业或集团甚至会有数几十个分公司,包含直销.代理.零售以及第三方物流等多种业态.越是复杂的业务,信息化建设越困难,比如运用大量 ...
- Tableau未必最佳,国内BI也能突破重围!
如今,百度一下商业智能或BI工具,总能看到Tableau的身影.并不是Tableau的营销做得好,而是国内对于商业智能工具的认知和选择似乎都落在了Tableau身上.导致不管业内业外都对商业智能的概念 ...
- Android Weekly Notes Issue #236
Android Weekly Issue #236 December 18th, 2016 Android Weekly Issue #236 本期内容包括: Google的物联网平台Android ...
- 真正的汉化-PowerDesigner 16.5 汉化
一.背景 经常使用PowerDesigner,之前使用15版本,后来16出来后,就一直在使用16,不过一直是英文.一些同事对使用英文版总显示有些吃力. 遍寻百度.必应,都没有找到真正的针对版本16的汉 ...
- 让Mono 4在Raspberry Pi上飞
最近公司有项目想要在树莓派上做,代替原来的工控机(我们是把工控主机当作小的主机用,一台小的工控主机最少也要600左右,而树莓派只要200多).于是,公司买了一个Raspberry Pi B+和一个Ra ...
- 监督学习 VS 无监督学习
监督学习 就是人们常说的分类,通过已有的训练样本(即已知数据以及其对应的输出)去训练得到一个最优模型(这个模型属于某个函数的集合,最优则表示在某个评价准则下是最佳的),再利用这个模型将所有的输入映射为 ...