Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / ex18_dome2.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/
19 #
20 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
21 # =======================================
22
23 from geompy import *
24
25 import smesh
26
27 import math
28
29 # Geometrie
30 # =========
31
32 # Creer un cylindre ayant a chaque bout un morceau de sphere et le tout troue par un petit cylindrique excentre.
33 # Decouper en hexahedre et mailler.
34
35 # Donnees
36 # -------
37
38 # unite: millimetre
39
40 g_ox = 0
41 g_oy = 0
42 g_oz = 0
43
44 g_cyl_rayon       = 1000
45 g_cyl_demiHauteur = 3000
46
47 g_trou_rayon       =   5
48 g_trou_centre      = 300
49
50 g_sphere_rayon = 3500
51
52 g_trim = 15000
53
54 # Cylindre
55 # --------
56
57 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
58 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
59 c_hauteur  = 2*g_cyl_demiHauteur
60
61 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
62
63 # Sphere
64 # ------
65
66 s_hauteur = math.sqrt(g_sphere_rayon*g_sphere_rayon - g_cyl_rayon*g_cyl_rayon) - g_cyl_demiHauteur
67
68 s_sphere  = MakeSphere(g_ox, g_oy, g_oz-s_hauteur, g_sphere_rayon)
69
70 # Calottes
71 # --------
72
73 c_outils = []
74 c_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz+g_cyl_demiHauteur), MakeVectorDXDYDZ(0, 0, 1), g_trim))
75
76 c_cpd = MakePartition([s_sphere], c_outils, [], [], ShapeType["SOLID"])
77 c_calotte_haut, c_reste = SubShapeAllSorted(c_cpd, ShapeType["SOLID"])
78
79 c_plan = MakePlane(MakeVertex(g_ox, g_oy, g_oz), MakeVectorDXDYDZ(0, 0, 1), g_trim)
80 c_calotte_bas = MakeMirrorByPlane(c_calotte_haut, c_plan)
81
82 # Fusionner
83 # ---------
84
85 f_piece1 = MakeFuse(c_cylindre, c_calotte_haut)
86 f_piece  = MakeFuse(f_piece1, c_calotte_bas)
87
88 # Trouer
89 # ------
90
91 t_hauteur = g_sphere_rayon
92 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
93 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
94
95 t_piece   = MakeCut(f_piece, t_trou)
96
97 # Decouper
98 # --------
99
100 h_outils = []
101 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
102 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
103
104 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
105
106 # Reparer
107 # -------
108
109 piece = RemoveExtraEdges(h_piece)
110
111 # Ajouter la piece dans l'etude
112 # -----------------------------
113
114 piece_id = addToStudy(piece, "ex18_dome2")
115
116 # Maillage
117 # ========
118
119 # Maillage hexahedrique
120 # ---------------------
121
122 hexa = smesh.Mesh(piece, "ex18_dome2:hexa")
123
124 algo = hexa.Segment()
125 algo.NumberOfSegments(2)
126
127 hexa.Quadrangle()
128
129 hexa.Hexahedron()
130
131 # Calcul du maillage
132 # ------------------
133
134 hexa.Compute()