Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / ex05_hole1build.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 # A centered holed cube build by  build by points, edges, faces and solids
33
34 # Values
35 # ------
36
37 ox = 0
38 oy = 0
39 oz = 0
40
41 longueur = 100
42 largeur  =  80
43 hauteur  =  50
44
45 rayon = 10
46
47 # Points
48 # ------
49
50 basePoint111 = MakeVertex(ox         ,  oy, oz)
51 basePoint211 = MakeVertex(ox+longueur,  oy, oz)
52 basePoint112 = MakeVertex(ox         ,  oy, oz+largeur)
53 basePoint212 = MakeVertex(ox+longueur,  oy, oz+largeur)
54
55 cx = ox+longueur/2
56 cy = oy
57 cz = oz+largeur/2
58
59 ll = longueur/largeur
60 ll = ll*ll
61 dx = rayon/math.sqrt(1+ll)
62 dz = rayon/math.sqrt(1+1/ll)
63
64 circlePoint1 = MakeVertex(cx-dx, cy, cz-dz)
65 circlePoint2 = MakeVertex(cx+dx, cy, cz-dz)
66 circlePoint3 = MakeVertex(cx+dx, cy, cz+dz)
67 circlePoint4 = MakeVertex(cx-dx, cy, cz+dz)
68
69 # Edges
70 # -----
71
72 squareEdge1 = MakeEdge(basePoint111, basePoint211)
73 squareEdge2 = MakeEdge(basePoint211, basePoint212)
74 squareEdge3 = MakeEdge(basePoint212, basePoint112)
75 squareEdge4 = MakeEdge(basePoint112, basePoint111)
76
77 diagEdge1   = MakeEdge(basePoint111, circlePoint1)
78 diagEdge2   = MakeEdge(basePoint211, circlePoint2)
79 diagEdge3   = MakeEdge(basePoint212, circlePoint3)
80 diagEdge4   = MakeEdge(basePoint112, circlePoint4)
81
82 arcEdge1    = MakeArc(circlePoint1, MakeVertex(cx      , cy, cz-rayon), circlePoint2)
83 arcEdge2    = MakeArc(circlePoint2, MakeVertex(cx+rayon, cy, cz      ), circlePoint3)
84 arcEdge3    = MakeArc(circlePoint3, MakeVertex(cx      , cy, cz+rayon), circlePoint4)
85 arcEdge4    = MakeArc(circlePoint4, MakeVertex(cx-rayon, cy, cz      ), circlePoint1)
86
87 # Faces
88 # -----
89
90 baseFace1 = MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1)
91 baseFace2 = MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2)
92 baseFace3 = MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3)
93 baseFace4 = MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4)
94
95 # Solids
96 # ------
97
98 baseVector = MakeVectorDXDYDZ(0, 1, 0)
99
100 baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur)
101 baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur)
102 baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur)
103 baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur)
104
105 # Compound
106 # --------
107
108 c_l = []
109 c_l.append(baseSolid1)
110 c_l.append(baseSolid2)
111 c_l.append(baseSolid3)
112 c_l.append(baseSolid4)
113
114 c_cpd = MakeCompound(c_l)
115 piece = MakeGlueFaces(c_cpd, 1.e-5)
116
117 # Add in study
118 # ------------
119
120 piece_id = addToStudy(piece, "ex05_hole1build")
121
122 # Meshing
123 # =======
124
125 # Create a hexahedral mesh
126 # ------------------------
127
128 hexa = smesh.Mesh(piece, "ex05_hole1build:hexa")
129
130 algo = hexa.Segment()
131
132 algo.NumberOfSegments(6, 3)
133
134 hexa.Quadrangle()
135
136 hexa.Hexahedron()
137
138 # Mesh calculus
139 # -------------
140
141 hexa.Compute()