Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_SWIG / SMESH_hexaedre.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 #==============================================================================
24 #  Info.
25 #  Bug (from script, bug)   : hexaedre_modified.py, PAL6194, PAL7153
26 #  Modified                 : 25/11/2004
27 #  Author                   : Kovaltchuk Alexey
28 #  Project                  : PAL/SALOME
29 #==============================================================================
30 #
31 import salome
32 import geompy
33 import smesh
34
35 import math
36
37 # -----------------------------------------------------------------------------
38
39 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
40 myBuilder = salome.myStudy.NewBuilder()
41 gg = salome.ImportComponentGUI("GEOM")
42
43 ShapeTypeCompSolid = 1
44 ShapeTypeSolid     = 2
45 ShapeTypeShell     = 3
46 ShapeTypeFace      = 4
47 ShapeTypeWire      = 5
48 ShapeTypeEdge      = 6
49 ShapeTypeVertex    = 7
50
51 Boolop_common = 1
52 Boolop_cut = 2
53 Boolop_fuse = 3
54 Boolop_section = 4
55
56 p0 = geompy.MakeVertex(0., 0., 0.)
57 px = geompy.MakeVertex(100., 0., 0.)
58 py = geompy.MakeVertex(0., 100., 0.)
59 pz = geompy.MakeVertex(0., 0., 100.)
60 vx = geompy.MakeVector(p0, px)
61 vy = geompy.MakeVector(p0, py)
62 vz = geompy.MakeVector(p0, pz)
63
64 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
65 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
66 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
67 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
68 ptcyle    = geompy.MakeVertex(0., -300., -450.)
69 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
70
71 vol1=geompy.MakeCut(sphereExt,sphereA)
72 vol2=geompy.MakeCut(vol1,sphereB)
73 vol3=geompy.MakeCut(vol2,cylindre)
74 blob=geompy.MakeCut(vol3,sphereInt)
75
76 idblob = geompy.addToStudy(blob,"blob")
77
78 aretes = []
79 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
80 eid=0
81
82 # -------------------------------
83 # --- numerotation des aretes
84 ##for edge in aretes:
85 ##    edname="arete%d"%eid
86 ##    idedge=geompy.addToStudy(edge,edname)
87 ##    eid=eid+1
88
89 salome.sg.updateObjBrowser(1)
90
91 # --- epaisseur 0 2 8 10
92 # --- hauteur   1 3 9 11
93 # --- largeur   4 5 6 7
94
95 # -----------------------------------------------------------------------------
96
97 print "-------------------------- mesh"
98
99 # ---- init a Mesh with the geom shape
100 shape_mesh = blob
101 mesh=smesh.Mesh(shape_mesh, "MeshBlob")
102
103 # ---- add hypothesis and algorithms to mesh
104 print "-------------------------- add hypothesis to mesh"
105 algo1 = mesh.Segment()
106 algo2 = mesh.Quadrangle()
107 algo3 = mesh.Hexahedron()
108
109 numberOfSegmentsA = 4
110
111 algo = mesh.Segment(aretes[0])
112 algo.NumberOfSegments(numberOfSegmentsA)
113 algo = mesh.Segment(aretes[2])
114 algo.NumberOfSegments(numberOfSegmentsA)
115 algo = mesh.Segment(aretes[8])
116 algo.NumberOfSegments(numberOfSegmentsA)
117 algo = mesh.Segment(aretes[10])
118 algo.NumberOfSegments(numberOfSegmentsA)
119
120
121 numberOfSegmentsC = 15
122
123 algo = mesh.Segment(aretes[1])
124 algo.NumberOfSegments(numberOfSegmentsC)
125 algo = mesh.Segment(aretes[3])
126 algo.NumberOfSegments(numberOfSegmentsC)
127 algo = mesh.Segment(aretes[9])
128 algo.NumberOfSegments(numberOfSegmentsC)
129 algo = mesh.Segment(aretes[11])
130 algo.NumberOfSegments(numberOfSegmentsC)
131
132
133 numberOfSegmentsB = 10
134 algo = mesh.Segment(aretes[4])
135 algo.NumberOfSegments(numberOfSegmentsB)
136 algo = mesh.Segment(aretes[5])
137 algo.NumberOfSegments(numberOfSegmentsB)
138 algo = mesh.Segment(aretes[6])
139 algo.NumberOfSegments(numberOfSegmentsB)
140 algo = mesh.Segment(aretes[7])
141 algo.NumberOfSegments(numberOfSegmentsB)
142
143
144 # ---- compute mesh
145
146 print "-------------------------- compute mesh"
147 ret=mesh.Compute()
148 print ret
149 if ret != 0:
150     #log=mesh.GetLog(0) # no erase trace
151     #for linelog in log:
152     #    print linelog
153     print "Information about the Mesh:"
154     print "Number of nodes       : ", mesh.NbNodes()
155     print "Number of edges       : ", mesh.NbEdges()
156     print "Number of faces       : ", mesh.NbFaces()
157     print "Number of quadrangles : ", mesh.NbQuadrangles()
158     print "Number of volumes     : ", mesh.NbVolumes()
159     print "Number of hexahedrons : ", mesh.NbHexas()
160 else:
161     print "problem when Computing the mesh"
162
163 salome.sg.updateObjBrowser(1)