Salome HOME
In Translate*() allow for definition of Vector as a list of 3 components
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index e224ade4c5c8eee268352dadbe428bac06a24d30..046e5e9ab8cd3e78c903b29786f2af65b9623132 100644 (file)
@@ -186,7 +186,10 @@ def GetName(obj):
         if isinstance(obj, SALOMEDS._objref_SObject):
             # study object
             return obj.GetName()
-        ior  = salome.orb.object_to_string(obj)
+        try:
+            ior  = salome.orb.object_to_string(obj)
+        except:
+            ior = None
         if ior:
             # CORBA object
             studies = salome.myStudyManager.GetOpenStudies()
@@ -255,8 +258,7 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
 def AssureGeomPublished(mesh, geom, name=''):
     if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
         return
-    if not geom.IsSame( mesh.geom ) and \
-           not geom.GetStudyEntry() and \
+    if not geom.GetStudyEntry() and \
            mesh.smeshpyD.GetCurrentStudy():
         ## set the study
         studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
@@ -330,7 +332,6 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         return Mesh(self,self.geompyD,obj,name)
 
     ## Returns a long value from enumeration
-    #  Should be used for SMESH.FunctorType enumeration
     #  @ingroup l1_controls
     def EnumToLong(self,theItem):
         return theItem._v
@@ -509,7 +510,9 @@ class smeshDC(SMESH._objref_SMESH_Gen):
     #  @return [ an instance of Mesh class, SMESH::ComputeError ]
     #  @ingroup l2_impexp
     def CreateMeshesFromGMF( self, theFileName ):
-        aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,theFileName)
+        aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
+                                                                        theFileName,
+                                                                        True)
         if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
         return Mesh(self, self.geompyD, aSmeshMesh), error
 
@@ -520,8 +523,10 @@ class smeshDC(SMESH._objref_SMESH_Gen):
     #  @param mergeNodesAndElements if true, equal nodes and elements aremerged
     #  @param mergeTolerance tolerance for merging nodes
     #  @param allGroups forces creation of groups of all elements
+    #  @param name name of a new mesh
     def Concatenate( self, meshes, uniteIdenticalGroups,
-                     mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
+                     mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False,
+                     name = ""):
         if not meshes: return None
         for i,m in enumerate(meshes):
             if isinstance(m, Mesh):
@@ -534,7 +539,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         else:
             aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
                 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
-        aMesh = Mesh(self, self.geompyD, aSmeshMesh)
+        aMesh = Mesh(self, self.geompyD, aSmeshMesh, name=name)
         return aMesh
 
     ## Create a mesh by copying a part of another mesh.
@@ -640,9 +645,13 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             # Checks that Threshold is GEOM object
             if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
                 aCriterion.ThresholdStr = GetName(aThreshold)
-                aCriterion.ThresholdID = aThreshold.GetStudyEntry()
+                aCriterion.ThresholdID  = aThreshold.GetStudyEntry()
                 if not aCriterion.ThresholdID:
-                    raise RuntimeError, "Threshold shape must be published"
+                    name = aCriterion.ThresholdStr
+                    if not name:
+                        name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000)
+                    aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name )
+                    #raise RuntimeError, "Threshold shape must be published"
             else:
                 print "Error: The Threshold should be a shape."
                 return None
@@ -682,6 +691,20 @@ class smeshDC(SMESH._objref_SMESH_Gen):
                     return None
                 pass
             pass
+        elif CritType == FT_EntityType:
+            # Checks the Threshold
+            try:
+                aCriterion.Threshold = self.EnumToLong(aThreshold)
+                assert( aThreshold in SMESH.EntityType._items )
+            except:
+                if isinstance(aThreshold, int):
+                    aCriterion.Threshold = aThreshold
+                else:
+                    print "Error: The Threshold should be an integer or SMESH.EntityType."
+                    return None
+                pass
+            pass
+        
         elif CritType == FT_GroupColor:
             # Checks the Threshold
             try:
@@ -768,37 +791,42 @@ class smeshDC(SMESH._objref_SMESH_Gen):
     #  @return SMESH_NumericalFunctor
     #  @ingroup l1_controls
     def GetFunctor(self,theCriterion):
