Salome HOME
INT PAL 0052683: Parameter "Color group" in the "Create Group" dialog box is empty
[modules/smesh.git] / src / SMESH_SWIG / SMESH_demo_hexa2_upd.py
index 8f1956dab74a73acfa3dfa8f2db35ec49e0ec4c9..8414aa21a68ce596061ddcb8da97850a266197a1 100755 (executable)
@@ -1,22 +1,26 @@
-#  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
+# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
 #
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
-#  See http://www.salome-platform.org/
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 #==============================================================================
 #  Info.
 #  Bug (from script, bug)   : SMESH_demo_hexa2_upd.py, PAL6781
 # Hypothesis and algorithms for the mesh generation are not global:
 # the mesh of some edges is thinner
 #
-
 import salome
-import geompy
-
-import StdMeshers
-import NETGENPlugin
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
 
-geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
-
-smeshgui = salome.ImportComponentGUI("SMESH")
-smeshgui.Init(salome.myStudyId);
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+smesh =  smeshBuilder.New(salome.myStudy)
 
 import math
 
+
 # -----------------------------------------------------------------------------
 
 ShapeTypeShell     = 3
@@ -129,87 +131,56 @@ for i in range(8):
     idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
 
 ### ---------------------------- SMESH --------------------------------------
+smesh.SetCurrentStudy(salome.myStudy)
+
+# ---- init a Mesh with the volume
 
-# ---- create Hypothesis
+mesh = smesh.Mesh(vol, "meshVolume")
 
-print "-------------------------- create Hypothesis"
+# ---- set Hypothesis and Algorithm to main shape
 
 print "-------------------------- NumberOfSegments the global one"
 
 numberOfSegments = 10
 
-hypNbSeg=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
-hypNbSeg.SetNumberOfSegments(numberOfSegments)
-hypNbSegID = hypNbSeg.GetId()
+regular1D = mesh.Segment()
+regular1D.SetName("Wire Discretisation")
+hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
 print hypNbSeg.GetName()
-print hypNbSegID
+print hypNbSeg.GetId()
 print hypNbSeg.GetNumberOfSegments()
+smesh.SetName(hypNbSeg, "NumberOfSegments")
 
-smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments")
-
-print "-------------------------- NumberOfSegments in the Z direction"
-
-numberOfSegmentsZ = 40
-
-hypNbSegZ=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
-hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
-hypNbSegZID = hypNbSegZ.GetId()
-print hypNbSegZ.GetName()
-print hypNbSegZID
-print hypNbSegZ.GetNumberOfSegments()
-
-smeshgui.SetName(salome.ObjectToID(hypNbSegZ), "NumberOfSegmentsZ")
-
-# ---- create Algorithms
-
-print "-------------------------- create Algorithms"
-
-print "-------------------------- Regular_1D"
-
-regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
-smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
 
 print "-------------------------- Quadrangle_2D"
 
-quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
-smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
+quad2D=mesh.Quadrangle()
+quad2D.SetName("Quadrangle_2D")
 
 print "-------------------------- Hexa_3D"
 
-hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
-smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
-
-# ---- init a Mesh with the volume
-
-mesh = smesh.CreateMesh(vol)
-smeshgui.SetName(salome.ObjectToID(mesh), "meshVolume")
+hexa3D=mesh.Hexahedron()
+hexa3D.SetName("Hexa_3D")
 
-# ---- add hypothesis to the volume
 
-print "-------------------------- add hypothesis to the volume"
+print "-------------------------- NumberOfSegments in the Z direction"
 
-ret=mesh.AddHypothesis(vol,regular1D)
-print ret
-ret=mesh.AddHypothesis(vol,hypNbSeg)
-print ret
-ret=mesh.AddHypothesis(vol,quad2D)
-print ret
-ret=mesh.AddHypothesis(vol,hexa3D)
-print ret
+numberOfSegmentsZ = 40
 
 for i in range(8):
     print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
 
-    subMeshEdgeZ = mesh.GetSubMesh(edgeZ[i],"SubMeshEdgeZ_"+str(i+1))
-
-    retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
-    print " add hyp Z ", retZ
+    algo = mesh.Segment(edgeZ[i])
+    hyp = algo.NumberOfSegments(numberOfSegmentsZ)
+    smesh.SetName(hyp, "NumberOfSegmentsZ")
+    smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
+  
 
 salome.sg.updateObjBrowser(1)
 
 print "-------------------------- compute the mesh of the volume"
 
-ret=smesh.Compute(mesh,vol)
+ret=mesh.Compute()
 
 print ret
 if ret != 0: