mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-16 10:38:34 +05:00
654 lines
19 KiB
Plaintext
654 lines
19 KiB
Plaintext
/*!
|
|
|
|
\page tui_complex_objs_page Complex Objects
|
|
|
|
\anchor tui_creation_prism
|
|
<br><h2>Creation of a Prism</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
# create a vertex and a vector
|
|
p1 = geompy.MakeVertex( 0., 0., 0.)
|
|
p2 = geompy.MakeVertex( 100., 0., 0.)
|
|
p3 = geompy.MakeVertex( 100., 100., 0.)
|
|
p4 = geompy.MakeVertex( 0., 100., 0.)
|
|
p5 = geompy.MakeVertex( 0., 0., 60.)
|
|
p6 = geompy.MakeVertex(-100., 0., 0.)
|
|
p7 = geompy.MakeVertex(-100.,-100., 0.)
|
|
p8 = geompy.MakeVertex( 0.,-100., 0.)
|
|
|
|
# create a vector from the given components
|
|
vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)
|
|
|
|
#create vectors from two points
|
|
vector1_arc1 = geompy.MakeVector(p1, p2)
|
|
vector2_arc1 = geompy.MakeVector(p1, p4)
|
|
vector1_arc2 = geompy.MakeVector(p1, p6)
|
|
vector2_arc2 = geompy.MakeVector(p1, p8)
|
|
|
|
# create arcs from three points
|
|
arc1 = geompy.MakeArc(p2, p3, p4)
|
|
arc2 = geompy.MakeArc(p6, p7, p8)
|
|
|
|
# create wires
|
|
wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])
|
|
wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])
|
|
|
|
# create faces
|
|
isPlanarWanted = 1
|
|
face1 = geompy.MakeFace(wire1, isPlanarWanted)
|
|
face2 = geompy.MakeFace(wire2, isPlanarWanted)
|
|
|
|
# create prisms
|
|
prism1 = geompy.MakePrism(face2, p1, p5)
|
|
prism2 = geompy.MakePrismVecH(face1, vector, 50)
|
|
prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50)
|
|
|
|
# add objects in the study
|
|
id_face1 = geompy.addToStudy(face1,"Face1")
|
|
id_face2 = geompy.addToStudy(face2,"Face2")
|
|
id_prism1 = geompy.addToStudy(prism1,"Prism1")
|
|
id_prism2 = geompy.addToStudy(prism2,"Prism2")
|
|
id_prism3 = geompy.addToStudy(prism3,"Prism3")
|
|
|
|
# display cylinders
|
|
gg.createAndDisplayGO(id_face1)
|
|
gg.setDisplayMode(id_face1,1)
|
|
gg.createAndDisplayGO(id_face2)
|
|
gg.setDisplayMode(id_face2,1)
|
|
gg.createAndDisplayGO(id_prism1)
|
|
gg.setDisplayMode(id_prism1,1)
|
|
gg.createAndDisplayGO(id_prism2)
|
|
gg.setDisplayMode(id_prism2,1)
|
|
gg.createAndDisplayGO(id_prism3)
|
|
gg.setDisplayMode(id_prism3,1)
|
|
\endcode
|
|
|
|
\anchor tui_creation_revolution
|
|
<br><h2>Creation of a Revolution</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
# create a vertex and a vector
|
|
p1 = geompy.MakeVertex( 10., 10., 10.)
|
|
p2 = geompy.MakeVertex( 15., 15., 50.)
|
|
p3 = geompy.MakeVertex( 40., 40., 0.)
|
|
|
|
#create vectors from two points
|
|
vector1 = geompy.MakeVector(p1, p2)
|
|
vector2 = geompy.MakeVector(p1, p3)
|
|
|
|
# create a vector from the given components
|
|
vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.)
|
|
|
|
# create a wire
|
|
wire = geompy.MakeWire([vector1, vector2])
|
|
|
|
# create a revolution
|
|
revolution = geompy.MakeRevolution(wire, vector3, 2.3)
|
|
|
|
# add objects in the study
|
|
id_vector3 = geompy.addToStudy(vector3,"Axis")
|
|
id_wire = geompy.addToStudy(wire,"Wire")
|
|
id_revolution = geompy.addToStudy(revolution,"Revolution")
|
|
|
|
# display the vector, the wire and the revolution
|
|
gg.createAndDisplayGO(id_vector3)
|
|
gg.createAndDisplayGO(id_wire)
|
|
gg.createAndDisplayGO(id_revolution)
|
|
gg.setDisplayMode(id_revolution,1)
|
|
\endcode
|
|
|
|
\anchor tui_creation_filling
|
|
<br><h2>Creation of a Filling</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
mindeg = 2
|
|
maxdeg = 5
|
|
tol3d = 0.0001
|
|
tol2d = 0.0001
|
|
nbiter = 5
|
|
|
|
# create a vertex and a vector
|
|
p1 = geompy.MakeVertex( -30., -30., 50.)
|
|
p2 = geompy.MakeVertex( -60., -60., 30.)
|
|
p3 = geompy.MakeVertex( -30., -30., 10.)
|
|
|
|
# create an arc from three points
|
|
arc = geompy.MakeArc(p1, p2, p3)
|
|
ShapeListCompound = []
|
|
i = 0
|
|
while i <= 3 :
|
|
S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
|
|
ShapeListCompound.append(S)
|
|
i = i + 1
|
|
|
|
compound = geompy.MakeCompound(ShapeListCompound)
|
|
|
|
# create a filling
|
|
filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter)
|
|
|
|
# add objects in the study
|
|
id_compound = geompy.addToStudy(compound,"Compound")
|
|
id_filling = geompy.addToStudy(filling,"Filling")
|
|
|
|
# display the compound and the filling
|
|
gg.createAndDisplayGO(id_compound)
|
|
gg.createAndDisplayGO(id_filling)
|
|
gg.setDisplayMode(id_filling,1)
|
|
\endcode
|
|
|
|
\anchor tui_creation_pipe
|
|
<br><h2>Creation of a Pipe</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
# create vertices
|
|
p0 = geompy.MakeVertex(0. , 0. , 0. )
|
|
px = geompy.MakeVertex(100., 0. , 0. )
|
|
py = geompy.MakeVertex(0. , 100., 0. )
|
|
pz = geompy.MakeVertex(0. , 0. , 100.)
|
|
pxyz = geompy.MakeVertex(100., 100., 100.)
|
|
|
|
# create a vector from two points
|
|
vxy = geompy.MakeVector(px, py)
|
|
|
|
# create an arc from three points
|
|
arc = geompy.MakeArc(py, pz, px)
|
|
|
|
# create a wire
|
|
wire = geompy.MakeWire([vxy, arc])
|
|
|
|
# create an edge
|
|
edge = geompy.MakeEdge(p0, pxyz)
|
|
|
|
# create a pipe
|
|
pipe = geompy.MakePipe(wire, edge)
|
|
|
|
# add objects in the study
|
|
id_wire = geompy.addToStudy(wire,"Wire")
|
|
id_edge = geompy.addToStudy(edge,"Edge")
|
|
id_pipe = geompy.addToStudy(pipe,"Pipe")
|
|
|
|
# display the wire, the edge (path) and the pipe
|
|
gg.createAndDisplayGO(id_wire)
|
|
gg.createAndDisplayGO(id_edge)
|
|
gg.createAndDisplayGO(id_pipe)
|
|
gg.setDisplayMode(id_pipe,1)
|
|
\endcode
|
|
|
|
\anchor tui_creation_pipe_with_diff_sec
|
|
<br><h2>Creation of a PipeWithDifferentSections</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
|
|
edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"])
|
|
vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"])
|
|
|
|
# create sections
|
|
circles=[]
|
|
circles.append(geompy.MakeCircle(vertices[0], edges[0], 20))
|
|
circles.append(geompy.MakeCircle(vertices[1], edges[0], 40))
|
|
circles.append(geompy.MakeCircle(vertices[2], edges[2], 30))
|
|
circles.append(geompy.MakeCircle(vertices[3], edges[2], 20))
|
|
|
|
# create pipe
|
|
Pipe = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0)
|
|
|
|
# add objects in the study
|
|
geompy.addToStudy(circles[0], "circles1")
|
|
geompy.addToStudy(circles[1], "circles2")
|
|
geompy.addToStudy(circles[2], "circles3")
|
|
geompy.addToStudy(circles[3], "circles4")
|
|
id_wire = geompy.addToStudy(Wire_1, "Path")
|
|
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
|
|
|
# display the wire(path) and the pipe
|
|
gg.createAndDisplayGO(id_wire)
|
|
gg.createAndDisplayGO(id_pipe)
|
|
gg.setDisplayMode(id_pipe,1)
|
|
\endcode
|
|
|
|
\anchor tui_creation_pipe_with_shell_sec
|
|
<br><h2>Creation of a PipeWithShellSections</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
# create path
|
|
WirePath = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
|
|
|
|
#=======================================================
|
|
# Create shell sections
|
|
#=======================================================
|
|
ps = [Vertex_1,Vertex_2,Vertex_3,Vertex_4]
|
|
theLocations = [Vertex_1, Vertex_2, Vertex_3, Vertex_4]
|
|
VC = geompy.MakeCompound(theLocations)
|
|
geompy.addToStudy(VC,"VC")
|
|
vs = [Edge_1,Edge_1,Edge_3,Edge_3]
|
|
hs = [20,40,30,20]
|
|
shells = []
|
|
subbases = []
|
|
|
|
# 1 section
|
|
c0 = geompy.PointCoordinates(ps[0])
|
|
c1 = geompy.PointCoordinates(ps[1])
|
|
nx = c1[0] - c0[0]
|
|
ny = c1[1] - c0[1]
|
|
nz = c1[2] - c0[2]
|
|
|
|
faces = []
|
|
f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF",
|
|
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
|
f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF",
|
|
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
|
f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF",
|
|
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
|
f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF",
|
|
[c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
|
|
faces.append(f1)
|
|
faces.append(f2)
|
|
faces.append(f3)
|
|
faces.append(f4)
|
|
shell = geompy.MakeSewing(faces,1.e-6)
|
|
shells.append(shell)
|
|
faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"])
|
|
subbases.append(faces[0])
|
|
|
|
# 2 section
|
|
faces = []
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
|
|
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,-1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f1 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
|
|
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,-1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f2 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
|
|
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,-1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f3 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
|
|
[c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,-1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f4 = geompy.MakeFace(w,1)
|
|
|
|
faces.append(f1)
|
|
faces.append(f2)
|
|
faces.append(f3)
|
|
faces.append(f4)
|
|
shell = geompy.MakeSewing(faces,1.e-6)
|
|
shells.append(shell)
|
|
faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"])
|
|
subbases.append(faces[0])
|
|
|
|
# 3 section
|
|
faces = []
|
|
c2 = geompy.PointCoordinates(ps[2])
|
|
c3 = geompy.PointCoordinates(ps[3])
|
|
nx = c3[0] - c2[0]
|
|
ny = c3[1] - c2[1]
|
|
nz = c3[2] - c2[2]
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
|
|
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f1 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
|
|
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f2 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
|
|
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f3 = geompy.MakeFace(w,1)
|
|
|
|
w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
|
|
[c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
|
|
[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
|
|
arc = MakeArc(w,3,1)
|
|
w = geompy.MakeWire([e1,e2,e3,arc])
|
|
f4 = geompy.MakeFace(w,1)
|
|
|
|
faces.append(f1)
|
|
faces.append(f2)
|
|
faces.append(f3)
|
|
faces.append(f4)
|
|
shell = geompy.MakeSewing(faces,1.e-6)
|
|
shells.append(shell)
|
|
faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"])
|
|
subbases.append(faces[2])
|
|
|
|
# 4 section
|
|
faces = []
|
|
|
|
kk = 4
|
|
dx = c3[0] - nx/kk
|
|
dy = c3[1] - ny/kk
|
|
dz = c3[2] - nz/kk
|
|
rad = math.sqrt(nx*nx+ny*ny+nz*nz)
|
|
vc = geompy.MakeVertex(dx,dy,dz)
|
|
sph = geompy.MakeSpherePntR(vc,rad/kk)
|
|
shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"])
|
|
|
|
fs = []
|
|
vec = geompy.MakeVectorDXDYDZ(0,0,1)
|
|
ff = geompy.MakePlane(ps[3],vec,40)
|
|
fs.append(ff)
|
|
vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20)
|
|
ff = geompy.MakePlane(vp,vec,40)
|
|
fs.append(ff)
|
|
vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20)
|
|
ff = geompy.MakePlane(vp,vec,40)
|
|
fs.append(ff)
|
|
vec = geompy.MakeVectorDXDYDZ(1,0,0)
|
|
ff = geompy.MakePlane(ps[3],vec,40)
|
|
fs.append(ff)
|
|
vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2])
|
|
ff = geompy.MakePlane(vp,vec,40)
|
|
fs.append(ff)
|
|
vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2])
|
|
ff = geompy.MakePlane(vp,vec,40)
|
|
fs.append(ff)
|
|
aPartition = geompy.MakePartition(shellsph,fs)
|
|
fs = geompy.SubShapeAllSorted(aPartition, geompy.ShapeType["FACE"])
|
|
|
|
faces.append(fs[0])
|
|
faces.append(fs[1])
|
|
faces.append(fs[2])
|
|
faces.append(fs[3])
|
|
shell = geompy.MakeSewing(faces,1.e-6)
|
|
shells.append(shell)
|
|
faces = geompy.SubShapeAllSorted(shell, geompy.ShapeType["FACE"])
|
|
|
|
|
|
#===========================================================
|
|
# Create Pipe
|
|
#===========================================================
|
|
subbases = []
|
|
Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath,
|
|
theWithContact=0, theWithCorrection=0)
|
|
|
|
# add objects in the study
|
|
resc = geompy.MakeCompound(shells)
|
|
id_sec = geompy.addToStudy(resc,"sections")
|
|
id_wire = geompy.addToStudy(WirePath,"WirePath")
|
|
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
|
|
|
# display the wire(path), sections and the pipe
|
|
gg.createAndDisplayGO(id_wire)
|
|
gg.createAndDisplayGO(id_sec)
|
|
gg.createAndDisplayGO(id_pipe)
|
|
gg.setDisplayMode(id_pipe,1)
|
|
\endcode
|
|
|
|
|
|
\anchor tui_creation_pipe_without_path
|
|
<br><h2>Creation of a PipeShellsWithoutPath</h2>
|
|
|
|
\code
|
|
import geompy
|
|
import math
|
|
import salome
|
|
gg = salome.ImportComponentGUI("GEOM")
|
|
|
|
# Add a section based on quadrangles
|
|
# ----------------------------------
|
|
def section(s, p1, p2=None, p3=None, p4=None):
|
|
if p2==None:
|
|
q = p1
|
|
else:
|
|
q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
|
|
pass
|
|
s.append(q)
|
|
publish(q, "section")
|
|
return q
|
|
|
|
|
|
# find distance between two points
|
|
# -------------------------------
|
|
def Dist(p1,p2):
|
|
c1 = geompy.PointCoordinates(p1)
|
|
c2 = geompy.PointCoordinates(p2)
|
|
return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
|
|
(c2[1]-c1[1])*(c2[1]-c1[1]) +
|
|
(c2[2]-c1[2])*(c2[2]-c1[2]) )
|
|
|
|
|
|
# return middle point
|
|
# -------------------------------
|
|
def MiddleVert(p1,p2):
|
|
c1 = geompy.PointCoordinates(p1)
|
|
c2 = geompy.PointCoordinates(p2)
|
|
return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
|
|
|
|
|
|
# Complex section
|
|
# result - 16 quads from lines
|
|
# pnt - point from path
|
|
# vec - direction from path
|
|
def MakeComplexSect(pnt,vec,rmax,rmin,nb):
|
|
dang = 1.0/nb/2
|
|
cmax = geompy.MakeCircle(pnt,vec,rmax)
|
|
cmin = geompy.MakeCircle(pnt,vec,rmin)
|
|
faces = []
|
|
for i in range(0,2*nb,2):
|
|
p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
|
|
p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
|
|
p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
|
|
f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
|
|
faces.append(f)
|
|
pass
|
|
shell = geompy.MakeSewing(faces,1.e-6)
|
|
return shell
|
|
|
|
|
|
#=======================================================
|
|
# Create simple path and recieve points
|
|
# for section creation
|
|
#=======================================================
|
|
WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
|
|
[0, 0, 0, 0, 0, 1, 1, 0, 0])
|
|
vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
|
|
|
|
#=======================================================
|
|
# Create shell sections
|
|
#=======================================================
|
|
shells = []
|
|
subbases = []
|
|
locs = []
|
|
|
|
# 1 section
|
|
shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
|
|
shells.append(shell)
|
|
vs1 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"])
|
|
locs.append(vs1[17])
|
|
|
|
# 2 section
|
|
shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
|
|
shells.append(shell)
|
|
vs2 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"])
|
|
locs.append(vs2[17])
|
|
|
|
# 3 section
|
|
shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
|
|
shells.append(shell)
|
|
vs3 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"])
|
|
locs.append(vs3[17])
|
|
|
|
# 4 section
|
|
shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
|
|
shells.append(shell)
|
|
vs4 = geompy.SubShapeAllSorted(shell,geompy.ShapeType["VERTEX"])
|
|
locs.append(vs4[17])
|
|
|
|
|
|
#===========================================================
|
|
# Create Pipe
|
|
#===========================================================
|
|
|
|
Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
|
|
|
|
# add objects in the study
|
|
resc = geompy.MakeCompound(shells)
|
|
id_sec = geompy.addToStudy(resc,"sections")
|
|
resl = geompy.MakeCompound(locs)
|
|
id_loc = geompy.addToStudy(resl,"locations")
|
|
id_pipe = geompy.addToStudy(Pipe, "Pipe")
|
|
|
|
# display the sections, locations and pipe
|
|
gg.createAndDisplayGO(id_sec)
|
|
gg.createAndDisplayGO(id_loc)
|
|
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
|
|
|
|
<br><h2>Creation of Tangent Plane On Face</h2>
|
|
\code
|
|
import salome
|
|
import geompy
|
|
|
|
# Create Vertexes for curve
|
|
Vertex_1 = geompy.MakeVertex(0, 0, 0)
|
|
Vertex_2 = geompy.MakeVertex(0, 90, 30)
|
|
Vertex_3 = geompy.MakeVertex(100, 90, 0)
|
|
Vertex_4 = geompy.MakeVertex(-100, 90, 0)
|
|
# Create curve
|
|
Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1])
|
|
# Create Face by Extrusion of the Curve
|
|
Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60)
|
|
# Make Tangent on this Extrusion (Face)
|
|
Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150)
|
|
# Publish in the study
|
|
geompy.addToStudy( Vertex_1, "Vertex_1" )
|
|
geompy.addToStudy( Vertex_2, "Vertex_2" )
|
|
geompy.addToStudy( Vertex_3, "Vertex_3" )
|
|
geompy.addToStudy( Vertex_4, "Vertex_4" )
|
|
geompy.addToStudy( Curve_1, "Curve_1" )
|
|
geompy.addToStudy( Extrusion_1, "Extrusion_1" )
|
|
geompy.addToStudy( Tangent_1, "Tangent_1" )
|
|
\endcode
|
|
|
|
|
|
*/
|