+        if isinstance( theCriterion, SMESH._objref_NumericalFunctor ):
+            return theCriterion
         aFilterMgr = self.CreateFilterManager()
+        functor = None
         if theCriterion == FT_AspectRatio:
-            return aFilterMgr.CreateAspectRatio()
+            functor = aFilterMgr.CreateAspectRatio()
         elif theCriterion == FT_AspectRatio3D:
-            return aFilterMgr.CreateAspectRatio3D()
+            functor = aFilterMgr.CreateAspectRatio3D()
         elif theCriterion == FT_Warping:
-            return aFilterMgr.CreateWarping()
+            functor = aFilterMgr.CreateWarping()
         elif theCriterion == FT_MinimumAngle:
-            return aFilterMgr.CreateMinimumAngle()
+            functor = aFilterMgr.CreateMinimumAngle()
         elif theCriterion == FT_Taper:
-            return aFilterMgr.CreateTaper()
+            functor = aFilterMgr.CreateTaper()
         elif theCriterion == FT_Skew:
-            return aFilterMgr.CreateSkew()
+            functor = aFilterMgr.CreateSkew()
         elif theCriterion == FT_Area:
-            return aFilterMgr.CreateArea()
+            functor = aFilterMgr.CreateArea()
         elif theCriterion == FT_Volume3D:
-            return aFilterMgr.CreateVolume3D()
+            functor = aFilterMgr.CreateVolume3D()
         elif theCriterion == FT_MaxElementLength2D:
-            return aFilterMgr.CreateMaxElementLength2D()
+            functor = aFilterMgr.CreateMaxElementLength2D()
         elif theCriterion == FT_MaxElementLength3D:
-            return aFilterMgr.CreateMaxElementLength3D()
+            functor = aFilterMgr.CreateMaxElementLength3D()
         elif theCriterion == FT_MultiConnection:
-            return aFilterMgr.CreateMultiConnection()
+            functor = aFilterMgr.CreateMultiConnection()
         elif theCriterion == FT_MultiConnection2D:
-            return aFilterMgr.CreateMultiConnection2D()
+            functor = aFilterMgr.CreateMultiConnection2D()
         elif theCriterion == FT_Length:
-            return aFilterMgr.CreateLength()
+            functor = aFilterMgr.CreateLength()
         elif theCriterion == FT_Length2D:
-            return aFilterMgr.CreateLength2D()
+            functor = aFilterMgr.CreateLength2D()
         else:
             print "Error: given parameter is not numerical functor type."
+        aFilterMgr.UnRegister()
+        return functor
 
     ## Creates hypothesis
     #  @param theHType mesh hypothesis type (string)
@@ -972,10 +1000,11 @@ class Mesh:
         self.geompyD=geompyD
         if obj is None:
             obj = 0
+        objHasName = False
         if obj != 0:
-            objHasName = True
             if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
                 self.geom = obj
+                objHasName = True
                 # publish geom of mesh (issue 0021122)
                 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
                     objHasName = False
@@ -984,9 +1013,9 @@ class Mesh:
                         geompyD.init_geom( smeshpyD.GetCurrentStudy())
                         pass
                     if name:
-                        geo_name = name
+                        geo_name = name + " shape"
                     else:
-                        geo_name = "%s_%s_for_meshing"%(self.geom.GetShapeType(), id(self.geom)%100)
+                        geo_name = "%s_%s to mesh"%(self.geom.GetShapeType(), id(self.geom)%100)
                     geompyD.addToStudy( self.geom, geo_name )
                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
 
@@ -994,15 +1023,16 @@ class Mesh:
                 self.SetMesh(obj)
         else:
             self.mesh = self.smeshpyD.CreateEmptyMesh()
-        if name != 0:
+        if name:
             self.smeshpyD.SetName(self.mesh, name)
-        elif obj != 0 and objHasName:
-            self.smeshpyD.SetName(self.mesh, GetName(obj))
+        elif objHasName:
+            self.smeshpyD.SetName(self.mesh, GetName(obj)) # + " mesh"
 
         if not self.geom:
             self.geom = self.mesh.GetShapeToMesh()
 
-        self.editor = self.mesh.GetMeshEditor()
+        self.editor   = self.mesh.GetMeshEditor()
+        self.functors = [None] * SMESH.FT_Undefined._v
 
         # set self to algoCreator's
         for attrName in dir(self):
