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