Salome HOME
activateModule/deactivateModule functions are made "bool".
[modules/smesh.git] / src / SMESH_SWIG / ex19_sphereINcube.py
1 # CEA/LGLS 2005, Francis KLOSS (OCC)
2 # ==================================
3
4 from geompy import *
5
6 import smesh
7
8 # Geometrie
9 # =========
10
11 # Mailler en hexahedre une sphere dans un cube.
12
13 # Donnees
14 # -------
15
16 sphere_rayon = 100
17
18 cube_cote = 200
19
20 plan_trim = 1000
21
22 # Sphere
23 # ------
24
25 sphere_centre = MakeVertex(0, 0, 0)
26
27 sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
28
29 # Cube interieur
30 # --------------
31
32 boite_cote = sphere_rayon / 2
33
34 boite = MakeBox(-boite_cote, -boite_cote, -boite_cote,  +boite_cote, +boite_cote, +boite_cote)
35
36 blocs = [boite]
37
38 # Decoupage sphere
39 # ----------------
40
41 sphere_troue = MakeCut(sphere_pleine, boite)
42
43 sphere_outils = []
44 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0,  1), plan_trim))
45 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim))
46 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1,  0), plan_trim))
47 sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1,  0), plan_trim))
48
49 sphere_decoupee = MakePartition([sphere_troue], sphere_outils, [], [], ShapeType["SOLID"])
50
51 sphere_partie   = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
52 sphere_bloc     = RemoveExtraEdges(sphere_partie)
53
54 blocs.append(sphere_bloc)
55
56 pi2 = 3.141592653/2
57
58 sphere_dir1 = MakeVectorDXDYDZ(0, 1,  0)
59 sphere_dir2 = MakeVectorDXDYDZ(0, 0,  1)
60
61 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
62 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
63
64 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
65 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
66
67 blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
68
69 # Cube exterieur
70 # --------------
71
72 cube_plein   = MakeBox(-cube_cote, -cube_cote, -cube_cote,  +cube_cote, +cube_cote, +cube_cote)
73 cube_trou    = MakeCut(cube_plein, sphere_pleine)
74 cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
75 cube_partie  = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
76 cube_bloc    = RemoveExtraEdges(cube_partie)
77
78 blocs.append(cube_bloc)
79
80 blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
81 blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
82
83 blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
84 blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
85
86 blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
87
88 # Piece
89 # -----
90
91 piece_cpd = MakeCompound(blocs)
92 piece = MakeGlueFaces(piece_cpd, 1.e-3)
93
94 piece_id = addToStudy(piece, "ex19_sphereINcube")
95
96 # Groupe geometrique
97 # ==================
98
99 # Definition du groupe
100 # --------------------
101
102 groupe = CreateGroup(piece, ShapeType["SOLID"])
103
104 groupe_nom = "ex19_sphereINcube_interieur"
105 addToStudy(groupe, groupe_nom)
106 groupe.SetName(groupe_nom)
107
108 # Contenu du groupe
109 # -----------------
110
111 groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
112
113 UnionList(groupe, groupe_sphere)
114
115 # Meshing
116 # =======
117
118 # Create a hexahedral mesh
119 # ------------------------
120
121 hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
122
123 algo = hexa.Segment()
124 algo.NumberOfSegments(10)
125
126 hexa.Quadrangle()
127
128 hexa.Hexahedron()
129
130 # Mesh calculus
131 # -------------
132
133 hexa.Compute()
134
135 # Le groupe de mailles
136 # --------------------
137
138 hexa_groupe = hexa.Group(groupe)