@@ -1014,8 +1044,11 @@ class Mesh:
     #  @param theMesh a SMESH_Mesh object
     #  @ingroup l2_construct
     def SetMesh(self, theMesh):
+        if self.mesh: self.mesh.UnRegister()
         self.mesh = theMesh
-        self.geom = self.mesh.GetShapeToMesh()
+        if self.mesh:
+            self.mesh.Register()
+            self.geom = self.mesh.GetShapeToMesh()
 
     ## Returns the mesh, that is an instance of SMESH_Mesh interface
     #  @return a SMESH_Mesh object
@@ -1089,19 +1122,25 @@ class Mesh:
         return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
 
     ## Returns the mesh dimension depending on the dimension of the underlying shape
+    #  or, if the mesh is not based on any shape, basing on deimension of elements
     #  @return mesh dimension as an integer value [0,3]
     #  @ingroup l1_auxiliary
     def MeshDimension(self):
-        shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
-        if len( shells ) > 0 :
-            return 3
-        elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
-            return 2
-        elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
-            return 1
+        if self.mesh.HasShapeToMesh():
+            shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SOLID"] )
+            if len( shells ) > 0 :
+                return 3
+            elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
+                return 2
+            elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
+                return 1
+            else:
+                return 0;
         else:
-            return 0;
-        pass
+            if self.NbVolumes() > 0: return 3
+            if self.NbFaces()   > 0: return 2
+            if self.NbEdges()   > 0: return 1
+        return 0
 
     ## Evaluates size of prospective mesh on a shape
     #  @return a list where i-th element is a number of elements of i-th SMESH.EntityType
@@ -1183,7 +1222,7 @@ class Mesh:
                              "Invalid input mesh",   #COMPERR_BAD_INPUT_MESH
                              "std::exception",       #COMPERR_STD_EXCEPTION
                              "OCC exception",        #COMPERR_OCC_EXCEPTION
-                             "SALOME exception",     #COMPERR_SLM_EXCEPTION
+                             "..",                   #COMPERR_SLM_EXCEPTION
                              "Unknown exception",    #COMPERR_EXCEPTION
                              "Memory allocation problem", #COMPERR_MEMORY_PB
                              "Algorithm failed",     #COMPERR_ALGO_FAILED
@@ -1224,9 +1263,13 @@ class Mesh:
                 elif err.state == HYP_BAD_GEOMETRY:
                     reason = ('%s %sD algorithm "%s" is assigned to mismatching'
                               'geometry' % ( glob, dim, name ))
+                elif err.state == HYP_HIDDEN_ALGO:
+                    reason = ('%s %sD algorithm "%s" is ignored due to presence of a %s '
+                              'algorithm of upper dimension generating %sD mesh'
+                              % ( glob, dim, name, glob, dim ))
                 else:
-                    reason = "For unknown reason."+\
-                             " Revise Mesh.Compute() implementation in smeshDC.py!"
+                    reason = ("For unknown reason. "
+                              "Developer, revise Mesh.Compute() implementation in smeshDC.py!")
                     pass
                 if allReasons != "":allReasons += "\n"
                 allReasons += "-  " + reason
@@ -1264,7 +1307,8 @@ class Mesh:
     #  @ingroup l2_construct
     def Clear(self):
         self.mesh.Clear()
-        if salome.sg.hasDesktop():
+        if ( salome.sg.hasDesktop() and 
+             salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() )):
             smeshgui = salome.ImportComponentGUI("SMESH")
             smeshgui.Init(self.mesh.GetStudyId())
             smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
@@ -1345,7 +1389,7 @@ class Mesh:
     #  @return True of False
     #  @ingroup l2_hypotheses
     def IsUsedHypothesis(self, hyp, geom):
-        if not hyp or not geom:
+        if not hyp: # or not geom
             return False
         if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
@@ -1365,11 +1409,16 @@ class Mesh:
         if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
             pass
-        if not geom:
-            geom = self.geom
+        shape = geom
+        if not shape:
+            shape = self.geom
             pass
