1 # Creation of a PipeShellsWithoutPath
6 gg = salome.ImportComponentGUI("GEOM")
8 # Add a section based on quadrangles
9 # ----------------------------------
10 def section(s, p1, p2=None, p3=None, p4=None):
14 q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
21 # find distance between two points
22 # -------------------------------
24 c1 = geompy.PointCoordinates(p1)
25 c2 = geompy.PointCoordinates(p2)
26 return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
27 (c2[1]-c1[1])*(c2[1]-c1[1]) +
28 (c2[2]-c1[2])*(c2[2]-c1[2]) )
32 # -------------------------------
33 def MiddleVert(p1,p2):
34 c1 = geompy.PointCoordinates(p1)
35 c2 = geompy.PointCoordinates(p2)
36 return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
40 # result - 16 quads from lines
41 # pnt - point from path
42 # vec - direction from path
43 def MakeComplexSect(pnt,vec,rmax,rmin,nb):
45 cmax = geompy.MakeCircle(pnt,vec,rmax)
46 cmin = geompy.MakeCircle(pnt,vec,rmin)
48 for i in range(0,2*nb,2):
49 p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
50 p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
51 p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
52 f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
55 shell = geompy.MakeSewing(faces,1.e-6)
59 #=======================================================
60 # Create simple path and recieve points
61 # for section creation
62 #=======================================================
63 WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
64 [0, 0, 0, 0, 0, 1, 1, 0, 0])
65 vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
67 #=======================================================
68 # Create shell sections
69 #=======================================================
75 shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
77 vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
81 shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
83 vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
87 shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
89 vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
93 shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
95 vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
99 #===========================================================
101 #===========================================================
103 Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
105 # add objects in the study
106 resc = geompy.MakeCompound(shells)
107 id_sec = geompy.addToStudy(resc,"sections")
108 resl = geompy.MakeCompound(locs)
109 id_loc = geompy.addToStudy(resl,"locations")
110 id_pipe = geompy.addToStudy(Pipe, "Pipe")
112 # display the sections, locations and pipe
113 gg.createAndDisplayGO(id_sec)
114 gg.createAndDisplayGO(id_loc)
115 gg.createAndDisplayGO(id_pipe)
116 gg.setDisplayMode(id_pipe,1)