-hyp3=gen.CreateHypothesis("MaxElementVolume")
-hypVolume=hyp3._narrow(SMESH.SMESH_MaxElementVolume)
-hypVolume.SetMaxElementVolume(maxElementVolume)
-print hypVolume.GetName()
-print hypVolume.GetId()
-print hypVolume.GetMaxElementVolume()
-
-idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
-smeshgui.SetName(idvolume, "MaxElementVolume")
-
-# ---- create Algorithms
-
-print "-------------------------- create Algorithms"
-
-print "-------------------------- Regular_1D"
-
-hypothesis=gen.CreateHypothesis("Regular_1D")
-regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
-regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
-smeshgui.SetName(regularID, "Wire Discretisation")
-
-print "-------------------------- MEFISTO_2D"
-
-hypothesis=gen.CreateHypothesis("MEFISTO_2D")
-mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
-mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
-smeshgui.SetName(mefistoID, "MEFISTO_2D")
-
-print "-------------------------- NETGEN_3D"
-
-hypothesis=gen.CreateHypothesis("NETGEN_3D")
-netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
-netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
-smeshgui.SetName(netgenID, "NETGEN_3D")
-
-# ---- init a Mesh with the shell
-
-mesh=gen.Init(idshell)
-idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
-smeshgui.SetName(idmesh, "MeshBox2")
-smeshgui.SetShape(idshell, idmesh)
-
-# ---- add hypothesis to shell
-
-print "-------------------------- add hypothesis to shell"
-
-ret=mesh.AddHypothesis(shell,regular1D)
-print ret
-ret=mesh.AddHypothesis(shell,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(shell,mefisto2D)
-print ret
-ret=mesh.AddHypothesis(shell,hypArea)
-print ret
-ret=mesh.AddHypothesis(shell,netgen3D)
-print ret
-ret=mesh.AddHypothesis(shell,hypVolume)
-print ret
-
-smeshgui.SetAlgorithms( idmesh, regularID)
-smeshgui.SetHypothesis( idmesh, idseg )
-smeshgui.SetAlgorithms( idmesh, mefistoID )
-smeshgui.SetHypothesis( idmesh, idarea )
-smeshgui.SetAlgorithms( idmesh, netgenID )
-smeshgui.SetHypothesis( idmesh, idvolume )
-
-sg.updateObjBrowser(1)
-
-
-print "-------------------------- compute shell"
-ret=gen.Compute(mesh,idshell)
-print ret
-log=mesh.GetLog(0) # no erase trace
-for linelog in log:
- print linelog
-
-
-sg.updateObjBrowser(1)
+netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
+hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
+print(hypVolume.GetName())
+print(hypVolume.GetId())
+print(hypVolume.GetMaxElementVolume())
+smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
+
+print("-------------------------- compute shell")
+ret = mesh.Compute()
+print(ret)
+if ret != 0:
+ log = mesh.GetLog(0) # no erase trace
+ for linelog in log:
+ print(linelog)
+ print("Information about the MeshBox2:")
+ print("Number of nodes : ", mesh.NbNodes())
+ print("Number of edges : ", mesh.NbEdges())
+ print("Number of faces : ", mesh.NbFaces())
+ print("Number of triangles : ", mesh.NbTriangles())
+ print("Number of volumes : ", mesh.NbVolumes())
+ print("Number of tetrahedrons: ", mesh.NbTetras())
+else:
+ print("probleme when computing the mesh")
+
+salome.sg.updateObjBrowser(True)