-        status = self.mesh.RemoveHypothesis(geom, hyp)
-        return status
+        if self.IsUsedHypothesis( hyp, shape ):
+            return self.mesh.RemoveHypothesis( shape, hyp )
+        hypName = GetName( hyp )
+        geoName = GetName( shape )
+        print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName )
+        return None
 
     ## Gets the list of hypotheses added on a geometry
     #  @param geom a sub-shape of mesh geometry
@@ -1476,7 +1525,7 @@ class Mesh:
             meshPart = meshPart.mesh
         elif not meshPart:
             meshPart = self.mesh
-        self.mesh.ExportGMF(meshPart, f)
+        self.mesh.ExportGMF(meshPart, f, True)
 
     ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
     #  Exports the mesh in a file in MED format and chooses the \a version of MED format
@@ -2098,6 +2147,12 @@ class Mesh:
     def GetNodePosition(self,NodeID):
         return self.mesh.GetNodePosition(NodeID)
 
+    ## @brief Returns the position of an element on the shape
+    #  @return SMESH::ElementPosition
+    #  @ingroup l1_meshinfo
+    def GetElementPosition(self,ElemID):
+        return self.mesh.GetElementPosition(ElemID)
+
     ## If the given element is a node, returns the ID of shape
     #  \n If there is no node for the given ID - returns -1
     #  @return an integer value
@@ -2120,7 +2175,7 @@ class Mesh:
     def GetElemNbNodes(self, id):
         return self.mesh.GetElemNbNodes(id)
 
-    ## Returns the node ID the given index for the given element
+    ## Returns the node ID the given (zero based) index for the given element
     #  \n If there is no element for the given ID - returns -1
     #  \n If there is no node for the given index - returns -2
     #  @return an integer value
@@ -2334,6 +2389,24 @@ class Mesh:
     def Add0DElement(self, IDOfNode):
         return self.editor.Add0DElement(IDOfNode)
 
+    ## Create 0D elements on all nodes of the given elements except those 
+    #  nodes on which a 0D element already exists.
+    #  @param theObject an object on whose nodes 0D elements will be created.
+    #         It can be mesh, sub-mesh, group, list of element IDs or a holder
+    #         of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE )
+    #  @param theGroupName optional name of a group to add 0D elements created
+    #         and/or found on nodes of \a theObject.
+    #  @return an object (a new group or a temporary SMESH_IDSource) holding
+    #          IDs of new and/or found 0D elements. IDs of 0D elements 
+    #          can be retrieved from the returned object by calling GetIDs()
+    #  @ingroup l2_modif_add
+    def Add0DElementsToAllNodes(self, theObject, theGroupName=""):
+        if isinstance( theObject, Mesh ):
+            theObject = theObject.GetMesh()
+        if isinstance( theObject, list ):
+            theObject = self.GetIDSource( theObject, SMESH.ALL )
+        return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName )
+
     ## Creates a ball element on a node with given ID.
     #  @param IDOfNode the ID of node for creation of the element.
     #  @param diameter the bal diameter.
@@ -2627,30 +2700,25 @@ class Mesh:
 
     ## Fuses the neighbouring triangles into quadrangles.
     #  @param IDsOfElements The triangles to be fused,
-    #  @param theCriterion  is FT_...; used to choose a neighbour to fuse with.
+    #  @param theCriterion  is a numerical functor, in terms of enum SMESH.FunctorType, used to
+    #                       choose a neighbour to fuse with.
     #  @param MaxAngle      is the maximum angle between element normals at which the fusion
     #                       is still performed; theMaxAngle is mesured in radians.
     #                       Also it could be a name of variable which defines angle in degrees.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_unitetri
     def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
-        flag = False
-        if isinstance(MaxAngle,str):
-            flag = True
         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
         self.mesh.SetParameters(Parameters)
         if not IDsOfElements:
             IDsOfElements = self.GetElementsId()
-        Functor = 0
-        if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
-            Functor = theCriterion
-        else:
-            Functor = self.smeshpyD.GetFunctor(theCriterion)
+        Functor = self.smeshpyD.GetFunctor(theCriterion)
         return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
 
     ## Fuses the neighbouring triangles of the object into quadrangles
     #  @param theObject is mesh, submesh or group
