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