Salome HOME
Fix for problem: SIGSEGV appears if to select group after opening "Edit Group" dialog...
[modules/smesh.git] / src / SMESH_SWIG / ex16_cyl2complementary.py
1 # CEA/LGLS 2004-2005, Francis KLOSS (OCC)
2 # =======================================
3
4 from geompy import *
5
6 import smesh
7
8 # Geometry
9 # ========
10
11 # Create the hexahedrical block geometry of a holed parallelepipede.
12 # The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
13 # This piece is meshed in hexahedrical.
14
15 # Values
16 # ------
17
18 gx = 0
19 gy = 0
20 gz = 0
21
22 g_dx = 250
23 g_dy = 200
24 g_dz = 150
25
26 g_rayonGrand = 70
27 g_rayonPetit = 50
28
29 g_trim = 1000
30
31 # The parallelepipede
32 # -------------------
33
34 p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz,  gx+g_dx, gy+g_dy, gz+g_dz)
35
36 # The great cylinder
37 # ------------------
38
39 g_base = MakeVertex(gx-g_dx, gy, gz)
40 g_dir  = MakeVectorDXDYDZ(1, 0, 0)
41 g_cyl  = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
42
43 # The first hole
44 # --------------
45
46 b_boite = MakeCut(p_boite , g_cyl)
47
48 # Partitioning
49 # ------------
50
51 p_base = MakeVertex(gx, gy, gz)
52
53 p_tools = []
54
55 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  1   , 0   ), g_trim))
56 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0,  g_dz, g_dy), g_trim))
57 p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
58
59 p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
60 p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
61
62 p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"])
63
64 # The small cylinder
65 # ------------------
66
67 c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
68
69 # The second hole
70 # ---------------
71
72 d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"])
73
74 d_element[ 8] = MakeCut(d_element[ 8], c_cyl)
75 d_element[10] = MakeCut(d_element[10], c_cyl)
76
77 # Compound
78 # --------
79
80 piece = RemoveExtraEdges(MakeCompound(d_element))
81
82 # Add piece in study
83 # ------------------
84
85 piece_id = addToStudy(piece, "ex16_cyl2complementary")
86
87 # Meshing
88 # =======
89
90 # Create a hexahedral mesh
91 # ------------------------
92
93 hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
94
95 algo = hexa.Segment()
96 algo.NumberOfSegments(12)
97
98 hexa.Quadrangle()
99
100 hexa.Hexahedron()
101
102 # Define local hypothesis
103 # -----------------------
104
105 def local(x, y, z, d):
106     edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
107     algo = hexa.Segment(edge)
108     algo.NumberOfSegments(d)
109     algo.Propagation()
110
111 local(gx     , gy+g_dy, gz+g_dz, 7)
112 local(gx+g_dx, gy+g_dy, gz     , 21)
113 local(gx+g_dx, gy-g_dy, gz     , 21)
114
115 # Mesh calculus
116 # -------------
117
118 hexa.Compute()