Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESH_SWIG / SMESH_box_tetra.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 #
21 # Tetrahedrization of a simple box. Hypothesis and algorithms for
22 # the mesh generation are global
23 #
24
25 import salome
26 import geompy
27
28 import StdMeshers
29 import NETGENPlugin
30
31 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
33 smeshgui = salome.ImportComponentGUI("SMESH")
34 smeshgui.Init(salome.myStudyId);
35
36 # ---- define a boxe
37
38 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
39
40 idbox = geompy.addToStudy(box, "box")
41
42 print "Analysis of the geometry box :"
43 subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
44 subFaceList  = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
45 subEdgeList  = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
46
47 print "number of Shells in box : ", len(subShellList)
48 print "number of Faces  in box : ", len(subFaceList)
49 print "number of Edges  in box : ", len(subEdgeList)
50
51
52 ### ---------------------------- SMESH --------------------------------------
53
54 # ---- create Hypothesis
55
56 print "-------------------------- create Hypothesis"
57
58 print "-------------------------- NumberOfSegments"
59
60 numberOfSegments = 10
61
62 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
63 hypNbSeg.SetNumberOfSegments(numberOfSegments)
64
65 print hypNbSeg.GetName()
66 print hypNbSeg.GetId()
67 print hypNbSeg.GetNumberOfSegments()
68
69 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
70
71 print "-------------------------- MaxElementArea"
72
73 maxElementArea = 500
74
75 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
76 hypArea.SetMaxElementArea(maxElementArea)
77
78 print hypArea.GetName()
79 print hypArea.GetId()
80 print hypArea.GetMaxElementArea()
81
82 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
83
84 print "-------------------------- MaxElementVolume"
85
86 maxElementVolume = 500
87
88 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
89 hypVolume.SetMaxElementVolume(maxElementVolume)
90
91 print hypVolume.GetName()
92 print hypVolume.GetId()
93 print hypVolume.GetMaxElementVolume()
94
95 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
96
97 # ---- create Algorithms
98
99 print "-------------------------- create Algorithms"
100
101 print "-------------------------- Regular_1D"
102
103 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
104 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
105
106 print "-------------------------- MEFISTO_2D"
107
108 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
109 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
110
111 print "-------------------------- NETGEN_3D"
112
113 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
114 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
115
116 # ---- init a Mesh with the boxe
117
118 mesh = smesh.CreateMesh(box)
119 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
120
121 # ---- add hypothesis to the boxe
122
123 print "-------------------------- add hypothesis to the box"
124
125 mesh.AddHypothesis(box,regular1D)
126 mesh.AddHypothesis(box,hypNbSeg)
127
128 mesh.AddHypothesis(box,mefisto2D)
129 mesh.AddHypothesis(box,hypArea)
130
131 mesh.AddHypothesis(box,netgen3D)
132 mesh.AddHypothesis(box,hypVolume)
133
134 salome.sg.updateObjBrowser(1)
135
136 print "-------------------------- compute the mesh of the boxe"
137 ret = smesh.Compute(mesh,box)
138 print ret
139 if ret != 0:
140     log = mesh.GetLog(0) # no erase trace
141     for linelog in log:
142         print linelog
143     print "Information about the MeshBox:"
144     print "Number of nodes       : ", mesh.NbNodes()
145     print "Number of edges       : ", mesh.NbEdges()
146     print "Number of faces       : ", mesh.NbFaces()
147     print "Number of triangles   : ", mesh.NbTriangles()
148     print "Number of volumes     : ", mesh.NbVolumes()
149     print "Number of tetrahedrons: ", mesh.NbTetras()
150 else:
151     print "probleme when computing the mesh"