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