Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / ex02_cube2primitive.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 # A small cube centered and put on a great cube build by primitive geometric functionalities
33
34 # Values
35 # ------
36
37 ox = 0
38 oy = 0
39 oz = 0
40
41 arete = 10
42
43 # Points
44 # ------
45
46 blockPoint111 = MakeVertex(ox      , oy, oz)
47 blockPoint211 = MakeVertex(ox+arete, oy, oz)
48 blockPoint112 = MakeVertex(ox      , oy, oz+arete)
49 blockPoint212 = MakeVertex(ox+arete, oy, oz+arete)
50
51 # Face and solid
52 # --------------
53
54 blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112)
55
56 blockSolid11  = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete)
57
58 # Translations
59 # ------------
60
61 blockSolid21  = MakeTranslation(blockSolid11, arete, 0, 0)
62 blockSolid31  = MakeTranslation(blockSolid21, arete, 0, 0)
63
64 blockSolid12  = MakeTranslation(blockSolid11, 0, 0, arete)
65 blockSolid22  = MakeTranslation(blockSolid12, arete, 0, 0)
66 blockSolid32  = MakeTranslation(blockSolid22, arete, 0, 0)
67
68 blockSolid13  = MakeTranslation(blockSolid12, 0, 0, arete)
69 blockSolid23  = MakeTranslation(blockSolid13, arete, 0, 0)
70 blockSolid33  = MakeTranslation(blockSolid23, arete, 0, 0)
71
72 blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0)
73
74 # Compound and glue
75 # -----------------
76
77 c_l = []
78 c_l.append(blockSolid11)
79 c_l.append(blockSolid21)
80 c_l.append(blockSolid31)
81 c_l.append(blockSolid12)
82 c_l.append(blockSolid22)
83 c_l.append(blockSolid32)
84 c_l.append(blockSolid13)
85 c_l.append(blockSolid23)
86 c_l.append(blockSolid33)
87 c_l.append(blockSolid111)
88
89 c_cpd = MakeCompound(c_l)
90
91 piece = MakeGlueFaces(c_cpd, 1.e-5)
92
93 # Add in study
94 # ------------
95
96 piece_id = addToStudy(piece, "ex02_cube2primitive")
97
98 # Meshing
99 # =======
100
101 # Create hexahedrical mesh on piece
102 # ---------------------------------
103
104 hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa")
105
106 algo = hexa.Segment()
107 algo.LocalLength(1)
108
109 hexa.Quadrangle()
110
111 hexa.Hexahedron()
112
113 # Compute the mesh
114 # ----------------
115
116 hexa.Compute()