1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # ==================================
34 # Mailler en hexahedre une sphere dans un cube.
48 sphere_centre = MakeVertex(0, 0, 0)
50 sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
55 boite_cote = sphere_rayon / 2
57 boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
64 sphere_troue = MakeCut(sphere_pleine, boite)
67 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim))
68 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim))
69 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim))
70 #sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim))
72 f1 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim)
73 f2 = MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim)
74 f3 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim)
75 f4 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim)
78 #sphere_decoupee = MakePartition(solids, sphere_outils, [], [], ShapeType["SOLID"])
79 solids = geompy.SubShapeAll(sphere_troue,geompy.ShapeType["SOLID"])
80 sphere_decoupee = MakePartition(solids, [f1], [], [], ShapeType["SOLID"])
81 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
82 sphere_decoupee = MakePartition(solids, [f2], [], [], ShapeType["SOLID"])
83 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
84 sphere_decoupee = MakePartition(solids, [f3], [], [], ShapeType["SOLID"])
85 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
86 sphere_decoupee = MakePartition(solids, [f4], [], [], ShapeType["SOLID"])
87 solids = geompy.SubShapeAll(sphere_decoupee,geompy.ShapeType["SOLID"])
89 sphere_partie = geompy.MakeCompound(solids)
91 sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
92 sphere_bloc = RemoveExtraEdges(sphere_partie)
94 blocs.append(sphere_bloc)
98 sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
99 sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
101 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
102 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
104 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
105 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
107 blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
112 cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
113 cube_trou = MakeCut(cube_plein, sphere_pleine)
114 #cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
116 solids = geompy.SubShapeAll(cube_trou,geompy.ShapeType["SOLID"])
117 cube_decoupe = MakePartition(solids, [f1], [], [], ShapeType["SOLID"])
118 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
119 cube_decoupe = MakePartition(solids, [f2], [], [], ShapeType["SOLID"])
120 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
121 cube_decoupe = MakePartition(solids, [f3], [], [], ShapeType["SOLID"])
122 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
123 cube_decoupe = MakePartition(solids, [f4], [], [], ShapeType["SOLID"])
124 solids = geompy.SubShapeAll(cube_decoupe,geompy.ShapeType["SOLID"])
126 cube_decoupe = geompy.MakeCompound(solids)
129 cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
130 cube_bloc = RemoveExtraEdges(cube_partie)
132 blocs.append(cube_bloc)
134 blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
135 blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
137 blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
138 blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
140 blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
145 piece_cpd = MakeCompound(blocs)
146 piece = MakeGlueFaces(piece_cpd, 1.e-3)
148 piece_id = addToStudy(piece, "ex19_sphereINcube")
153 # Definition du groupe
154 # --------------------
156 groupe = CreateGroup(piece, ShapeType["SOLID"])
158 groupe_nom = "ex19_sphereINcube_interieur"
159 addToStudy(groupe, groupe_nom)
160 groupe.SetName(groupe_nom)
165 groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
167 UnionList(groupe, groupe_sphere)
172 smesh.SetCurrentStudy(salome.myStudy)
174 # Create a hexahedral mesh
175 # ------------------------
177 hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
179 algo = hexa.Segment()
180 algo.NumberOfSegments(10)
191 # Le groupe de mailles
192 # --------------------
194 hexa_groupe = hexa.Group(groupe)