Opencascade Ring Type Spring Modeling
[Email protected]
Abstract. The directly create an edge was 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 T Ype 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, Ring Spring
1. Introduction
On the internet when inadvertently see the ZWCAD forum such a post: Ring spring Three-dimensional modeling exercise: http://www.zwcad.com/community/forum.php?mod=viewthread&tid=2302
Figure 1.1 Ring Type Spring
From the visible, this figure is still very interesting, the forum gives a way to shape in ZW, that is, first create a spiral ring, and then use a circular display to get the ring spring.
How to shape in the Opencascade? I think the method is to use sweep, the key is the sweep of the path of the ring-shaped spiral line construction. Because the original use of Pcurve to generate a common spring, so in the thought can not be extended on this basis, to the ring spring to shape.
2.PCurve
According to Pcurve definition: The curve is defined as a 2d curve in the parametric space of a surface. You can see the two characteristics of Pcurve:
V Pcurve is a two-dimensional curve;
V is related to surface;
Namely Pcurve is a two-dimensional curve in the surface parameter space, the point on the Pcurve is the point in the surface parameter space, and its mapping process is: Pcurve calculates a two-dimensional point (u,v) according to a parameter x, calculates the point S (u,v) of the surface as a parameter of the surface (u,v ), which is the curve that corresponds to the pcurve on the surface. Because it is ring-shaped, I associate the torus surface as shown in:
Figure 2.1 Torus in Opencascade Draw Test Harness
Creating a torus in the draw Test harness is still simple and requires only the following commands:
1 0.3 Mkface F tvdisplay F
According to the method of using cylindrical surface to shape the ordinary spring "make Helix Curve in Opencascade"
Http://www.cppblog.com/eryar/archive/2015/07/09/211212.html, is it possible to use torus to create ring springs? Practice is the only standard to test the truth, to try, anyway, failed has no loss. To use Pcurve to find the surface and its parameter space of a two-dimensional curve, and now preliminarily determined that the surface is torus surface, the following to find Pcurve. According to the Opencascade BRep Format, the equation for the torus parameter representation is:
It is known from the parametric equation that the parameter space of the torus polygon is a square area of 0 to 2PI, as shown in:
Figure 2.2 Pcurve of Torus face
When u=0 or v=0, the parametric equation for the surface is:
Figure 2.3 Torus curves when u=0 and v=0
Corresponds to a line on the U-axis and a line on the V-axis, respectively, to the parameter space. When you take a few fixed values, v changes arbitrarily in the parameter space, that is, you can get a few circular curves on the torus. When the u,v parameter is continuously changing, first try it with the simplest line of a curve, the Tcl script looks like this:
## Make Helix torus in opencascade.# shing Liu ([email protected]) # 2016-02-20 21:00#pload MODELING Visualization#Use torus surface.Torus AtorusTen 2Set Aslope0.05Line aline2d0 0 $aSlope 1Trim asegment aline2d0 2*Pi#Make Edge by the Pcurve.Mkedge Ahelixedge asegment Atorus0 2*pi/$aSlope#there is no curve 3d in the Pcurve edge.# so need this to approximate one.Mkedgecurve Ahelixedge0.01#display the edge.Vdisplay Ahelixedge
The build results are as follows:
Figure 2.4 Torus Curve made by Pcurve
The pitch adjustment can be achieved by adjusting the slope of the pcurve.
Figure 2.5 Torus Spring
Visible from the diagram, the Pcurve uses a straight line effect to be more ideal. After the curve is generated, you simply sweep a contour along the curve.
3.Modeling in Draw Test harness
Put the above together to achieve a ring spring shape, in order to facilitate testing, mainly in the draw test harness using TCL script test results. The use of TCL script to test the effect has many advantages, mainly do not need to write C + + code, do not compile, you can test the results in real time. and the Opencascade Tcl script can also be easily translated into C + + code. So there are many advantages of learning Tcl script, such as TCL has cross-platform features, through the use of scripting, can have a further understanding of parameterization. To get to the bottom, the following is a TCL script for ring Spring styling:
## Make Helix torus (Ring Type Spring) in opencascade.# Shing Liu ([email protected]) # 2016-02-20 21:00#pload MODELING Visualization#Use torus surface.Torus AtorusTen 2Set Aslope0.05Line aline2d0 0 $aSlope 1Trim asegment aline2d0 2*Pi#Make Edge by the Pcurve.Mkedge Ahelixedge asegment Atorus0 2*pi/$aSlope#there is no curve 3d in the Pcurve edge.# so need this to approximate one.Mkedgecurve Ahelixedge0.01Wire Ahelixwire Ahelixedge#Make the profile .Circle Aprofile A 0 0 1 1 1 0.3Mkedge aprofile aprofilewire aprofile aprofilemkplane aprofile aprofile#display the profile.vdisplay aprofile Ahelixedge#Loft The circle along the Helix curve.Pipeaspring ahelixwire aprofile#display the result.Vdisplay aspring#vsetmaterial aspring SteelVsetgradientbg the $ 255 the the the 2Vsetdispmode1vzbufftrihedronset Ray Tracingif{ ! [Catch {vrenderparams-raytrace-shadows-reflections-fsaa-raydepth5}]} {vtextureenv on1}
The build results are as follows:
Is the effect that is shown after using ray tracing, it feels good:
4. Conclusion
In summary, after understanding the Pcurve can be a few rules of the interesting curve to shape. In addition, learn to use Tcl script in draw Test harness to try your own ideas, you will feel the convenience of the script. In fact, in Opencascade's official online is also advocating the use of TCL script reported 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