Salome HOME
PAL10467. Add "Quadrangle Preference" hypothesis for "Quadrangle(Mapping)" algo
[modules/smesh.git] / src / SMESH_SWIG / smesh.py
index 50df727f9aa4f5aa0ec9b61d52aaf30b3d842b78..776ee83c71dbc37e2511509a2cc89e98114d8afb 100644 (file)
@@ -77,6 +77,7 @@ class Mesh_Algorithm:
     mesh = 0
     geom = 0
     subm = 0
+    algo = 0
 
     def GetSubMesh(self):
         """
@@ -85,6 +86,12 @@ class Mesh_Algorithm:
         """
         return self.subm
 
+    def GetAlgorithm(self):
+        """
+         Return the wrapped mesher
+        """
+        return self.algo
+
     def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
         """
          Private method
@@ -102,9 +109,9 @@ class Mesh_Algorithm:
                 geompy.addToStudyInFather(piece, geom, name)
             self.subm = mesh.mesh.GetSubMesh(geom, hypo)
 
-        algo = smesh.CreateHypothesis(hypo, so)
-        SetName(algo, name + "/" + hypo)
-        mesh.mesh.AddHypothesis(self.geom, algo)
+        self.algo = smesh.CreateHypothesis(hypo, so)
+        SetName(self.algo, name + "/" + hypo)
+        mesh.mesh.AddHypothesis(self.geom, self.algo)
 
     def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
         """
@@ -274,6 +281,15 @@ class Mesh_Quadrangle(Mesh_Algorithm):
         """
         self.Create(mesh, geom, "Quadrangle_2D")
 
+    def QuadranglePreference(self):
+        """
+         Define "QuadranglePreference" hypothesis, forcing construction
+         of quadrangles if the number of nodes on opposite edges is not the same
+         in the case where the global number of nodes on edges is even
+        """
+        hyp = self.Hypothesis("QuadranglePreference")
+        return hyp
+
 # Public class: Mesh_Tetrahedron
 # ------------------------------
 
@@ -378,12 +394,16 @@ class Mesh:
          \param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
          \param geom If defined, subshape to be meshed
         """
+        ## if Segment(geom) is called by mistake
+        if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
+            algo, geom = geom, algo
+            pass
         if algo == REGULAR:
             return Mesh_Segment(self, geom)
         elif algo == PYTHON:
             return Mesh_Segment_Python(self, geom)
         else:
-            return Mesh_Segment(self, algo)
+            return Mesh_Segment(self, geom)
 
     def Triangle(self, geom=0):
         """
@@ -412,6 +432,10 @@ class Mesh:
          \param algo values are: smesh.NETGEN, smesh.GHS3D
          \param geom If defined, subshape to be meshed
         """
+        ## if Tetrahedron(geom) is called by mistake
+        if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
+            algo, geom = geom, algo
+            pass
         return Mesh_Tetrahedron(self, algo, geom)
 
     def Hexahedron(self, geom=0):
@@ -449,8 +473,7 @@ class Mesh:
         if dim > 2 :
             self.Tetrahedron(NETGEN)
             pass
-        self.Compute()
-        pass
+        return self.Compute()
 
     def AutomaticHexahedralization(self):
         """
@@ -466,8 +489,7 @@ class Mesh:
         if dim > 2 :
             self.Hexahedron()            
             pass
-        self.Compute()
-        pass
+        return self.Compute()
 
     def RemoveGlobalHypotheses(self):
         """