Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESH_SWIG / ex03_cube2partition.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/ or email : webmaster.salome@opencascade.com
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 # A small cube centered and put on a great cube build with partition
31
32 # Values
33 # ------
34
35 g_ox = 0
36 g_oy = 0
37 g_oz = 0
38
39 g_arete = 10
40
41 g_trim = 1000
42
43 # Points
44 # ------
45
46 v_arete2 = g_arete*2
47 v_arete3 = g_arete*3
48
49 v_1 = MakeVertex(g_ox         , g_oy         , g_oz         )
50 v_2 = MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3)
51
52 v_3 = MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete )
53 v_4 = MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2)
54
55 # Solids
56 # ------
57
58 s_base = MakeBoxTwoPnt(v_1, v_2)
59 s_haut = MakeBoxTwoPnt(v_3, v_4)
60
61 # Partition
62 # ---------
63
64 p_dir1 = MakeVectorDXDYDZ(1, 0, 0)
65 p_dir2 = MakeVectorDXDYDZ(0, 0, 1)
66 p_dir3 = MakeVectorDXDYDZ(0, 1, 0)
67
68 p_tools = []
69
70 p_tools.append(MakePlane(v_3, p_dir1, g_trim))
71 p_tools.append(MakePlane(v_4, p_dir1, g_trim))
72 p_tools.append(MakePlane(v_3, p_dir2, g_trim))
73 p_tools.append(MakePlane(v_4, p_dir2, g_trim))
74 p_tools.append(MakePlane(v_3, p_dir3, g_trim))
75
76 piece = MakePartition([s_base, s_haut], p_tools, [], [], ShapeType["SOLID"])
77
78 # Study
79 # -----
80
81 piece_id = addToStudy(piece, "ex03_cube2partition")
82
83 # Meshing
84 # =======
85
86 # Create hexahedrical mesh on piece
87 # ---------------------------------
88
89 hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa")
90
91 algo = hexa.Segment()
92 algo.NumberOfSegments(5)
93
94 hexa.Quadrangle()
95
96 hexa.Hexahedron()
97
98 # Compute the mesh
99 # ----------------
100
101 hexa.Compute()