Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / ex14_cyl1holed.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 # Geometrie
30 # =========
31
32 # Creer un cylindre avec un trou cylindrique excentre, decoupage en hexahedre et mailler.
33
34 # Donnees
35 # -------
36
37 # unite: millimetre
38
39 g_ox = 0
40 g_oy = 0
41 g_oz = 0
42
43 g_cyl_rayon       = 1000
44 g_cyl_demiHauteur = 3000
45
46 g_trou_rayon       =   5
47 g_trou_centre      = 300
48
49 g_trim = 15000
50
51 # Construire le cylindre
52 # ----------------------
53
54 c_point    = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
55 c_dir      = MakeVectorDXDYDZ(0, 0, 1)
56 c_hauteur  = 2*g_cyl_demiHauteur
57 c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
58
59 # Trouer le cylindre par un minuscule cylindre excentre
60 # -----------------------------------------------------
61
62 t_hauteur = g_cyl_demiHauteur
63 t_point   = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
64 t_trou    = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
65
66 t_piece   = MakeCut(c_cylindre, t_trou)
67
68 # Geometrie hexahedrique
69 # ======================
70
71 # Decouper
72 # --------
73
74 h_outils = []
75 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
76 h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
77
78 h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
79
80 # Decouper pour les conditions locales
81 # ------------------------------------
82
83 l_outils = []
84 l_i = 1
85 l_n = 12
86 l_hauteur = c_hauteur/l_n
87
88 while l_i<l_n:
89     l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
90     l_i = l_i+1
91
92 piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
93
94 # Ajouter la piece dans l'etude
95 # -----------------------------
96
97 piece_id = addToStudy(piece, "ex14_cyl1holed")
98
99 # Maillage
100 # ========
101
102 # Creer un maillage hexahedrique
103 # ------------------------------
104
105 hexa = smesh.Mesh(piece, "ex14_cyl1holed:hexa")
106
107 algo = hexa.Segment()
108 algo.NumberOfSegments(4)
109
110 hexa.Quadrangle()
111
112 hexa.Hexahedron()
113
114 # Poser les hypotheses locales
115 # ----------------------------
116
117 m_i = 0
118 m_n = 12
119 m_h = c_hauteur/m_n
120 m_d = [4, 6, 8, 10, 10, 9, 8, 7, 6, 5, 4, 3]
121
122 m_x = g_ox+g_cyl_rayon
123 m_y = g_oy
124 m_z = g_oz-g_cyl_demiHauteur+m_h/2
125
126 while m_i<m_n:
127     m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
128     m_e = GetEdgeNearPoint(piece, m_p)
129     m_a = hexa.Segment(m_e)
130     m_a.NumberOfSegments(m_d[m_i])
131     m_a.Propagation()
132     m_i = m_i + 1
133
134 # Calculer le maillage
135 # --------------------
136
137 hexa.Compute()