-    #  @param theCriterion is FT_...; used to choose a neighbour to fuse with.
+    #  @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
+    #         choose a neighbour to fuse with.
     #  @param MaxAngle   a max angle between element normals at which the fusion
     #                   is still performed; theMaxAngle is mesured in radians.
     #  @return TRUE in case of success, FALSE otherwise.
@@ -2658,29 +2726,42 @@ class Mesh:
     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
         MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
         self.mesh.SetParameters(Parameters)
-        if ( isinstance( theObject, Mesh )):
+        if isinstance( theObject, Mesh ):
             theObject = theObject.GetMesh()
-        return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
+        Functor = self.smeshpyD.GetFunctor(theCriterion)
+        return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
 
     ## Splits quadrangles into triangles.
+    #
     #  @param IDsOfElements the faces to be splitted.
-    #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
+    #  @param theCriterion   is a numerical functor, in terms of enum SMESH.FunctorType, used to
+    #         choose a diagonal for splitting. If @a theCriterion is None, which is a default
+    #         value, then quadrangles will be split by the smallest diagonal.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_cutquadr
-    def QuadToTri (self, IDsOfElements, theCriterion):
+    def QuadToTri (self, IDsOfElements, theCriterion = None):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
-        return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
+        if theCriterion is None:
+            theCriterion = FT_MaxElementLength2D
+        Functor = self.smeshpyD.GetFunctor(theCriterion)
+        return self.editor.QuadToTri(IDsOfElements, Functor)
 
     ## Splits quadrangles into triangles.
-    #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
-    #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
+    #  @param theObject the object from which the list of elements is taken,
+    #         this is mesh, submesh or group
+    #  @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
+    #         choose a diagonal for splitting. If @a theCriterion is None, which is a default
+    #         value, then quadrangles will be split by the smallest diagonal.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_cutquadr
-    def QuadToTriObject (self, theObject, theCriterion):
+    def QuadToTriObject (self, theObject, theCriterion = None):
         if ( isinstance( theObject, Mesh )):
             theObject = theObject.GetMesh()
-        return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
+        if theCriterion is None:
+            theCriterion = FT_MaxElementLength2D
+        Functor = self.smeshpyD.GetFunctor(theCriterion)
+        return self.editor.QuadToTriObject(theObject, Functor)
 
     ## Splits quadrangles into triangles.
     #  @param IDsOfElements the faces to be splitted
@@ -2693,7 +2774,8 @@ class Mesh:
         return self.editor.SplitQuad(IDsOfElements, Diag13)
 
     ## Splits quadrangles into triangles.
-    #  @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
+    #  @param theObject the object from which the list of elements is taken,
+    #         this is mesh, submesh or group
     #  @param Diag13    is used to choose a diagonal for splitting.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_cutquadr
@@ -2704,7 +2786,8 @@ class Mesh:
 
     ## Finds a better splitting of the given quadrangle.
     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
-    #  @param theCriterion  FT_...; a criterion to choose a diagonal for splitting.
+    #  @param theCriterion  is a numerical functor, in terms of enum SMESH.FunctorType, used to
+    #         choose a diagonal for splitting.
     #  @return 1 if 1-3 diagonal is better, 2 if 2-4
     #          diagonal is better, 0 if error occurs.
     #  @ingroup l2_modif_cutquadr
@@ -2933,19 +3016,23 @@ class Mesh:
         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
                                                   MaxNbOfIterations, MaxAspectRatio, Method)
 
-    ## Converts the mesh to quadratic, deletes old elements, replacing
+    ## Converts the mesh to quadratic or bi-quadratic, deletes old elements, replacing
     #  them with quadratic with the same id.
     #  @param theForce3d new node creation method:
     #         0 - the medium node lies at the geometrical entity from which the mesh element is built
     #         1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
     #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
+    #  @param theToBiQuad If True, converts the mesh to bi-quadratic
     #  @ingroup l2_modif_tofromqu
-    def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
-        if theSubMesh:
-            self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
+    def ConvertToQuadratic(self, theForce3d, theSubMesh=None, theToBiQuad=False):
+        if theToBiQuad:
+            self.editor.ConvertToBiQuadratic(theForce3d,theSubMesh)
         else:
