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