Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / ex16_cyl2complementary.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
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.
8 #
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.
13 #
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
17 #
18 #  See http://www.salome-platform.org/
19 #
20 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
21 # =======================================
22
23 from geompy import *
24
25 import smesh
26
27 # Geometry
28 # ========
29
30 # Create the hexahedrical block geometry of a holed parallelepipede.
31 # The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
32 # This piece is meshed in hexahedrical.
33
34 # Values
35 # ------
36
37 gx = 0
38 gy = 0
39 gz = 0
40
41 g_dx = 250
42 g_dy = 200
43 g_dz = 150
44
45 g_rayonGrand = 70
46 g_rayonPetit = 50
47
48 g_trim = 1000
49
50 # The parallelepipede
51 # -------------------
52
53 p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
54
55 # The great cylinder
56 # ------------------
57
58 g_base = MakeVertex(gx-g_dx, gy, gz)
59 g_dir  = MakeVectorDXDYDZ(1, 0, 0)
60 g_cyl  = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
61
62 # The first hole
63 # --------------
64
65 b_boite = MakeCut(p_boite , g_cyl)
66
67 # Partitioning
68 # ------------
69
70 p_base = MakeVertex(gx, gy, gz)
71
72 p_tools = []
73
74 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  1   , 0   ), g_trim))
75 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  g_dz, g_dy), g_trim))
76 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
77
78 p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
79 p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
80
81 p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"])
82
83 # The small cylinder
84 # ------------------
85
86 c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
87
88 # The second hole
89 # ---------------
90
91 d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"])
92
93 d_element[ 8] = MakeCut(d_element[ 8], c_cyl)
94 d_element[10] = MakeCut(d_element[10], c_cyl)
95
96 # Compound
97 # --------
98
99 piece = RemoveExtraEdges(MakeCompound(d_element))
100
101 # Add piece in study
102 # ------------------
103
104 piece_id = addToStudy(piece, "ex16_cyl2complementary")
105
106 # Meshing
107 # =======
108
109 # Create a hexahedral mesh
110 # ------------------------
111
112 hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
113
114 algo = hexa.Segment()
115 algo.NumberOfSegments(12)
116
117 hexa.Quadrangle()
118
119 hexa.Hexahedron()
120
121 # Define local hypothesis
122 # -----------------------
123
124 def local(x, y, z, d):
125     edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
126     algo = hexa.Segment(edge)
127     algo.NumberOfSegments(d)
128     algo.Propagation()
129
130 local(gx     , gy+g_dy, gz+g_dz, 7)
131 local(gx+g_dx, gy+g_dy, gz     , 21)
132 local(gx+g_dx, gy-g_dy, gz     , 21)
133
134 # Mesh calculus
135 # -------------
136
137 hexa.Compute()