-            self.editor.ConvertToQuadratic(theForce3d)
-
+            if theSubMesh:
+                self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
+            else:
+                self.editor.ConvertToQuadratic(theForce3d)
+            
     ## Converts the mesh from quadratic to ordinary,
     #  deletes old quadratic elements, \n replacing
     #  them with ordinary mesh elements with the same id.
@@ -3147,7 +3234,9 @@ class Mesh:
 
     ## Generates new elements by extrusion of the elements with given ids
     #  @param IDsOfElements the list of elements ids for extrusion
-    #  @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
+    #  @param StepVector vector or DirStruct or 3 vector components, defining
+    #         the direction and value of extrusion for one step (the total extrusion
+    #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @param IsNodes is True if elements with given ids are nodes
@@ -3156,8 +3245,10 @@ class Mesh:
     def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
-        if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
+        if isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object):
             StepVector = self.smeshpyD.GetDirStruct(StepVector)
+        if isinstance( StepVector, list ):
+            StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
         Parameters = StepVector.PS.parameters + var_separator + Parameters
         self.mesh.SetParameters(Parameters)
@@ -3174,7 +3265,9 @@ class Mesh:
 
     ## Generates new elements by extrusion of the elements with given ids
     #  @param IDsOfElements is ids of elements
-    #  @param StepVector vector, defining the direction and value of extrusion
+    #  @param StepVector vector or DirStruct or 3 vector components, defining
+    #         the direction and value of extrusion for one step (the total extrusion
+    #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param ExtrFlags sets flags for extrusion
     #  @param SewTolerance uses for comparing locations of nodes if flag
@@ -3186,6 +3279,8 @@ class Mesh:
                           ExtrFlags, SewTolerance, MakeGroups=False):
         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
             StepVector = self.smeshpyD.GetDirStruct(StepVector)
+        if isinstance( StepVector, list ):
+            StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
         if MakeGroups:
             return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
                                                            ExtrFlags, SewTolerance)
@@ -3196,7 +3291,9 @@ class Mesh:
     ## Generates new elements by extrusion of the elements which belong to the object
     #  @param theObject the object which elements should be processed.
     #                   It can be a mesh, a sub mesh or a group.
-    #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
+    #  @param StepVector vector or DirStruct or 3 vector components, defining
+    #         the direction and value of extrusion for one step (the total extrusion
+    #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @param  IsNodes is True if elements which belong to the object are nodes
@@ -3207,6 +3304,8 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
             StepVector = self.smeshpyD.GetDirStruct(StepVector)
+        if isinstance( StepVector, list ):
+            StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
         Parameters = StepVector.PS.parameters + var_separator + Parameters
         self.mesh.SetParameters(Parameters)
@@ -3224,7 +3323,9 @@ class Mesh:
     ## Generates new elements by extrusion of the elements which belong to the object
     #  @param theObject object which elements should be processed.
     #                   It can be a mesh, a sub mesh or a group.
-    #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
+    #  @param StepVector vector or DirStruct or 3 vector components, defining
+    #         the direction and value of extrusion for one step (the total extrusion
+    #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param MakeGroups to generate new groups from existing ones
     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
@@ -3234,6 +3335,8 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
             StepVector = self.smeshpyD.GetDirStruct(StepVector)
+        if isinstance( StepVector, list ):
+            StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
         Parameters = StepVector.PS.parameters + var_separator + Parameters
         self.mesh.SetParameters(Parameters)
@@ -3245,7 +3348,9 @@ class Mesh:
     ## Generates new elements by extrusion of the elements which belong to the object
     #  @param theObject object which elements should be processed.
     #                   It can be a mesh, a sub mesh or a group.
-    #  @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
+    #  @param StepVector vector or DirStruct or 3 vector components, defining
+    #         the direction and value of extrusion for one step (the total extrusion
+    #         length will be NbOfSteps * ||StepVector||)
     #  @param NbOfSteps the number of steps
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
@@ -3255,6 +3360,8 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
             StepVector = self.smeshpyD.GetDirStruct(StepVector)
+        if isinstance( StepVector, list ):
+            StepVector = self.smeshpyD.MakeDirStruct(*StepVector)
         NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
         Parameters = StepVector.PS.parameters + var_separator + Parameters
         self.mesh.SetParameters(Parameters)
@@ -3559,7 +3666,7 @@ class Mesh:
 
     ## Translates the elements
     #  @param IDsOfElements list of elements ids
