Salome HOME
Merging with WPdev
[modules/smesh.git] / src / SMESH_SWIG / SMESH_hexaedre.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 #==============================================================================
21 #  Info.
22 #  Bug (from script, bug)   : hexaedre_modified.py, PAL6194, PAL7153
23 #  Modified                 : 25/11/2004
24 #  Author                   : Kovaltchuk Alexey
25 #  Project                  : PAL/SALOME
26 #==============================================================================
27
28 import salome
29 import geompy
30 import smesh
31
32 import math
33
34 # -----------------------------------------------------------------------------
35
36 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
37 myBuilder = salome.myStudy.NewBuilder()
38 gg = salome.ImportComponentGUI("GEOM")
39
40 ShapeTypeCompSolid = 1
41 ShapeTypeSolid     = 2
42 ShapeTypeShell     = 3
43 ShapeTypeFace      = 4
44 ShapeTypeWire      = 5
45 ShapeTypeEdge      = 6
46 ShapeTypeVertex    = 7
47
48 Boolop_common = 1
49 Boolop_cut = 2
50 Boolop_fuse = 3
51 Boolop_section = 4
52
53 p0 = geompy.MakeVertex(0., 0., 0.)
54 px = geompy.MakeVertex(100., 0., 0.)
55 py = geompy.MakeVertex(0., 100., 0.)
56 pz = geompy.MakeVertex(0., 0., 100.)
57 vx = geompy.MakeVector(p0, px)
58 vy = geompy.MakeVector(p0, py)
59 vz = geompy.MakeVector(p0, pz)
60
61 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
62 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
63 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
64 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
65 ptcyle    = geompy.MakeVertex(0., -300., -450.)
66 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
67
68 vol1=geompy.MakeCut(sphereExt,sphereA)
69 vol2=geompy.MakeCut(vol1,sphereB)
70 vol3=geompy.MakeCut(vol2,cylindre)
71 blob=geompy.MakeCut(vol3,sphereInt)
72
73 idblob = geompy.addToStudy(blob,"blob")
74
75 aretes = []
76 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
77 eid=0
78
79 # -------------------------------
80 # --- numerotation des aretes
81 ##for edge in aretes:
82 ##    edname="arete%d"%eid
83 ##    idedge=geompy.addToStudy(edge,edname)
84 ##    eid=eid+1
85
86 salome.sg.updateObjBrowser(1)
87
88 # --- epaisseur 0 2 8 10
89 # --- hauteur   1 3 9 11
90 # --- largeur   4 5 6 7
91
92 # -----------------------------------------------------------------------------
93
94 print "-------------------------- mesh"
95
96 # ---- init a Mesh with the geom shape
97 shape_mesh = blob
98 mesh=smesh.Mesh(shape_mesh, "MeshBlob")
99
100 # ---- add hypothesis and algorithms to mesh
101 print "-------------------------- add hypothesis to mesh"
102 algo1 = mesh.Segment()
103 algo2 = mesh.Quadrangle()
104 algo3 = mesh.Hexahedron()
105
106 numberOfSegmentsA = 4
107
108 algo = mesh.Segment(aretes[0])
109 algo.NumberOfSegments(numberOfSegmentsA)
110 algo = mesh.Segment(aretes[2])
111 algo.NumberOfSegments(numberOfSegmentsA)
112 algo = mesh.Segment(aretes[8])
113 algo.NumberOfSegments(numberOfSegmentsA)
114 algo = mesh.Segment(aretes[10])
115 algo.NumberOfSegments(numberOfSegmentsA)
116
117
118 numberOfSegmentsC = 15
119
120 algo = mesh.Segment(aretes[1])
121 algo.NumberOfSegments(numberOfSegmentsC)
122 algo = mesh.Segment(aretes[3])
123 algo.NumberOfSegments(numberOfSegmentsC)
124 algo = mesh.Segment(aretes[9])
125 algo.NumberOfSegments(numberOfSegmentsC)
126 algo = mesh.Segment(aretes[11])
127 algo.NumberOfSegments(numberOfSegmentsC)
128
129
130 numberOfSegmentsB = 10
131 algo = mesh.Segment(aretes[4])
132 algo.NumberOfSegments(numberOfSegmentsB)
133 algo = mesh.Segment(aretes[5])
134 algo.NumberOfSegments(numberOfSegmentsB)
135 algo = mesh.Segment(aretes[6])
136 algo.NumberOfSegments(numberOfSegmentsB)
137 algo = mesh.Segment(aretes[7])
138 algo.NumberOfSegments(numberOfSegmentsB)
139
140
141 # ---- compute mesh
142
143 print "-------------------------- compute mesh"
144 ret=mesh.Compute()
145 print ret
146 if ret != 0:
147     #log=mesh.GetLog(0) # no erase trace
148     #for linelog in log:
149     #    print linelog
150     print "Information about the Mesh:"
151     print "Number of nodes       : ", mesh.NbNodes()
152     print "Number of edges       : ", mesh.NbEdges()
153     print "Number of faces       : ", mesh.NbFaces()
154     print "Number of quadrangles : ", mesh.NbQuadrangles()
155     print "Number of volumes     : ", mesh.NbVolumes()
156     print "Number of hexahedrons : ", mesh.NbHexas()
157 else:
158     print "problem when Computing the mesh"
159
160 salome.sg.updateObjBrowser(1)