Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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 from salome import sg
30
31 import geompy
32
33 import math
34
35 # -----------------------------------------------------------------------------
36
37 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38 myBuilder = salome.myStudy.NewBuilder()
39 gg = salome.ImportComponentGUI("GEOM")
40 from salome import sg
41
42 ShapeTypeCompSolid = 1
43 ShapeTypeSolid     = 2
44 ShapeTypeShell     = 3
45 ShapeTypeFace      = 4
46 ShapeTypeWire      = 5
47 ShapeTypeEdge      = 6
48 ShapeTypeVertex    = 7
49
50 Boolop_common = 1
51 Boolop_cut = 2
52 Boolop_fuse = 3
53 Boolop_section = 4
54
55 p0 = geompy.MakeVertex(0., 0., 0.)
56 px = geompy.MakeVertex(100., 0., 0.)
57 py = geompy.MakeVertex(0., 100., 0.)
58 pz = geompy.MakeVertex(0., 0., 100.)
59 vx = geompy.MakeVector(p0, px)
60 vy = geompy.MakeVector(p0, py)
61 vz = geompy.MakeVector(p0, pz)
62
63 sphereExt = geompy.MakeSphere(    0.,  0.,  0., 400.)
64 sphereInt = geompy.MakeSphere(    0.,-50.,  0., 350.)
65 sphereA   = geompy.MakeSphere( -400., 50., 50., 400.)
66 sphereB   = geompy.MakeSphere(  350.,-50.,-50., 350.)
67 ptcyle    = geompy.MakeVertex(0., -300., -450.)
68 cylindre  = geompy.MakeCylinder(ptcyle,vz,500.,900.)
69
70 vol1=geompy.MakeCut(sphereExt,sphereA)
71 vol2=geompy.MakeCut(vol1,sphereB)
72 vol3=geompy.MakeCut(vol2,cylindre)
73 blob=geompy.MakeCut(vol3,sphereInt)
74
75 idblob = geompy.addToStudy(blob,"blob")
76
77 aretes = []
78 aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge)
79 eid=0
80
81 # -------------------------------
82 # --- numerotation des aretes
83 ##for edge in aretes:
84 ##    edname="arete%d"%eid
85 ##    idedge=geompy.addToStudy(edge,edname)
86 ##    eid=eid+1
87
88 salome.sg.updateObjBrowser(1)
89
90 # --- epaisseur 0 2 8 10
91 # --- hauteur   1 3 9 11
92 # --- largeur   4 5 6 7
93
94 # -----------------------------------------------------------------------------
95
96 print "-------------------------- mesh"
97
98 import SMESH
99 import StdMeshers
100 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
101 smesh.SetCurrentStudy(salome.myStudy)
102
103 # ---- create Hypothesis
104 print "-------------------------- create Hypothesis"
105 numberOfSegments = 4
106 hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
107 hypNbSegA.SetNumberOfSegments(numberOfSegments)
108 numberOfSegments = 10
109 hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
110 hypNbSegB.SetNumberOfSegments(numberOfSegments)
111 numberOfSegments = 15
112 hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
113 hypNbSegC.SetNumberOfSegments(numberOfSegments)
114
115 # ---- create Algorithms
116 print "-------------------------- create Algorithms"
117 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
118 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
119 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
120
121 # ---- init a Mesh with the geom shape
122 shape_mesh = blob
123 myMesh=smesh.CreateMesh(shape_mesh)
124
125 # ---- add hypothesis and algorithms to mesh
126 print "-------------------------- add hypothesis to mesh"
127 myMesh.AddHypothesis(shape_mesh,regular1D)
128 myMesh.AddHypothesis(shape_mesh,quad2D)
129 myMesh.AddHypothesis(shape_mesh,hexa3D)
130
131 #myMesh.AddHypothesis(shape_mesh,hypNbSeg)
132
133 myMesh.AddHypothesis(aretes[0],hypNbSegA)
134 myMesh.AddHypothesis(aretes[2],hypNbSegA)
135 myMesh.AddHypothesis(aretes[8],hypNbSegA)
136 myMesh.AddHypothesis(aretes[10],hypNbSegA)
137
138 myMesh.AddHypothesis(aretes[1],hypNbSegC)
139 myMesh.AddHypothesis(aretes[3],hypNbSegC)
140 myMesh.AddHypothesis(aretes[9],hypNbSegC)
141 myMesh.AddHypothesis(aretes[11],hypNbSegC)
142
143 myMesh.AddHypothesis(aretes[4],hypNbSegB)
144 myMesh.AddHypothesis(aretes[5],hypNbSegB)
145 myMesh.AddHypothesis(aretes[6],hypNbSegB)
146 myMesh.AddHypothesis(aretes[7],hypNbSegB)
147
148 # ---- compute mesh
149
150 print "-------------------------- compute mesh"
151 ret=smesh.Compute(myMesh, shape_mesh)
152 print ret
153 if ret != 0:
154     #log=myMesh.GetLog(0) # no erase trace
155     #for linelog in log:
156     #    print linelog
157     print "Information about the Mesh:"
158     print "Number of nodes       : ", myMesh.NbNodes()
159     print "Number of edges       : ", myMesh.NbEdges()
160     print "Number of faces       : ", myMesh.NbFaces()
161     print "Number of quadrangles : ", myMesh.NbQuadrangles()
162     print "Number of volumes     : ", myMesh.NbVolumes()
163     print "Number of hexahedrons : ", myMesh.NbHexas()
164 else:
165     print "problem when Computing the mesh"
166
167 salome.sg.updateObjBrowser(1)