To implement issue 0019962: MakePipeBiNormalAlongAxis implementation.

This commit is contained in:
akl 2008-09-29 07:13:29 +00:00
parent 53daed0dad
commit eb4c2e36a5
3 changed files with 99 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

View File

@ -4,7 +4,7 @@
To generate a \b Pipe in the <b>Main Menu</b> select <b>New Entity - > Generation - > Extrusion along a path</b>
\n To create an extruded \b Pipe shape, you need to define the <b>Base
\n Firstly, to create an extruded \b Pipe shape, you can define the <b>Base
Object</b> (vertex, edge, planar wire, face or shell), which will be extruded
and the <b>Path Object</b> (edge or wire) along which the <b>Base
Object</b> will be extruded.
@ -18,12 +18,30 @@ definition of the path.
\image html pipe.png
\n Secondly, you can define the <b>Base
Object</b> (edge, planar wire or face), which will be extruded,
the <b>Path Object</b> (edge or wire) along which the <b>Base
Object</b> will be extruded and the <b>Vector</b> (edge or wire)
to keep constant angular relations between the sections and this one.
\n The \b Result of the operation will be a GEOM_Object (edge, face, shell,
solid or compsolid).
\n <b>TUI Command:</b> <em>geompy.MakePipeBiNormalAlongVector(baseShape, pathShape, binormalShape)</em>
\n <b>Arguments:</b> Name + 1 shape (edge, planar wire or face)
serving as base object + 1 shape (edge or wire) for
definition of the path + 1 shape (edge or wire) to set a fixed
BiNormal direction to perform the extrusion.
\image html pipe2.png
<b>Example:</b>
\image html pipe_wire_edgesn.png
\image html pipesn.png
\image html pipebinormalsn.png
Our <b>TUI Scripts</b> provide you with useful examples of creation of
\ref tui_creation_pipe "Complex Geometric Objects".

View File

@ -543,4 +543,84 @@ gg.createAndDisplayGO(id_pipe)
gg.setDisplayMode(id_pipe,1)
\endcode
\anchor tui_creation_pipe_binormal_along_vector
<br><h2>Creation of a PipeBiNormalAlongVector</h2>
\code
def MakeHelix(radius, height, rotation, direction):
# - create a helix -
radius = 1.0 * radius
height = 1.0 * height
rotation = 1.0 * rotation
if direction > 0:
direction = +1
else:
direction = -1
pass
from math import sqrt
length_z = height
length_xy = radius*rotation
length = sqrt(length_z*length_z + length_xy*length_xy)
import geompy
nb_steps = 1
epsilon = 1.0e-6
while 1:
z_step = height / nb_steps
angle_step = rotation / nb_steps
z = 0.0
angle = 0.0
helix_points = []
for n in range(nb_steps+1):
from math import cos, sin
x = radius * cos(angle)
y = radius * sin(angle)
p = geompy.MakeVertex(x, y, z)
helix_points.append( p )
z += z_step
angle += direction * angle_step
pass
helix = geompy.MakeInterpol(helix_points)
length_test = geompy.BasicProperties(helix)[0]
prec = abs(length-length_test)/length
# print nb_steps, length_test, prec
if prec < epsilon:
break
nb_steps *= 2
pass
return helix
def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0):
# - create a pipe -
thread_radius = 1.0 * thread_radius
# create a helix
helix = MakeHelix(radius, height, rotation, direction)
# base in the (Ox, Oz) plane
import geompy
p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius)
p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius)
p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius)
p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius)
e0 = geompy.MakeEdge(p0, p1)
e1 = geompy.MakeEdge(p1, p2)
e2 = geompy.MakeEdge(p2, p3)
e3 = geompy.MakeEdge(p3, p0)
w = geompy.MakeWire([e0, e1, e2, e3])
# create a base face
base = geompy.MakeFace(w, True)
# create a binormal vector
binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0)
# create a pipe
spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal)
# Publish in the study
geompy.addToStudy(base, "base")
geompy.addToStudy(helix, "helix")
geompy.addToStudy(binormal, "binormal")
geompy.addToStudy(spring, "spring")
return spring
from math import pi
spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)
\endcode
*/