Salome HOME
7a28cfe4b8408e6a699aaae1b7a0070c9a1bcc10
[modules/geom.git] / src / GEOM_SWIG / GEOM_cyl2complementary.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #==============================================================================
23 #  Info.
24 #  Bug (from script, bug)   : cyl2complementary_modified.py, PAL6700
25 #  Modified                 : 25/11/2004
26 #  Author                   : Kovaltchuk Alexey
27 #  Project                  : PAL/SALOME
28 #==============================================================================
29 # Import
30 # ------
31 #
32 import salome
33 import geompy
34 geomgui = salome.ImportComponentGUI("GEOM") 
35 import salome_ComponentGUI
36 def addToStudy(shape, name):
37     i = geompy.addToStudy(shape, name)
38     salome.sg.updateObjBrowser(0)
39     if not isinstance(geomgui, type(salome_ComponentGUI)):
40         geomgui.createAndDisplayGO(i)
41     return i
42
43 # Piece
44 # -----
45
46 # Creer la geometrie en bloc hexahedrique d'un parallelepipede troue d'une piece en forme de T composee de 2 cylindres de diametre different dont les axes se coupent orthogonalement,
47 # puis mailler en hexahedrique.
48
49 gx = 0
50 gy = 0
51 gz = 0
52
53 g_dx = 250
54 g_dy = 200
55 g_dz = 150
56
57 g_rayonGrand = 70
58 g_rayonPetit = 50
59
60 # Geometrie
61 # =========
62
63 # Le parallelepipede
64 # ------------------
65
66 p_boite = geompy.MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
67
68 # Le grand cylindre
69 # -----------------
70
71 g_base = geompy.MakeVertex(gx-g_dx, gy, gz)
72 g_dir  = geompy.MakeVectorDXDYDZ(1, 0, 0)
73 g_cyl  = geompy.MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
74
75 # Le petit cylindre
76 # -----------------
77
78 c_base = geompy.MakeVertex(gx, gy, gz)
79 c_dir  = geompy.MakeVectorDXDYDZ(0, 0, 1)
80 c_cyl  = geompy.MakeCylinder(c_base, c_dir, g_rayonPetit, g_dz)
81
82 # Le parallelepipede troue
83 # ------------------------
84
85 t_boite1 = geompy.MakeBoolean(p_boite , g_cyl, 2)
86 t_boite  = geompy.MakeBoolean(t_boite1, c_cyl, 2)
87
88 # Partitionner
89 # ------------
90
91 p_tools = []
92
93 p_tools.append(geompy.MakePlane(c_base, geompy.MakeVectorDXDYDZ(0,  g_dz, g_dy), 10))
94 p_tools.append(geompy.MakePlane(c_base, geompy.MakeVectorDXDYDZ(0, -g_dz, g_dy), 10))
95
96 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx-g_rayonPetit, 0, 0), geompy.MakeVectorDXDYDZ(1, 0, 0), 10))
97 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx+g_rayonPetit, 0, 0), geompy.MakeVectorDXDYDZ(1, 0, 0), 10))
98
99 addToStudy(t_boite, "t_boite")
100
101 p_element = geompy.MakePartition([t_boite], p_tools, [], [], 4, 0, [], 0)
102
103 # Compound
104 # --------
105
106 # Ajouter la piece dans l'etude
107 # -----------------------------
108
109 idpiece = addToStudy(p_element, "BoxHoled2Cylinders")