Salome HOME
Merge from V6_main 13/12/2012
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_complex_objs.doc
1 /*!
2
3 \page tui_complex_objs_page Complex Objects
4
5 \anchor tui_creation_prism
6 <br><h2>Creation of a Prism</h2>
7
8 \code
9 import geompy
10 import salome
11 gg = salome.ImportComponentGUI("GEOM")
12
13 # create a vertex and a vector
14 p1 = geompy.MakeVertex(   0.,   0.,   0.)
15 p2 = geompy.MakeVertex( 100.,   0.,   0.)
16 p3 = geompy.MakeVertex( 100., 100.,   0.)
17 p4 = geompy.MakeVertex(   0., 100.,   0.)
18 p5 = geompy.MakeVertex(   0.,   0.,  60.)
19 p6 = geompy.MakeVertex(-100.,   0.,   0.)
20 p7 = geompy.MakeVertex(-100.,-100.,   0.)
21 p8 = geompy.MakeVertex(   0.,-100.,   0.)
22
23 # create a vector from the given components
24 vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)
25
26 #create vectors from two points
27 vector1_arc1 = geompy.MakeVector(p1, p2)
28 vector2_arc1 = geompy.MakeVector(p1, p4)
29 vector1_arc2 = geompy.MakeVector(p1, p6)
30 vector2_arc2 = geompy.MakeVector(p1, p8)
31
32 # create arcs from three points
33 arc1 = geompy.MakeArc(p2, p3, p4)
34 arc2 = geompy.MakeArc(p6, p7, p8)
35
36 # create wires
37 wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])
38 wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])
39
40 # create faces
41 isPlanarWanted = 1
42 face1 = geompy.MakeFace(wire1, isPlanarWanted)
43 face2 = geompy.MakeFace(wire2, isPlanarWanted)
44
45 # create prisms
46 prism1 = geompy.MakePrism(face2, p1, p5)
47 prism2 = geompy.MakePrismVecH(face1, vector, 50)
48 prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50)
49
50 # add objects in the study
51 id_face1   = geompy.addToStudy(face1,"Face1")
52 id_face2   = geompy.addToStudy(face2,"Face2")
53 id_prism1 = geompy.addToStudy(prism1,"Prism1")
54 id_prism2 = geompy.addToStudy(prism2,"Prism2")
55 id_prism3 = geompy.addToStudy(prism3,"Prism3")
56
57 # display cylinders
58 gg.createAndDisplayGO(id_face1)
59 gg.setDisplayMode(id_face1,1)
60 gg.createAndDisplayGO(id_face2)
61 gg.setDisplayMode(id_face2,1)
62 gg.createAndDisplayGO(id_prism1)
63 gg.setDisplayMode(id_prism1,1)
64 gg.createAndDisplayGO(id_prism2)
65 gg.setDisplayMode(id_prism2,1) 
66 gg.createAndDisplayGO(id_prism3)
67 gg.setDisplayMode(id_prism3,1) 
68 \endcode
69
70 \anchor tui_creation_revolution
71 <br><h2>Creation of a Revolution</h2>
72
73 \code
74 import geompy
75 import salome
76 gg = salome.ImportComponentGUI("GEOM")
77
78 # create a vertex and a vector
79 p1 = geompy.MakeVertex(  10.,  10.,  10.)
80 p2 = geompy.MakeVertex(  15.,  15.,  50.)
81 p3 = geompy.MakeVertex(  40.,  40.,   0.)
82
83 #create vectors from two points
84 vector1 = geompy.MakeVector(p1, p2)
85 vector2 = geompy.MakeVector(p1, p3)
86
87 # create a vector from the given components
88 vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.)
89
90 # create a wire
91 wire = geompy.MakeWire([vector1, vector2])
92
93 # create a revolution
94 revolution = geompy.MakeRevolution(wire, vector3, 2.3)
95
96 # add objects in the study
97 id_vector3    = geompy.addToStudy(vector3,"Axis")
98 id_wire       = geompy.addToStudy(wire,"Wire")
99 id_revolution = geompy.addToStudy(revolution,"Revolution")
100
101 # display the vector, the wire and the revolution
102 gg.createAndDisplayGO(id_vector3)
103 gg.createAndDisplayGO(id_wire)
104 gg.createAndDisplayGO(id_revolution)
105 gg.setDisplayMode(id_revolution,1) 
106 \endcode
107
108 \anchor tui_creation_filling
109 <br><h2>Creation of a Filling</h2>
110
111 \code
112 import geompy
113 import salome
114 gg = salome.ImportComponentGUI("GEOM")
115
116 mindeg = 2
117 maxdeg = 5
118 tol3d  = 0.0001
119 tol2d  = 0.0001
120 nbiter = 5
121
122 # create a vertex and a vector
123 p1 = geompy.MakeVertex(  -30.,  -30.,  50.)
124 p2 = geompy.MakeVertex(  -60.,  -60.,  30.)
125 p3 = geompy.MakeVertex(  -30.,  -30.,  10.)
126
127 # create an arc from three points
128 arc = geompy.MakeArc(p1, p2, p3)
129 ShapeListCompound = []
130 i = 0
131 while i <= 3 :
132     S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
133     ShapeListCompound.append(S)
134     i = i + 1
135
136 compound = geompy.MakeCompound(ShapeListCompound)
137
138 # create a filling
139 filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter)
140
141 # add objects in the study
142 id_compound = geompy.addToStudy(compound,"Compound")
143 id_filling = geompy.addToStudy(filling,"Filling")
144
145 # display the compound and the filling
146 gg.createAndDisplayGO(id_compound)
147 gg.createAndDisplayGO(id_filling)
148 gg.setDisplayMode(id_filling,1) 
149 \endcode
150  
151 \anchor tui_creation_pipe
152 <br><h2>Creation of a Pipe</h2>
153
154 \code
155 import geompy
156 import salome
157 gg = salome.ImportComponentGUI("GEOM")
158
159 # create vertices
160 p0   = geompy.MakeVertex(0.  , 0.  , 0.  )
161 px   = geompy.MakeVertex(100., 0.  , 0.  )
162 py   = geompy.MakeVertex(0.  , 100., 0.  )
163 pz   = geompy.MakeVertex(0.  , 0.  , 100.)
164 pxyz = geompy.MakeVertex(100., 100., 100.)
165
166 # create a vector from two points
167 vxy = geompy.MakeVector(px, py)
168
169 # create an arc from three points
170 arc = geompy.MakeArc(py, pz, px)
171
172 # create a wire
173 wire = geompy.MakeWire([vxy, arc])
174
175 # create an edge
176 edge = geompy.MakeEdge(p0, pxyz)
177
178 # create a pipe
179 pipe = geompy.MakePipe(wire, edge)
180
181 # add objects in the study
182 id_wire = geompy.addToStudy(wire,"Wire")
183 id_edge = geompy.addToStudy(edge,"Edge")
184 id_pipe = geompy.addToStudy(pipe,"Pipe")
185
186 # display the wire, the edge (path) and the pipe
187 gg.createAndDisplayGO(id_wire)
188 gg.createAndDisplayGO(id_edge)
189 gg.createAndDisplayGO(id_pipe)
190 gg.setDisplayMode(id_pipe,1) 
191 \endcode
192
193 \anchor tui_creation_pipe_with_diff_sec
194 <br><h2>Creation of a PipeWithDifferentSections</h2>
195
196 \code
197 import geompy
198 import salome
199 gg = salome.ImportComponentGUI("GEOM")
200
201 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])
202 edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"])
203 vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"])
204
205 # create sections
206 circles=[]
207 circles.append(geompy.MakeCircle(vertices[0], edges[0], 20))
208 circles.append(geompy.MakeCircle(vertices[1], edges[0], 40))
209 circles.append(geompy.MakeCircle(vertices[2], edges[2], 30))
210 circles.append(geompy.MakeCircle(vertices[3], edges[2], 20))
211
212 # create pipe
213 Pipe = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0)
214
215 # add objects in the study
216 geompy.addToStudy(circles[0], "circles1")
217 geompy.addToStudy(circles[1], "circles2")
218 geompy.addToStudy(circles[2], "circles3")
219 geompy.addToStudy(circles[3], "circles4")
220 id_wire = geompy.addToStudy(Wire_1, "Path")
221 id_pipe = geompy.addToStudy(Pipe, "Pipe")
222
223 # display the wire(path) and the pipe
224 gg.createAndDisplayGO(id_wire)
225 gg.createAndDisplayGO(id_pipe)
226 gg.setDisplayMode(id_pipe,1) 
227 \endcode
228
229 \anchor tui_creation_pipe_with_shell_sec
230 <br><h2>Creation of a PipeWithShellSections</h2>
231
232 \code
233 import geompy
234 import salome
235 gg = salome.ImportComponentGUI("GEOM")
236
237 # create path
238 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])
239
240 #=======================================================
241 #                 Create shell sections
242 #=======================================================
243 ps = [Vertex_1,Vertex_2,Vertex_3,Vertex_4]
244 theLocations = [Vertex_1, Vertex_2, Vertex_3, Vertex_4]
245 VC = geompy.MakeCompound(theLocations)
246 geompy.addToStudy(VC,"VC")
247 vs = [Edge_1,Edge_1,Edge_3,Edge_3]
248 hs = [20,40,30,20]
249 shells = []
250 subbases = []
251
252 # 1 section
253 c0 = geompy.PointCoordinates(ps[0])
254 c1 = geompy.PointCoordinates(ps[1])
255 nx = c1[0] - c0[0]
256 ny = c1[1] - c0[1]
257 nz = c1[2] - c0[2]
258
259 faces = []
260 f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF",
261                          [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
262 f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF",
263                          [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
264 f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF",
265                          [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
266 f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF",
267                          [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
268 faces.append(f1)
269 faces.append(f2)
270 faces.append(f3)
271 faces.append(f4)
272 shell = geompy.MakeSewing(faces,1.e-6)
273 shells.append(shell)
274 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
275 subbases.append(faces[0])
276
277 # 2 section
278 faces = []
279
280 w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
281                          [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
282 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
283 arc = MakeArc(w,3,-1)
284 w = geompy.MakeWire([e1,e2,e3,arc])
285 f1 = geompy.MakeFace(w,1)
286
287 w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
288                          [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
289 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
290 arc = MakeArc(w,3,-1)
291 w = geompy.MakeWire([e1,e2,e3,arc])
292 f2 = geompy.MakeFace(w,1)
293
294 w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
295                          [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
296 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
297 arc = MakeArc(w,3,-1)
298 w = geompy.MakeWire([e1,e2,e3,arc])
299 f3 = geompy.MakeFace(w,1)
300
301 w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
302                          [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
303 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
304 arc = MakeArc(w,3,-1)
305 w = geompy.MakeWire([e1,e2,e3,arc])
306 f4 = geompy.MakeFace(w,1)
307
308 faces.append(f1)
309 faces.append(f2)
310 faces.append(f3)
311 faces.append(f4)
312 shell = geompy.MakeSewing(faces,1.e-6)
313 shells.append(shell)
314 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
315 subbases.append(faces[0])
316
317 # 3 section
318 faces = []
319 c2 = geompy.PointCoordinates(ps[2])
320 c3 = geompy.PointCoordinates(ps[3])
321 nx = c3[0] - c2[0]
322 ny = c3[1] - c2[1]
323 nz = c3[2] - c2[2]
324
325 w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
326                          [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
327 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
328 arc = MakeArc(w,3,1)
329 w = geompy.MakeWire([e1,e2,e3,arc])
330 f1 = geompy.MakeFace(w,1)
331
332 w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
333                          [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
334 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
335 arc = MakeArc(w,3,1)
336 w = geompy.MakeWire([e1,e2,e3,arc])
337 f2 = geompy.MakeFace(w,1)
338
339 w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
340                          [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
341 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
342 arc = MakeArc(w,3,1)
343 w = geompy.MakeWire([e1,e2,e3,arc])
344 f3 = geompy.MakeFace(w,1)
345
346 w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
347                          [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
348 [e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"])
349 arc = MakeArc(w,3,1)
350 w = geompy.MakeWire([e1,e2,e3,arc])
351 f4 = geompy.MakeFace(w,1)
352
353 faces.append(f1)
354 faces.append(f2)
355 faces.append(f3)
356 faces.append(f4)
357 shell = geompy.MakeSewing(faces,1.e-6)
358 shells.append(shell)
359 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
360 subbases.append(faces[2])
361
362 # 4 section
363 faces = []
364
365 kk = 4
366 dx = c3[0] - nx/kk
367 dy = c3[1] - ny/kk
368 dz = c3[2] - nz/kk
369 rad = math.sqrt(nx*nx+ny*ny+nz*nz)
370 vc = geompy.MakeVertex(dx,dy,dz)
371 sph = geompy.MakeSpherePntR(vc,rad/kk)
372 shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"])
373
374 fs = []
375 vec = geompy.MakeVectorDXDYDZ(0,0,1)
376 ff = geompy.MakePlane(ps[3],vec,40)
377 fs.append(ff)
378 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20)
379 ff = geompy.MakePlane(vp,vec,40)
380 fs.append(ff)
381 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20)
382 ff = geompy.MakePlane(vp,vec,40)
383 fs.append(ff)
384 vec = geompy.MakeVectorDXDYDZ(1,0,0)
385 ff = geompy.MakePlane(ps[3],vec,40)
386 fs.append(ff)
387 vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2])
388 ff = geompy.MakePlane(vp,vec,40)
389 fs.append(ff)
390 vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2])
391 ff = geompy.MakePlane(vp,vec,40)
392 fs.append(ff)
393 aPartition = geompy.MakePartition(shellsph,fs)
394 fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"])
395
396 faces.append(fs[0])
397 faces.append(fs[1])
398 faces.append(fs[2])
399 faces.append(fs[3])
400 shell = geompy.MakeSewing(faces,1.e-6)
401 shells.append(shell)
402 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
403
404
405 #===========================================================
406 #                   Create Pipe
407 #===========================================================
408 subbases = []
409 Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath,
410                                         theWithContact=0, theWithCorrection=0)
411
412 # add objects in the study
413 resc = geompy.MakeCompound(shells)
414 id_sec = geompy.addToStudy(resc,"sections")
415 id_wire = geompy.addToStudy(WirePath,"WirePath")
416 id_pipe = geompy.addToStudy(Pipe, "Pipe")
417
418 # display the wire(path), sections and the pipe
419 gg.createAndDisplayGO(id_wire)
420 gg.createAndDisplayGO(id_sec)
421 gg.createAndDisplayGO(id_pipe)
422 gg.setDisplayMode(id_pipe,1) 
423 \endcode
424
425
426 \anchor tui_creation_pipe_without_path
427 <br><h2>Creation of a PipeShellsWithoutPath</h2>
428
429 \code
430 import geompy
431 import math
432 import salome
433 gg = salome.ImportComponentGUI("GEOM")
434
435 # Add a section based on quadrangles
436 # ----------------------------------
437 def section(s, p1, p2=None, p3=None, p4=None):
438     if p2==None:
439         q = p1
440     else:
441         q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
442         pass
443     s.append(q)
444     publish(q, "section")
445     return q
446
447
448 # find distance between two points
449 # -------------------------------
450 def Dist(p1,p2):
451     c1 = geompy.PointCoordinates(p1)
452     c2 = geompy.PointCoordinates(p2)
453     return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
454                       (c2[1]-c1[1])*(c2[1]-c1[1]) +
455                       (c2[2]-c1[2])*(c2[2]-c1[2]) )
456
457
458 # return middle point
459 # -------------------------------
460 def MiddleVert(p1,p2):
461     c1 = geompy.PointCoordinates(p1)
462     c2 = geompy.PointCoordinates(p2)
463     return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
464
465
466 # Complex section
467 # result - 16 quads from lines
468 # pnt - point from path
469 # vec - direction from path
470 def MakeComplexSect(pnt,vec,rmax,rmin,nb):
471     dang = 1.0/nb/2
472     cmax = geompy.MakeCircle(pnt,vec,rmax)
473     cmin = geompy.MakeCircle(pnt,vec,rmin)
474     faces = []
475     for i in range(0,2*nb,2):
476         p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
477         p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
478         p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
479         f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
480         faces.append(f)
481         pass
482     shell = geompy.MakeSewing(faces,1.e-6)
483     return shell
484
485
486 #=======================================================
487 #       Create simple path and recieve points
488 #              for section creation
489 #=======================================================
490 WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
491                                [0, 0, 0, 0, 0, 1, 1, 0, 0])
492 vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
493
494 #=======================================================
495 #                 Create shell sections
496 #=======================================================
497 shells = []
498 subbases = []
499 locs = []
500
501 # 1 section
502 shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
503 shells.append(shell)
504 vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
505 locs.append(vs1[17])
506
507 # 2 section
508 shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
509 shells.append(shell)
510 vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
511 locs.append(vs2[17])
512
513 # 3 section
514 shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
515 shells.append(shell)
516 vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
517 locs.append(vs3[17])
518
519 # 4 section
520 shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
521 shells.append(shell)
522 vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
523 locs.append(vs4[17])
524
525
526 #===========================================================
527 #                   Create Pipe
528 #===========================================================
529
530 Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
531
532 # add objects in the study
533 resc = geompy.MakeCompound(shells)
534 id_sec = geompy.addToStudy(resc,"sections")
535 resl = geompy.MakeCompound(locs)
536 id_loc = geompy.addToStudy(resl,"locations")
537 id_pipe = geompy.addToStudy(Pipe, "Pipe")
538
539 # display the sections, locations and pipe
540 gg.createAndDisplayGO(id_sec)
541 gg.createAndDisplayGO(id_loc)
542 gg.createAndDisplayGO(id_pipe)
543 gg.setDisplayMode(id_pipe,1) 
544 \endcode
545
546 \anchor tui_creation_pipe_binormal_along_vector
547 <br><h2>Creation of a PipeBiNormalAlongVector</h2>
548
549 \code
550 def MakeHelix(radius, height, rotation, direction):
551     #  - create a helix -
552     radius = 1.0 * radius
553     height = 1.0 * height
554     rotation = 1.0 * rotation
555     if direction > 0:
556         direction = +1
557     else:
558         direction = -1
559         pass
560     from math import sqrt
561     length_z  = height
562     length_xy = radius*rotation
563     length = sqrt(length_z*length_z + length_xy*length_xy)
564     import geompy
565     nb_steps = 1
566     epsilon = 1.0e-6
567     while 1:
568         z_step = height / nb_steps
569         angle_step = rotation / nb_steps
570         z = 0.0
571         angle = 0.0
572         helix_points = []
573         for n in range(nb_steps+1):
574             from math import cos, sin
575             x = radius * cos(angle)
576             y = radius * sin(angle)
577             p = geompy.MakeVertex(x, y, z)
578             helix_points.append( p )
579             z += z_step
580             angle += direction * angle_step
581             pass
582         helix = geompy.MakeInterpol(helix_points)
583         length_test = geompy.BasicProperties(helix)[0]
584         prec = abs(length-length_test)/length
585         # print nb_steps, length_test, prec
586         if prec < epsilon:
587             break
588         nb_steps *= 2
589         pass
590     return helix
591
592 def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0):
593     #  - create a pipe -
594     thread_radius = 1.0 * thread_radius
595     # create a helix
596     helix = MakeHelix(radius, height, rotation, direction)
597     # base in the (Ox, Oz) plane
598     import geompy
599     p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius)
600     p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius)
601     p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius)
602     p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius)
603     e0 = geompy.MakeEdge(p0, p1)
604     e1 = geompy.MakeEdge(p1, p2)
605     e2 = geompy.MakeEdge(p2, p3)
606     e3 = geompy.MakeEdge(p3, p0)
607     w = geompy.MakeWire([e0, e1, e2, e3])
608     # create a base face
609     base = geompy.MakeFace(w, True)
610     # create a binormal vector
611     binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0)
612     # create a pipe
613     spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal)
614     # Publish in the study
615     geompy.addToStudy(base, "base")
616     geompy.addToStudy(helix, "helix")
617     geompy.addToStudy(binormal, "binormal")
618     geompy.addToStudy(spring, "spring")
619     return spring
620
621 from math import pi
622
623 spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)
624 \endcode
625
626
627 \anchor tui_creation_pipe_path
628 <br><h2>Creation of a Middle Path</h2>
629
630 \code
631 import salome
632 import geompy
633
634 # Create a box
635 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
636
637 # Get two opposite faces
638 [Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33])
639
640 # Get edges
641 Box_1_edge_12 = geompy.GetSubShape(Box_1, [12])
642 Box_1_edge_22 = geompy.GetSubShape(Box_1, [22])
643 Box_1_edge_25 = geompy.GetSubShape(Box_1, [25])
644 Box_1_edge_29 = geompy.GetSubShape(Box_1, [29])
645 Box_1_edge_8 = geompy.GetSubShape(Box_1, [8])
646 Box_1_edge_18 = geompy.GetSubShape(Box_1, [18])
647 Box_1_edge_26 = geompy.GetSubShape(Box_1, [26])
648 Box_1_edge_30 = geompy.GetSubShape(Box_1, [30])
649
650 # These three calls to RestorePath return the same result
651 Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2)
652 Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2])
653 Path_3 = geompy.RestorePathEdges(Box_1,
654                                  [Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29],
655                                  [Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30])
656
657 # Publish created objects
658 geompy.addToStudy( Box_1, 'Box_1' )
659 geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' )
660 geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' )
661 geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' )
662 geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' )
663 geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' )
664 geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' )
665 geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' )
666 geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' )
667 geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' )
668 geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' )
669 geompy.addToStudy( Path_1, 'Path_1' )
670 geompy.addToStudy( Path_2, 'Path_2' )
671 geompy.addToStudy( Path_3, 'Path_3' )
672 \endcode
673
674 <br><h2>Creation of Tangent Plane On Face</h2>
675 \code
676 import salome
677 import geompy
678
679 # Create Vertexes for curve
680 Vertex_1 = geompy.MakeVertex(0, 0, 0)
681 Vertex_2 = geompy.MakeVertex(0, 90, 30)
682 Vertex_3 = geompy.MakeVertex(100, 90, 0)
683 Vertex_4 = geompy.MakeVertex(-100, 90, 0)
684 # Create curve
685 Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1])
686 # Create Face by Extrusion of the Curve
687 Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60)
688 # Make Tangent on this Extrusion (Face)
689 Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150)
690 # Publish in the study
691 geompy.addToStudy( Vertex_1, "Vertex_1" )
692 geompy.addToStudy( Vertex_2, "Vertex_2" )
693 geompy.addToStudy( Vertex_3, "Vertex_3" )
694 geompy.addToStudy( Vertex_4, "Vertex_4" )
695 geompy.addToStudy( Curve_1, "Curve_1" )
696 geompy.addToStudy( Extrusion_1, "Extrusion_1" )
697 geompy.addToStudy( Tangent_1, "Tangent_1" )
698 \endcode
699
700 */