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