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