Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / ex09_grid4build.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 import math
30
31 # Geometry
32 # ========
33
34 # Element of a grid compound by a square with a cylinder on each vertex build by points, edges, faces and solids
35
36 # Values
37 # ------
38
39 ox = 0
40 oy = 0
41 oz = 0
42
43 arete   =  50
44 hauteur = 100
45
46 rayon = 10
47
48 demi = rayon/2
49 r3   = demi*math.sqrt(3)
50
51 # Points
52 # ------
53
54 piecePoint111 = MakeVertex(ox+rayon      , oy, oz)
55 piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz)
56 piecePoint112 = MakeVertex(ox            , oy, oz+rayon)
57 piecePoint212 = MakeVertex(ox+arete      , oy, oz+rayon)
58 piecePoint113 = MakeVertex(ox            , oy, oz+arete-rayon)
59 piecePoint213 = MakeVertex(ox+arete      , oy, oz+arete-rayon)
60 piecePoint114 = MakeVertex(ox+rayon      , oy, oz+arete)
61 piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete)
62
63 pieceCenter1  = MakeVertex(ox            , oy, oz)
64 pieceCenter2  = MakeVertex(ox+arete      , oy, oz)
65 pieceCenter3  = MakeVertex(ox            , oy, oz+arete)
66 pieceCenter4  = MakeVertex(ox+arete      , oy, oz+arete)
67
68 piecePass1    = MakeVertex(ox+demi       , oy, oz+r3)
69 piecePass2    = MakeVertex(ox+arete-demi , oy, oz+r3)
70 piecePass3    = MakeVertex(ox+arete-demi , oy, oz+arete-r3)
71 piecePass4    = MakeVertex(ox+demi       , oy, oz+arete-r3)
72
73 # Edges
74 # -----
75
76 pieceEdgeSquare1   = MakeEdge(piecePoint111, piecePoint211)
77 pieceEdgeSquare2   = MakeEdge(piecePoint114, piecePoint214)
78 pieceEdgeSquare3   = MakeEdge(piecePoint112, piecePoint113)
79 pieceEdgeSquare4   = MakeEdge(piecePoint212, piecePoint213)
80
81 pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213)
82 pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214)
83
84 pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112)
85 pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212)
86 pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214)
87 pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114)
88
89 # Faces
90 # -----
91
92 pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1)
93 pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2)
94
95 pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2)
96
97 # Solids
98 # ------
99
100 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
101
102 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
103 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
104 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
105
106 # Compound and glue
107 # -----------------
108
109 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3])
110
111 piece = MakeGlueFaces(c_cpd, 1.e-5)
112
113 # Add in study
114 # ------------
115
116 piece_id = addToStudy(piece, "ex09_grid4build")
117
118 # Meshing
119 # =======
120
121 # Create a hexahedral mesh
122 # ------------------------
123
124 hexa = smesh.Mesh(piece, "ex09_grid4build:hexa")
125
126 algo = hexa.Segment()
127 algo.NumberOfSegments(6)
128
129 hexa.Quadrangle()
130
131 hexa.Hexahedron()
132
133 # Mesh calculus
134 # -------------
135
136 hexa.Compute()