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/ or email : webmaster.salome@opencascade.com
20 # CEA/LGLS 2005, Francis KLOSS (OCC)
21 # ==================================
31 # Mailler en hexahedre une sphere dans un cube.
45 sphere_centre = MakeVertex(0, 0, 0)
47 sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
52 boite_cote = sphere_rayon / 2
54 boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
61 sphere_troue = MakeCut(sphere_pleine, boite)
64 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim))
65 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim))
66 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim))
67 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim))
69 f1 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim)
70 f2 = MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim)
71 f3 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim)
72 f4 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim)
75 #sphere_decoupee = MakePartition(solids, sphere_outils, [], [], ShapeType["SOLID"])
76 solids = geompy.SubShapeAll(sphere_troue,geompy.ShapeType["SOLID"])
77 sphere_decoupee = MakePartition(solids, [f1], [], [], ShapeType["SOLID"])
78 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
79 sphere_decoupee = MakePartition(solids, [f2], [], [], ShapeType["SOLID"])
80 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
81 sphere_decoupee = MakePartition(solids, [f3], [], [], ShapeType["SOLID"])
82 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
83 sphere_decoupee = MakePartition(solids, [f4], [], [], ShapeType["SOLID"])
84 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
86 sphere_partie = geompy.MakeCompound(solids)
88 sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
89 sphere_bloc = RemoveExtraEdges(sphere_partie)
91 blocs.append(sphere_bloc)
95 sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
96 sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
98 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
99 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
101 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
102 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
104 blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
109 cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
110 cube_trou = MakeCut(cube_plein, sphere_pleine)
111 #cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
113 solids = geompy.SubShapeAll(cube_trou,geompy.ShapeType["SOLID"])
114 cube_decoupe = MakePartition(solids, [f1], [], [], ShapeType["SOLID"])
115 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
116 cube_decoupe = MakePartition(solids, [f2], [], [], ShapeType["SOLID"])
117 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
118 cube_decoupe = MakePartition(solids, [f3], [], [], ShapeType["SOLID"])
119 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
120 cube_decoupe = MakePartition(solids, [f4], [], [], ShapeType["SOLID"])
121 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
123 cube_decoupe = geompy.MakeCompound(solids)
126 cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
127 cube_bloc = RemoveExtraEdges(cube_partie)
129 blocs.append(cube_bloc)
131 blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
132 blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
134 blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
135 blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
137 blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
142 piece_cpd = MakeCompound(blocs)
143 piece = MakeGlueFaces(piece_cpd, 1.e-3)
145 piece_id = addToStudy(piece, "ex19_sphereINcube")
150 # Definition du groupe
151 # --------------------
153 groupe = CreateGroup(piece, ShapeType["SOLID"])
155 groupe_nom = "ex19_sphereINcube_interieur"
156 addToStudy(groupe, groupe_nom)
157 groupe.SetName(groupe_nom)
162 groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
164 UnionList(groupe, groupe_sphere)
169 # Create a hexahedral mesh
170 # ------------------------
172 hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
174 algo = hexa.Segment()
175 algo.NumberOfSegments(10)
186 # Le groupe de mailles
187 # --------------------
189 hexa_groupe = hexa.Group(groupe)