Salome HOME
0020373: MakeMultiTransformation1D failed on maintenances branch (V4 and V5)
[modules/smesh.git] / src / SMESH_SWIG / SMESH_Sphere.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 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
23 #  File   : GEOM_Sphere.py
24 #  Author : Damien COQUERET, Open CASCADE
25 #  Module : GEOM
26 #  $Header: 
27 #
28 from geompy import *
29 from math import *
30
31 import smesh
32
33 # It is an example of creating a hexahedrical mesh on a sphere.
34 #
35 # Used approach allows to avoid problems with degenerated and
36 # seam edges without special processing of geometrical shapes
37
38 #-----------------------------------------------------------------------
39 #Variables
40 Radius  = 100.
41 Dist    = Radius / 2.
42 Factor  = 2.5
43 Angle90 = pi / 2.
44 NbSeg   = 10
45
46 PointsList = []
47 ShapesList = []
48
49 #Basic Elements
50 P0 = MakeVertex(0., 0., 0.)
51 P1 = MakeVertex(-Dist, -Dist, -Dist)
52 P2 = MakeVertex(-Dist, -Dist, Dist)
53 P3 = MakeVertex(-Dist, Dist, Dist)
54 P4 = MakeVertex(-Dist, Dist, -Dist)
55
56 VZ = MakeVectorDXDYDZ(0., 0., 1.)
57
58 #Construction Elements
59 PointsList.append(P1)
60 PointsList.append(P2)
61 PointsList.append(P3)
62 PointsList.append(P4)
63 PointsList.append(P1)
64
65 PolyLine = MakePolyline(PointsList)
66
67 Face1 = MakeFace(PolyLine, 1)
68 Face2 = MakeScaleTransform(Face1, P0, Factor)
69 Face3 = MakeScaleTransform(Face1, P0, -1.)
70
71 #Models
72 Sphere = MakeSphereR(Radius)
73
74 Block = MakeHexa2Faces(Face1, Face2)
75 Cube  = MakeHexa2Faces(Face1, Face3)
76
77 Common1 = MakeBoolean(Sphere, Block, 1)
78 Common2 = MakeRotation(Common1, VZ, Angle90)
79
80 MultiBlock1 = MakeMultiTransformation1D(Common1, 20, -1, 3)
81 MultiBlock2 = MakeMultiTransformation1D(Common2, 30, -1, 3)
82
83 #Reconstruct sphere from several blocks
84 ShapesList.append(Cube)
85 ShapesList.append(MultiBlock1)
86 ShapesList.append(MultiBlock2)
87 Compound = MakeCompound(ShapesList)
88
89 Result = MakeGlueFaces(Compound, 0.1)
90
91 #addToStudy
92 Id_Sphere      = addToStudy(Sphere, "Sphere")
93 Id_Cube        = addToStudy(Cube, "Cube")
94
95 Id_Common1     = addToStudy(Common1, "Common1")
96 Id_Common2     = addToStudy(Common2, "Common2")
97
98 Id_MultiBlock1 = addToStudy(MultiBlock1, "MultiBlock1")
99 Id_MultiBlock2 = addToStudy(MultiBlock2, "MultiBlock2")
100
101 Id_Result      = addToStudy(Result, "Result")
102
103 #-----------------------------------------------------------------------
104 #Meshing
105 my_hexa = smesh.Mesh(Result, "Sphere_Mesh")
106 algo = my_hexa.Segment()
107 algo.NumberOfSegments(NbSeg)
108 my_hexa.Quadrangle()
109 my_hexa.Hexahedron()
110 my_hexa.Compute()