1 # Creation of a PipeShellsWithoutPath
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
9 gg = salome.ImportComponentGUI("GEOM")
11 # Add a section based on quadrangles
12 # ----------------------------------
13 def section(s, p1, p2=None, p3=None, p4=None):
17 q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
24 # find distance between two points
25 # -------------------------------
27 c1 = geompy.PointCoordinates(p1)
28 c2 = geompy.PointCoordinates(p2)
29 return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
30 (c2[1]-c1[1])*(c2[1]-c1[1]) +
31 (c2[2]-c1[2])*(c2[2]-c1[2]) )
35 # -------------------------------
36 def MiddleVert(p1,p2):
37 c1 = geompy.PointCoordinates(p1)
38 c2 = geompy.PointCoordinates(p2)
39 return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
43 # result - 16 quads from lines
44 # pnt - point from path
45 # vec - direction from path
46 def MakeComplexSect(pnt,vec,rmax,rmin,nb):
48 cmax = geompy.MakeCircle(pnt,vec,rmax)
49 cmin = geompy.MakeCircle(pnt,vec,rmin)
51 for i in range(0,2*nb,2):
52 p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
53 p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
54 p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
55 f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
58 shell = geompy.MakeSewing(faces,1.e-6)
62 #=======================================================
63 # Create simple path and recieve points
64 # for section creation
65 #=======================================================
66 WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
67 [0, 0, 0, 0, 0, 1, 1, 0, 0])
68 vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
70 #=======================================================
71 # Create shell sections
72 #=======================================================
78 shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
80 vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
84 shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
86 vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
90 shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
92 vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
96 shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
98 vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
102 #===========================================================
104 #===========================================================
106 Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
108 # add objects in the study
109 resc = geompy.MakeCompound(shells)
110 id_sec = geompy.addToStudy(resc,"sections")
111 resl = geompy.MakeCompound(locs)
112 id_loc = geompy.addToStudy(resl,"locations")
113 id_pipe = geompy.addToStudy(Pipe, "Pipe")
115 # display the sections, locations and pipe
116 gg.createAndDisplayGO(id_sec)
117 gg.createAndDisplayGO(id_loc)
118 gg.createAndDisplayGO(id_pipe)
119 gg.setDisplayMode(id_pipe,1)