1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # =======================================
31 # Construire avec des hexahedres une piece faite de 2 cylindres de diametre different
32 # et dont les axes se coupent orthogonalement, puis mailler.
54 g_base = MakeVertex(cx, cy, cz)
55 g_dir = MakeVectorDXDYDZ(0, 0, 1)
56 t_hauteur = p_rayon+10.0
58 g_cyl = MakeCylinder(g_base, g_dir, g_rayon, g_hauteur)
60 g_coupe = MakeVectorDXDYDZ(1, 0, 0)
63 g_tools.append(MakePlane(MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim))
64 g_tools.append(MakePlane(MakeVertex(cx-t_hauteur, cy, cz), g_coupe, g_trim))
66 g_partie = MakePartition([g_cyl], g_tools, [], [], ShapeType["SOLID"])
67 g_bas, g_centre, g_haut = SubShapeAllSorted(g_partie, ShapeType["SOLID"])
69 # Partie basse du gros cylindre
70 # -----------------------------
75 b_boite = MakeBox(cx-t_hauteur, cy-b_base, cz, cx-t_hauteur-b_hauteur, cy+b_base, cz+g_hauteur)
78 b_cyl = MakeCut(g_bas, b_boite)
81 b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy+b_base, cz), MakeVectorDXDYDZ( 1, 1, 0), g_trim))
82 b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy-b_base, cz), MakeVectorDXDYDZ(-1, 1, 0), g_trim))
84 b_partie = MakePartition([b_cyl], b_tools, [], [], ShapeType["SOLID"])
85 b_element = SubShapeAll(b_partie, ShapeType["SOLID"])
88 # Partie haute du gros cylindre
89 # -----------------------------
91 h_plan = MakePlane(g_base, g_coupe, g_trim)
93 cpd.append(MakeMirrorByPlane(b_boite, h_plan))
96 h_symetrie = MakeMirrorByPlane(h, h_plan)
97 cpd.append(h_symetrie)
103 x_arete = z_arete*t_hauteur*2/g_hauteur
109 p_base = MakeVertex(cx, py, pz)
110 p_dir = MakeVectorDXDYDZ(0, 1, 0)
111 p_cyl = MakeCylinder(p_base, p_dir, p_rayon, p_hauteur)
113 p_boite = MakeBox(px, py, pz-z_arete, cx+x_arete, py+p_hauteur, pz+z_arete)
115 # Partie interieure du petit cylindre
116 # -----------------------------------
118 i_cyl = MakeCommon(p_cyl, g_cyl)
119 i_tuyau = MakeCut(i_cyl, p_boite)
120 i_boite = MakeCommon(p_boite, g_cyl)
122 # Partie exterieure du petit cylindre
123 # -----------------------------------
125 e_cyl0 = MakeCut(p_cyl, g_cyl)
126 e_cyl = SubShapeAllSorted(e_cyl0, ShapeType["SOLID"])
128 e_tuyau = MakeCut(e_cyl[1], p_boite)
130 e_boite0 = MakeCut(p_boite, g_cyl)
131 e_boite = SubShapeAllSorted(e_boite0, ShapeType["SOLID"])
133 cpd.append(e_boite[1])
135 # Partie centrale du gros cylindre
136 # --------------------------------
138 c_cyl = MakeCut(g_centre, p_cyl)
144 p_tools.append(MakePlane(MakeVertex(px, py, pz-z_arete), MakeVectorDXDYDZ(-z_arete, 0, x_arete), g_trim))
145 p_tools.append(MakePlane(MakeVertex(px, py, pz+z_arete), MakeVectorDXDYDZ( z_arete, 0, x_arete), g_trim))
147 p_partie = MakePartition([e_tuyau], p_tools, [], [], ShapeType["SOLID"])
148 p_element = SubShapeAll(p_partie, ShapeType["SOLID"])
149 cpd = cpd + p_element
151 q_partie = MakePartition([i_tuyau, c_cyl], p_tools, [], [], ShapeType["SOLID"])
152 q_element = SubShapeAll(q_partie, ShapeType["SOLID"])
154 q_element = q_element + [i_boite]
157 q_tools.append(MakePlane(MakeVertex(cx, cy-b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim))
158 q_tools.append(MakePlane(MakeVertex(cx, cy+b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim))
162 r_partie = MakePartition([e], q_tools, [], [], ShapeType["SOLID"])
163 r_element = r_element + SubShapeAll(r_partie, ShapeType["SOLID"])
165 cpd = cpd + r_element
170 piece = RemoveExtraEdges(MakeCompound(cpd))
172 # Ajouter la piece dans l'etude
173 # -----------------------------
175 piece_id = addToStudy(piece, "ex15_cyl2geometry")
180 # Create a hexahedral mesh
181 # ------------------------
183 hexa = smesh.Mesh(piece, "ex15_cyl2geometry:hexa")
185 algo = hexa.Segment()
186 algo.NumberOfSegments(12)