-    #  @param Vector the direction of translation (DirStruct or vector)
+    #  @param Vector the direction of translation (DirStruct or vector or 3 vector components)
     #  @param Copy allows copying the translated elements
     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
@@ -3569,6 +3676,8 @@ class Mesh:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        if isinstance( Vector, list ):
+            Vector = self.smeshpyD.MakeDirStruct(*Vector)
         self.mesh.SetParameters(Vector.PS.parameters)
         if Copy and MakeGroups:
             return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
@@ -3577,7 +3686,7 @@ class Mesh:
 
     ## Creates a new mesh of translated elements
     #  @param IDsOfElements list of elements ids
-    #  @param Vector the direction of translation (DirStruct or vector)
+    #  @param Vector the direction of translation (DirStruct or vector or 3 vector components)
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @param NewMeshName the name of the newly created mesh
     #  @return instance of Mesh class
@@ -3587,13 +3696,15 @@ class Mesh:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        if isinstance( Vector, list ):
+            Vector = self.smeshpyD.MakeDirStruct(*Vector)
         self.mesh.SetParameters(Vector.PS.parameters)
         mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
         return Mesh ( self.smeshpyD, self.geompyD, mesh )
 
     ## Translates the object
     #  @param theObject the object to translate (mesh, submesh, or group)
-    #  @param Vector direction of translation (DirStruct or geom vector)
+    #  @param Vector direction of translation (DirStruct or geom vector or 3 vector components)
     #  @param Copy allows copying the translated elements
     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
@@ -3603,6 +3714,8 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        if isinstance( Vector, list ):
+            Vector = self.smeshpyD.MakeDirStruct(*Vector)
         self.mesh.SetParameters(Vector.PS.parameters)
         if Copy and MakeGroups:
             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
@@ -3611,16 +3724,18 @@ class Mesh:
 
     ## Creates a new mesh from the translated object
     #  @param theObject the object to translate (mesh, submesh, or group)
-    #  @param Vector the direction of translation (DirStruct or geom vector)
+    #  @param Vector the direction of translation (DirStruct or geom vector or 3 vector components)
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @param NewMeshName the name of the newly created mesh
     #  @return instance of Mesh class
     #  @ingroup l2_modif_trsf
     def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
-        if (isinstance(theObject, Mesh)):
+        if isinstance( theObject, Mesh ):
             theObject = theObject.GetMesh()
-        if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
+        if isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object ):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        if isinstance( Vector, list ):
+            Vector = self.smeshpyD.MakeDirStruct(*Vector)
         self.mesh.SetParameters(Vector.PS.parameters)
         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
         return Mesh( self.smeshpyD, self.geompyD, mesh )
@@ -3641,6 +3756,10 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( theObject, list )):
             theObject = self.GetIDSource(theObject, SMESH.ALL)
+        if ( isinstance( theScaleFact, float )):
+             theScaleFact = [theScaleFact]
+        if ( isinstance( theScaleFact, int )):
+             theScaleFact = [ float(theScaleFact)]
 
         self.mesh.SetParameters(thePoint.parameters)
 
@@ -3661,6 +3780,10 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( theObject, list )):
             theObject = self.GetIDSource(theObject,SMESH.ALL)
+        if ( isinstance( theScaleFact, float )):
+             theScaleFact = [theScaleFact]
+        if ( isinstance( theScaleFact, int )):
+             theScaleFact = [ float(theScaleFact)]
 
         self.mesh.SetParameters(thePoint.parameters)
         mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
@@ -4038,9 +4161,16 @@ class Mesh:
     def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
         return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords )
 
+    def _getFunctor(self, funcType ):
+        fn = self.functors[ funcType._v ]
+        if not fn:
+            fn = self.smeshpyD.GetFunctor(funcType)
+            fn.SetMesh(self.mesh)
+            self.functors[ funcType._v ] = fn
+        return fn
+
     def _valueFromFunctor(self, funcType, elemId):
-        fn = self.smeshpyD.GetFunctor(funcType)
-        fn.SetMesh(self.mesh)
+        fn = self._getFunctor( funcType )
         if fn.GetElementType() == self.GetElementType(elemId, True):
             val = fn.GetValue(elemId)
         else: