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