mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 01:58:36 +05:00
Changes for bug 0019915 from Mantis.
This commit is contained in:
parent
32973c2072
commit
a60b0da186
@ -190,4 +190,357 @@ 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
|
||||
|
||||
*/
|
||||
|
@ -938,7 +938,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
# orthogonal to the spine tangent in the correspondent point
|
||||
# @return New GEOM_Object, containing the created pipe.
|
||||
#
|
||||
# @ref swig_todo "Example"
|
||||
# @ref tui_creation_pipe_with_diff_sec "Example"
|
||||
def MakePipeWithDifferentSections(self, theSeqBases,
|
||||
theLocations, thePath,
|
||||
theWithContact, theWithCorrection):
|
||||
@ -949,10 +949,16 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
return anObj
|
||||
|
||||
## Create a shape by extrusion of the profile shape along
|
||||
# the path shape. The path shape can be a shell or a face.
|
||||
# the path shape. The path shape can be a wire or a edge.
|
||||
# the several profiles can be specified in the several locations of path.
|
||||
# @param theSeqBases - list of Bases shape to be extruded.
|
||||
# @param theSeqBases - list of Bases shape to be extruded. Base shape must be
|
||||
# shell or face. If number of faces in neighbour sections
|
||||
# aren't coincided result solid between such sections will
|
||||
# be created using external boundaries of this shells.
|
||||
# @param theSeqSubBases - list of corresponding subshapes of section shapes.
|
||||
# This list is used for searching correspondences between
|
||||
# faces in the sections. Size of this list must be equal
|
||||
# to size of list of base shapes.
|
||||
# @param theLocations - list of locations on the path corresponding
|
||||
# specified list of the Bases shapes. Number of locations
|
||||
# should be equal to number of bases. First and last
|
||||
@ -965,7 +971,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
# orthogonal to the spine tangent in the correspondent point
|
||||
# @return New GEOM_Object, containing the created solids.
|
||||
#
|
||||
# @ref swig_todo "Example"
|
||||
# @ref tui_creation_pipe_with_shell_sec "Example"
|
||||
def MakePipeWithShellSections(self,theSeqBases, theSeqSubBases,
|
||||
theLocations, thePath,
|
||||
theWithContact, theWithCorrection):
|
||||
@ -975,6 +981,12 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
RaiseIfFailed("MakePipeWithShellSections", self.PrimOp)
|
||||
return anObj
|
||||
|
||||
## Create a shape by extrusion of the profile shape along
|
||||
# the path shape. This function is used only for debug pipe
|
||||
# functionality - it is a version of previous function
|
||||
# (MakePipeWithShellSections(...)) which give a possibility to
|
||||
# recieve information about creating pipe between each pair of
|
||||
# sections step by step.
|
||||
def MakePipeWithShellSectionsBySteps(self, theSeqBases, theSeqSubBases,
|
||||
theLocations, thePath,
|
||||
theWithContact, theWithCorrection):
|
||||
@ -1011,7 +1023,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
# @param theLocations - list of corresponding vertexes
|
||||
# @return New GEOM_Object, containing the created solids.
|
||||
#
|
||||
# @ref swig_todo "Example"
|
||||
# @ref tui_creation_pipe_without_path "Example"
|
||||
def MakePipeShellsWithoutPath(self, theSeqBases, theLocations):
|
||||
anObj = self.PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations)
|
||||
RaiseIfFailed("MakePipeShellsWithoutPath", self.PrimOp)
|
||||
|
Loading…
Reference in New Issue
Block a user