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