Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / ex02_cube2primitive.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # =======================================
23 #
24 from geompy import *
25
26 import smesh
27
28 # Geometry
29 # ========
30
31 # A small cube centered and put on a great cube build by primitive geometric functionalities
32
33 # Values
34 # ------
35
36 ox = 0
37 oy = 0
38 oz = 0
39
40 arete = 10
41
42 # Points
43 # ------
44
45 blockPoint111 = MakeVertex(ox      , oy, oz)
46 blockPoint211 = MakeVertex(ox+arete, oy, oz)
47 blockPoint112 = MakeVertex(ox      , oy, oz+arete)
48 blockPoint212 = MakeVertex(ox+arete, oy, oz+arete)
49
50 # Face and solid
51 # --------------
52
53 blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112)
54
55 blockSolid11  = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete)
56
57 # Translations
58 # ------------
59
60 blockSolid21  = MakeTranslation(blockSolid11, arete, 0, 0)
61 blockSolid31  = MakeTranslation(blockSolid21, arete, 0, 0)
62
63 blockSolid12  = MakeTranslation(blockSolid11, 0, 0, arete)
64 blockSolid22  = MakeTranslation(blockSolid12, arete, 0, 0)
65 blockSolid32  = MakeTranslation(blockSolid22, arete, 0, 0)
66
67 blockSolid13  = MakeTranslation(blockSolid12, 0, 0, arete)
68 blockSolid23  = MakeTranslation(blockSolid13, arete, 0, 0)
69 blockSolid33  = MakeTranslation(blockSolid23, arete, 0, 0)
70
71 blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0)
72
73 # Compound and glue
74 # -----------------
75
76 c_l = []
77 c_l.append(blockSolid11)
78 c_l.append(blockSolid21)
79 c_l.append(blockSolid31)
80 c_l.append(blockSolid12)
81 c_l.append(blockSolid22)
82 c_l.append(blockSolid32)
83 c_l.append(blockSolid13)
84 c_l.append(blockSolid23)
85 c_l.append(blockSolid33)
86 c_l.append(blockSolid111)
87
88 c_cpd = MakeCompound(c_l)
89
90 piece = MakeGlueFaces(c_cpd, 1.e-5)
91
92 # Add in study
93 # ------------
94
95 piece_id = addToStudy(piece, "ex02_cube2primitive")
96
97 # Meshing
98 # =======
99
100 # Create hexahedrical mesh on piece
101 # ---------------------------------
102
103 hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa")
104
105 algo = hexa.Segment()
106 algo.LocalLength(1)
107
108 hexa.Quadrangle()
109
110 hexa.Hexahedron()
111
112 # Compute the mesh
113 # ----------------
114
115 hexa.Compute()