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