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