Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_SWIG / ex08_hole2build.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 twice holed cube build by points, edges, faces and solids
32
33 # Values
34 # ------
35
36 ox = 0
37 oy = 0
38 oz = 0
39
40 longueur = 200
41 largeur  = 100
42 hauteur  =  80
43
44 cylindre = 50
45
46 rayon = 20
47
48 # Points
49 # ------
50
51 piecePoint1 = MakeVertex(ox         , oy, oz)
52 piecePoint2 = MakeVertex(ox+longueur, oy, oz)
53 piecePoint3 = MakeVertex(ox+longueur, oy, oz+largeur)
54 piecePoint4 = MakeVertex(ox         , oy, oz+largeur)
55
56 cz = oz+largeur/2
57
58 cylPoint1    = MakeVertex(ox+cylindre         , oy, cz-rayon)
59 cylPoint2    = MakeVertex(ox+longueur-cylindre, oy, cz-rayon)
60 cylPoint3    = MakeVertex(ox+longueur-cylindre, oy, cz+rayon)
61 cylPoint4    = MakeVertex(ox+cylindre         , oy, cz+rayon)
62
63 # Edges
64 # -----
65
66 pieceEdge1 = MakeEdge(piecePoint1, piecePoint4)
67 pieceEdge2 = MakeEdge(piecePoint1, cylPoint1)
68 pieceEdge3 = MakeEdge(piecePoint4, cylPoint4)
69
70 pieceEdge4 = MakeEdge(piecePoint2, piecePoint3)
71 pieceEdge5 = MakeEdge(piecePoint2, cylPoint2)
72 pieceEdge6 = MakeEdge(piecePoint3, cylPoint3)
73
74 pieceEdge7 = MakeEdge(cylPoint1, cylPoint2)
75 pieceEdge8 = MakeEdge(cylPoint3, cylPoint4)
76
77 cylEdge1 = MakeArc(cylPoint1, MakeVertex(ox+cylindre-rayon         , oy, cz), cylPoint4)
78 cylEdge2 = MakeArc(cylPoint1, MakeVertex(ox+cylindre+rayon         , oy, cz), cylPoint4)
79 cylEdge3 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3)
80 cylEdge4 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3)
81
82 # Faces
83 # -----
84
85 pieceFace1 = MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 )
86 pieceFace2 = MakeQuad         (pieceEdge1 , pieceEdge2 , cylEdge1  , pieceEdge3)
87 pieceFace3 = MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 )
88 pieceFace4 = MakeQuad         (pieceEdge4 , pieceEdge5 , cylEdge4  , pieceEdge6)
89 pieceFace5 = MakeQuad         (pieceEdge7 , cylEdge3   , pieceEdge8, cylEdge2  )
90
91 # Solids
92 # ------
93
94 pieceVector = MakeVectorDXDYDZ(0, 1, 0)
95
96 pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
97 pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
98 pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
99 pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur)
100 pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur)
101
102 # Compound and glue
103 # -----------------
104
105 c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5])
106
107 piece = MakeGlueFaces(c_cpd, 1.e-5)
108
109 # Add in study
110 # ------------
111
112 piece_id = addToStudy(piece, "ex08_hole2build")
113
114 # Meshing
115 # =======
116
117 # Create a hexahedral mesh
118 # ------------------------
119
120 hexa = smesh.Mesh(piece, "ex08_hole2build:hexa")
121
122 algo = hexa.Segment()
123 algo.NumberOfSegments(7)
124
125 hexa.Quadrangle()
126
127 hexa.Hexahedron()
128
129 # Mesh calculus
130 # -------------
131
132 hexa.Compute()