1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/
20 # CEA/LGLS 2005, Francis KLOSS (OCC)
21 # ==================================
30 # Mailler en hexahedre une sphere dans un cube.
44 sphere_centre = MakeVertex(0, 0, 0)
46 sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
51 boite_cote = sphere_rayon / 2
53 boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
60 sphere_troue = MakeCut(sphere_pleine, boite)
63 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim))
64 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim))
65 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim))
66 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim))
68 sphere_decoupee = MakePartition([sphere_troue], sphere_outils, [], [], ShapeType["SOLID"])
70 sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
71 sphere_bloc = RemoveExtraEdges(sphere_partie)
73 blocs.append(sphere_bloc)
77 sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
78 sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
80 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
81 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
83 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
84 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
86 blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
91 cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
92 cube_trou = MakeCut(cube_plein, sphere_pleine)
93 cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
94 cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
95 cube_bloc = RemoveExtraEdges(cube_partie)
97 blocs.append(cube_bloc)
99 blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
100 blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
102 blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
103 blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
105 blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
110 piece_cpd = MakeCompound(blocs)
111 piece = MakeGlueFaces(piece_cpd, 1.e-3)
113 piece_id = addToStudy(piece, "ex19_sphereINcube")
118 # Definition du groupe
119 # --------------------
121 groupe = CreateGroup(piece, ShapeType["SOLID"])
123 groupe_nom = "ex19_sphereINcube_interieur"
124 addToStudy(groupe, groupe_nom)
125 groupe.SetName(groupe_nom)
130 groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
132 UnionList(groupe, groupe_sphere)
137 # Create a hexahedral mesh
138 # ------------------------
140 hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
142 algo = hexa.Segment()
143 algo.NumberOfSegments(10)
154 # Le groupe de mailles
155 # --------------------
157 hexa_groupe = hexa.Group(groupe)