1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 # See http://www.salome-platform.org/
21 # Tetrahedrization of a simple box. Hypothesis and algorithms for
22 # the mesh generation are global
31 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
33 smeshgui = salome.ImportComponentGUI("SMESH")
34 smeshgui.Init(salome.myStudyId);
38 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
40 idbox = geompy.addToStudy(box, "box")
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"])
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)
52 ### ---------------------------- SMESH --------------------------------------
54 # ---- create Hypothesis
56 print "-------------------------- create Hypothesis"
58 print "-------------------------- NumberOfSegments"
62 hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
63 hypNbSeg.SetNumberOfSegments(numberOfSegments)
65 print hypNbSeg.GetName()
66 print hypNbSeg.GetId()
67 print hypNbSeg.GetNumberOfSegments()
69 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
71 print "-------------------------- MaxElementArea"
75 hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
76 hypArea.SetMaxElementArea(maxElementArea)
78 print hypArea.GetName()
80 print hypArea.GetMaxElementArea()
82 smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
84 print "-------------------------- MaxElementVolume"
86 maxElementVolume = 500
88 hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
89 hypVolume.SetMaxElementVolume(maxElementVolume)
91 print hypVolume.GetName()
92 print hypVolume.GetId()
93 print hypVolume.GetMaxElementVolume()
95 smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
97 # ---- create Algorithms
99 print "-------------------------- create Algorithms"
101 print "-------------------------- Regular_1D"
103 regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
104 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
106 print "-------------------------- MEFISTO_2D"
108 mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
109 smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
111 print "-------------------------- NETGEN_3D"
113 netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
114 smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
116 # ---- init a Mesh with the boxe
118 mesh = smesh.CreateMesh(box)
119 smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
121 # ---- add hypothesis to the boxe
123 print "-------------------------- add hypothesis to the box"
125 mesh.AddHypothesis(box,regular1D)
126 mesh.AddHypothesis(box,hypNbSeg)
128 mesh.AddHypothesis(box,mefisto2D)
129 mesh.AddHypothesis(box,hypArea)
131 mesh.AddHypothesis(box,netgen3D)
132 mesh.AddHypothesis(box,hypVolume)
134 salome.sg.updateObjBrowser(1)
136 print "-------------------------- compute the mesh of the boxe"
137 ret = smesh.Compute(mesh,box)
140 log = mesh.GetLog(0) # no erase trace
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()
151 print "probleme when computing the mesh"