Salome HOME
NPAL18095: Pb. with dump python and mesh group by filter.
[modules/smesh.git] / src / SMESH_SWIG / smesh.py
index 0e77b345966c77210f765c8d59d01251bc8047c4..15f933c85096a00f0f91b946dad950cb891096f7 100644 (file)
@@ -128,6 +128,13 @@ def GetDirStruct(theVector):
     dir = DirStruct(pnt)
     return dir
 
+## Make DirStruct from a triplet
+#  @param x,y,z are vector components
+#  @return SMESH.DirStruct
+def MakeDirStruct(x,y,z):
+    pnt = PointStruct(x,y,z)
+    return DirStruct(pnt)
+
 ## Get AxisStruct from object
 #  @param theObj is GEOM object(line or plane)
 #  @return SMESH.AxisStruct
@@ -275,7 +282,7 @@ def GetCriterion(elementType,
             print "Error: Treshold should be a string."
             return None
     elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
-        # Here we don't need treshold
+        # Here we do not need treshold
         if aTreshold ==  FT_LogicalNOT:
             aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
         elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
@@ -395,7 +402,7 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo):
 
     
     
-## Mother class to define algorithm, recommended to don't use directly.
+## Mother class to define algorithm, recommended to do not use directly.
 #
 #  More details.
 class Mesh_Algorithm:
@@ -468,14 +475,14 @@ class Mesh_Algorithm:
 
         self.algo = algo
         status = mesh.mesh.AddHypothesis(self.geom, self.algo)
-        TreatHypoStatus( status, algo.GetName(), GetName(algo), True )
+        TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
 
     ## Private method
     def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so", UseExisting=0):
         CreateNew = 1
         if UseExisting:
             hypo = self.FindHypothesis(hyp, args)
-            if hypo!=None: CreateNew = 0
+            if hypo: CreateNew = 0
             pass
         if CreateNew:
             hypo = smesh.CreateHypothesis(hyp, so)
@@ -494,7 +501,7 @@ class Mesh_Algorithm:
             SetName(hypo, hyp + a)
             pass
         status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
-        TreatHypoStatus( status, hyp, GetName(hypo), 0 )
+        TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
         return hypo
 
 
@@ -506,7 +513,7 @@ class Mesh_Algorithm:
 #  More details.
 class Mesh_Segment(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Segment's
+    algo = 0 # algorithm object common for all Mesh_Segments
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -623,7 +630,7 @@ class Mesh_Segment(Mesh_Algorithm):
 #  More details.
 class Mesh_CompositeSegment(Mesh_Segment):
 
-    algo = 0 # algorithm object common for all Mesh_CompositeSegment's
+    algo = 0 # algorithm object common for all Mesh_CompositeSegments
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -642,7 +649,7 @@ class Mesh_CompositeSegment(Mesh_Segment):
 #  More details.
 class Mesh_Segment_Python(Mesh_Segment):
 
-    algo = 0 # algorithm object common for all Mesh_Segment_Python's
+    algo = 0 # algorithm object common for all Mesh_Segment_Pythons
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -781,22 +788,27 @@ class Mesh_Triangle(Mesh_Algorithm):
     #
     #  Only for algoType == NETGEN
     def SetMaxSize(self, theSize):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetMaxSize(theSize)
-        
+
     ## Set SecondOrder flag
     #
     #  Only for algoType == NETGEN
     def SetSecondOrder(self, theVal):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetSecondOrder(theVal)
-            return
 
     ## Set Optimize flag
     #
     #  Only for algoType == NETGEN
     def SetOptimize(self, theVal):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetOptimize(theVal)
 
     ## Set Fineness
@@ -805,33 +817,41 @@ class Mesh_Triangle(Mesh_Algorithm):
     #
     #  Only for algoType == NETGEN
     def SetFineness(self, theFineness):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetFineness(theFineness)
-        
+
     ## Set GrowthRate  
     #
     #  Only for algoType == NETGEN
     def SetGrowthRate(self, theRate):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetGrowthRate(theRate)
 
     ## Set NbSegPerEdge
     #
     #  Only for algoType == NETGEN
     def SetNbSegPerEdge(self, theVal):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetNbSegPerEdge(theVal)
 
     ## Set NbSegPerRadius
     #
     #  Only for algoType == NETGEN
     def SetNbSegPerRadius(self, theVal):
-        if self.params == 0 and self.Parameters():
+        if self.params == 0:
+            self.Parameters()
+        if self.params is not None:
             self.params.SetNbSegPerRadius(theVal)
 
     pass
-        
-    
+
+
 # Public class: Mesh_Quadrangle
 # -----------------------------
 
@@ -840,7 +860,7 @@ class Mesh_Triangle(Mesh_Algorithm):
 #  More details.
 class Mesh_Quadrangle(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Quadrangle's
+    algo = 0 # algorithm object common for all Mesh_Quadrangles
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -868,9 +888,9 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
     params = 0
     algoType = 0
 
-    algoNET = 0 # algorithm object common for all Mesh_Tetrahedron's
-    algoGHS = 0 # algorithm object common for all Mesh_Tetrahedron's
-    algoFNET = 0 # algorithm object common for all Mesh_Tetrahedron's
+    algoNET = 0 # algorithm object common for all Mesh_Tetrahedrons
+    algoGHS = 0 # algorithm object common for all Mesh_Tetrahedrons
+    algoFNET = 0 # algorithm object common for all Mesh_Tetrahedrons
 
     ## Private constructor.
     def __init__(self, mesh, algoType, geom=0):
@@ -974,7 +994,7 @@ class Mesh_Tetrahedron(Mesh_Algorithm):
 #  More details.
 class Mesh_Hexahedron(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Hexahedron's
+    algo = 0 # algorithm object common for all Mesh_Hexahedrons
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -998,8 +1018,8 @@ class Mesh_Netgen(Mesh_Algorithm):
 
     is3D = 0
 
-    algoNET23 = 0 # algorithm object common for all Mesh_Netgen's
-    algoNET2 = 0 # algorithm object common for all Mesh_Netgen's
+    algoNET23 = 0 # algorithm object common for all Mesh_Netgens
+    algoNET2 = 0 # algorithm object common for all Mesh_Netgens
 
     ## Private constructor.
     def __init__(self, mesh, is3D, geom=0):
@@ -1041,7 +1061,7 @@ class Mesh_Netgen(Mesh_Algorithm):
 #  More details.
 class Mesh_Projection1D(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Projection1D's
+    algo = 0 # algorithm object common for all Mesh_Projection1Ds
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -1079,7 +1099,7 @@ class Mesh_Projection1D(Mesh_Algorithm):
 #  More details.
 class Mesh_Projection2D(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Projection2D's
+    algo = 0 # algorithm object common for all Mesh_Projection2Ds
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -1123,7 +1143,7 @@ class Mesh_Projection2D(Mesh_Algorithm):
 #  More details.
 class Mesh_Projection3D(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Projection3D's
+    algo = 0 # algorithm object common for all Mesh_Projection3Ds
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -1169,7 +1189,7 @@ class Mesh_Projection3D(Mesh_Algorithm):
 #  More details.
 class Mesh_Prism3D(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_Prism3D's
+    algo = 0 # algorithm object common for all Mesh_Prism3Ds
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -1187,7 +1207,7 @@ class Mesh_Prism3D(Mesh_Algorithm):
 #  More details.
 class Mesh_RadialPrism3D(Mesh_Algorithm):
 
-    algo = 0 # algorithm object common for all Mesh_RadialPrism3D's
+    algo = 0 # algorithm object common for all Mesh_RadialPrism3Ds
 
     ## Private constructor.
     def __init__(self, mesh, geom=0):
@@ -1275,6 +1295,26 @@ class Mesh_RadialPrism3D(Mesh_Algorithm):
         hyp.SetFineness( fineness )
         return hyp
 
+# Private class: Mesh_UseExisting
+# -------------------------------
+class Mesh_UseExisting(Mesh_Algorithm):
+
+    algo1D = 0 # StdMeshers_UseExisting_1D object common for all Mesh_UseExisting
+    algo2D = 0 # StdMeshers_UseExisting_2D object common for all Mesh_UseExisting
+
+    def __init__(self, dim, mesh, geom=0):
+        if dim == 1:
+            if not Mesh_UseExisting.algo1D:
+                Mesh_UseExisting.algo1D= self.Create(mesh, geom, "UseExisting_1D")
+            else:
+                self.Assign( Mesh_UseExisting.algo1D, mesh, geom)
+                pass
+        else:
+            if not Mesh_UseExisting.algo2D:
+                Mesh_UseExisting.algo2D= self.Create(mesh, geom, "UseExisting_2D")
+            else:
+                self.Assign( Mesh_UseExisting.algo2D, mesh, geom)
+                pass
 
 # Public class: Mesh
 # ==================
@@ -1408,7 +1448,29 @@ class Mesh:
             return Mesh_CompositeSegment(self, geom)
         else:
             return Mesh_Segment(self, geom)
-        
+
+    ## Enable creation of nodes and segments usable by 2D algoritms.
+    #  Added nodes and segments must be bound to edges and vertices by
+    #  SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
+    #  If the optional \a geom parameter is not sets, this algorithm is global.
+    #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
+    #  @param geom subshape to be manually meshed
+    #  @return StdMeshers_UseExisting_1D algorithm that generates nothing
+    def UseExistingSegments(self, geom=0):
+        algo = Mesh_UseExisting(1,self,geom)
+        return algo.GetAlgorithm()
+
+    ## Enable creation of nodes and faces usable by 3D algoritms.
+    #  Added nodes and faces must be bound to geom faces by SetNodeOnFace()
+    #  and SetMeshElementOnShape()
+    #  If the optional \a geom parameter is not sets, this algorithm is global.
+    #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
+    #  @param geom subshape to be manually meshed
+    #  @return StdMeshers_UseExisting_2D algorithm that generates nothing
+    def UseExistingFaces(self, geom=0):
+        algo = Mesh_UseExisting(2,self,geom)
+        return algo.GetAlgorithm()
+
     ## Creates a triangle 2D algorithm for faces.
     #  If the optional \a geom parameter is not sets, this algorithm is global.
     #  \n Otherwise, this algorithm define a submesh based on \a geom subshape.
@@ -1501,33 +1563,36 @@ class Mesh:
         try:
             ok = smesh.Compute(self.mesh, geom)
         except SALOME.SALOME_Exception, ex:
-            print "Mesh computation failed, exception cought:"
+            print "Mesh computation failed, exception caught:"
             print "    ", ex.details.text
         except:
             import traceback
-            print "Mesh computation failed, exception cought:"
+            print "Mesh computation failed, exception caught:"
             traceback.print_exc()
         if not ok:
             errors = smesh.GetAlgoState( self.mesh, geom )
             allReasons = ""
             for err in errors:
                 if err.isGlobalAlgo:
-                    glob = " global "
+                    glob = "global"
                 else:
-                    glob = " local "
+                    glob = "local"
                     pass
-                dim = str(err.algoDim)
-                if err.name == MISSING_ALGO:
-                    reason = glob + dim + "D algorithm is missing"
-                elif err.name == MISSING_HYPO:
-                    name = '"' + err.algoName + '"'
-                    reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
-                elif err.name == NOT_CONFORM_MESH:
-                    reason = "Global \"Not Conform mesh allowed\" hypothesis is missing"
-                elif err.name == BAD_PARAM_VALUE:
-                    name = '"' + err.algoName + '"'
-                    reason = "Hypothesis of" + glob + dim + "D algorithm " + name +\
-                             " has a bad parameter value"
+                dim = err.algoDim
+                name = err.algoName
+                if len(name) == 0:
+                    reason = '%s %sD algorithm is missing' % (glob, dim)
+                elif err.state == HYP_MISSING:
+                    reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
+                              % (glob, dim, name, dim))
+                elif err.state == HYP_NOTCONFORM:
+                    reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
+                elif err.state == HYP_BAD_PARAMETER:
+                    reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
+                              % ( glob, dim, name ))
+                elif err.state == HYP_BAD_GEOMETRY:
+                    reason = ('%s %sD algorithm "%s" is assigned to geometry mismatching'
+                              'its expectation' % ( glob, dim, name ))
                 else:
                     reason = "For unknown reason."+\
                              " Revise Mesh.Compute() implementation in smesh.py!"
@@ -1809,6 +1874,10 @@ class Mesh:
     def GetGroups(self):
         return self.mesh.GetGroups()
 
+    ## Get number of groups existing in the mesh
+    def NbGroups(self):
+        return self.mesh.NbGroups()
+
     ## Get the list of names of groups existing in the mesh
     def GetGroupNames(self):
         groups = self.GetGroups()
@@ -2011,19 +2080,34 @@ class Mesh:
         return self.mesh.GetElementType(id, iselem)
 
     ## Returns list of submesh elements ids
-    #  @param shapeID is geom object(subshape) IOR
-    def GetSubMeshElementsId(self, shapeID):
-        return self.mesh.GetSubMeshElementsId(shapeID)
+    #  @param Shape is geom object(subshape) IOR
+    #  Shape must be subshape of a ShapeToMesh()
+    def GetSubMeshElementsId(self, Shape):
+        if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
+            ShapeID = Shape.GetSubShapeIndices()[0]
+        else:
+            ShapeID = Shape
+        return self.mesh.GetSubMeshElementsId(ShapeID)
 
     ## Returns list of submesh nodes ids
-    #  @param shapeID is geom object(subshape) IOR
-    def GetSubMeshNodesId(self, shapeID, all):
-        return self.mesh.GetSubMeshNodesId(shapeID, all)
+    #  @param Shape is geom object(subshape) IOR
+    #  Shape must be subshape of a ShapeToMesh()
+    def GetSubMeshNodesId(self, Shape, all):
+        if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
+            ShapeID = Shape.GetSubShapeIndices()[0]
+        else:
+            ShapeID = Shape
+        return self.mesh.GetSubMeshNodesId(ShapeID, all)
     
     ## Returns list of ids of submesh elements with given type
-    #  @param shapeID is geom object(subshape) IOR
-    def GetSubMeshElementType(self, shapeID):
-        return self.mesh.GetSubMeshElementType(shapeID)
+    #  @param Shape is geom object(subshape) IOR
+    #  Shape must be subshape of a ShapeToMesh()
+    def GetSubMeshElementType(self, Shape):
+        if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
+            ShapeID = Shape.GetSubShapeIndices()[0]
+        else:
+            ShapeID = Shape
+        return self.mesh.GetSubMeshElementType(ShapeID)
       
     ## Get mesh description
     def Dump(self):
@@ -2043,6 +2127,11 @@ class Mesh:
     def GetNodeInverseElements(self, id):
         return self.mesh.GetNodeInverseElements(id)
 
+    ## @brief Return position of a node on shape
+    #  @return SMESH::NodePosition
+    def GetNodePosition(self,NodeID):
+        return self.mesh.GetNodePosition(NodeID)
+
     ## If given element is node returns IDs of shape from position
     #  \n If there is not node for given ID - returns -1
     def GetShapeID(self, id):
@@ -2166,6 +2255,87 @@ class Mesh:
     def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
         return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
     
+
+    ## @brief Bind a node to a vertex
+    # @param NodeID - node ID
+    # @param Vertex - vertex or vertex ID
+    # @return True if succeed else raise an exception
+    def SetNodeOnVertex(self, NodeID, Vertex):
+        if ( isinstance( Vertex, geompy.GEOM._objref_GEOM_Object)):
+            VertexID = Vertex.GetSubShapeIndices()[0]
+        else:
+            VertexID = Vertex
+        try:
+            self.editor.SetNodeOnVertex(NodeID, VertexID)
+        except SALOME.SALOME_Exception, inst:
+            raise ValueError, inst.details.text
+        return True
+        
+
+    ## @brief Store node position on an edge
+    # @param NodeID - node ID
+    # @param Edge - edge or edge ID
+    # @param paramOnEdge - parameter on edge where the node is located
+    # @return True if succeed else raise an exception
+    def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
+        if ( isinstance( Edge, geompy.GEOM._objref_GEOM_Object)):
+            EdgeID = Edge.GetSubShapeIndices()[0]
+        else:
+            EdgeID = Edge
+        try:
+            self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
+        except SALOME.SALOME_Exception, inst:
+            raise ValueError, inst.details.text
+        return True
+
+    ## @brief Store node position on a face
+    # @param NodeID - node ID
+    # @param Face - face or face ID
+    # @param u - U parameter on face where the node is located
+    # @param v - V parameter on face where the node is located
+    # @return True if succeed else raise an exception
+    def SetNodeOnFace(self, NodeID, Face, u, v):
+        if ( isinstance( Face, geompy.GEOM._objref_GEOM_Object)):
+            FaceID = Face.GetSubShapeIndices()[0]
+        else:
+            FaceID = Face
+        try:
+            self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
+        except SALOME.SALOME_Exception, inst:
+            raise ValueError, inst.details.text
+        return True
+
+    ## @brief Bind a node to a solid
+    # @param NodeID - node ID
+    # @param Solid - solid or solid ID
+    # @return True if succeed else raise an exception
+    def SetNodeInVolume(self, NodeID, Solid):
+        if ( isinstance( Solid, geompy.GEOM._objref_GEOM_Object)):
+            SolidID = Solid.GetSubShapeIndices()[0]
+        else:
+            SolidID = Solid
+        try:
+            self.editor.SetNodeInVolume(NodeID, SolidID)
+        except SALOME.SALOME_Exception, inst:
+            raise ValueError, inst.details.text
+        return True
+
+    ## @brief Bind an element to a shape
+    # @param ElementID - element ID
+    # @param Shape - shape or shape ID
+    # @return True if succeed else raise an exception
+    def SetMeshElementOnShape(self, ElementID, Shape):
+        if ( isinstance( Shape, geompy.GEOM._objref_GEOM_Object)):
+            ShapeID = Shape.GetSubShapeIndices()[0]
+        else:
+            ShapeID = Shape
+        try:
+            self.editor.SetMeshElementOnShape(ElementID, ShapeID)
+        except SALOME.SALOME_Exception, inst:
+            raise ValueError, inst.details.text
+        return True
+
+
     ## Move node with given id
     #  @param NodeID id of the node
     #  @param x new X coordinate
@@ -2217,6 +2387,8 @@ class Mesh:
     ## Reorient all elements of the object
     #  @param theObject is mesh, submesh or group
     def ReorientObject(self, theObject):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.ReorientObject(theObject)
 
     ## Fuse neighbour triangles into quadrangles.
@@ -2237,6 +2409,8 @@ class Mesh:
     #                   is still performed; theMaxAngle is mesured in radians.
     #  @return TRUE in case of success, FALSE otherwise.
     def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
 
     ## Split quadrangles into triangles.
@@ -2252,6 +2426,8 @@ class Mesh:
     #  @param theObject object to taking list of elements from, is mesh, submesh or group
     #  @param theCriterion  is FT_...; used to choose a diagonal for splitting.
     def QuadToTriObject (self, theObject, theCriterion):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
 
     ## Split quadrangles into triangles.
@@ -2266,6 +2442,8 @@ class Mesh:
     ## Split quadrangles into triangles.
     #  @param theObject is object to taking list of elements from, is mesh, submesh or group
     def SplitQuadObject (self, theObject, Diag13):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.SplitQuadObject(theObject, Diag13)
 
     ## Find better splitting of the given quadrangle.
@@ -2438,6 +2616,8 @@ class Mesh:
     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
     def SmoothObject(self, theObject, IDsOfFixedNodes, 
                      MaxNbOfIterations, MaxxAspectRatio, Method):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.SmoothObject(theObject, IDsOfFixedNodes, 
                                         MaxNbOfIterations, MaxxAspectRatio, Method)
 
@@ -2464,6 +2644,8 @@ class Mesh:
     #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
     def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
                                MaxNbOfIterations, MaxAspectRatio, Method):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
                                                   MaxNbOfIterations, MaxAspectRatio, Method)
 
@@ -2492,12 +2674,17 @@ class Mesh:
     #  @param AngleInRadians angle of Rotation
     #  @param NbOfSteps number of steps
     #  @param Tolerance tolerance
-    def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
+    #  @param MakeGroups to generate new groups from existing ones
+    def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
             Axix = GetAxisStruct(Axix)
+        if MakeGroups:
+            return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
+                                                       AngleInRadians, NbOfSteps, Tolerance)
         self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
+        return []
 
     ## Generate new elements by rotation of the elements of object around the axis
     #  @param theObject object wich elements should be sweeped
@@ -2505,21 +2692,32 @@ class Mesh:
     #  @param AngleInRadians angle of Rotation
     #  @param NbOfSteps number of steps
     #  @param Tolerance tolerance
-    def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
+    #  @param MakeGroups to generate new groups from existing ones
+    def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
             Axix = GetAxisStruct(Axix)
+        if MakeGroups:
+            return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
+                                                             NbOfSteps, Tolerance)
         self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
+        return []
 
     ## Generate new elements by extrusion of the elements with given ids
     #  @param IDsOfElements list of elements ids for extrusion
     #  @param StepVector vector, defining the direction and value of extrusion 
     #  @param NbOfSteps the number of steps
-    def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
+    #  @param MakeGroups to generate new groups from existing ones
+    def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
             StepVector = GetDirStruct(StepVector)
+        if MakeGroups:
+            return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
         self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
+        return []
 
     ## Generate new elements by extrusion of the elements with given ids
     #  @param IDsOfElements is ids of elements
@@ -2528,37 +2726,61 @@ class Mesh:
     #  @param ExtrFlags set flags for performing extrusion
     #  @param SewTolerance uses for comparing locations of nodes if flag
     #         EXTRUSION_FLAG_SEW is set
-    def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
+    #  @param MakeGroups to generate new groups from existing ones
+    def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance, MakeGroups=False):
         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
             StepVector = GetDirStruct(StepVector)
-        self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
+        if MakeGroups:
+            return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
+                                                           ExtrFlags, SewTolerance)
+        self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
+                                      ExtrFlags, SewTolerance)
+        return []
 
     ## Generate new elements by extrusion of the elements belong to object
     #  @param theObject object wich elements should be processed
     #  @param StepVector vector, defining the direction and value of extrusion 
     #  @param NbOfSteps the number of steps
-    def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
+    #  @param MakeGroups to generate new groups from existing ones
+    def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
             StepVector = GetDirStruct(StepVector)
+        if MakeGroups:
+            return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
         self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
+        return []
 
     ## Generate new elements by extrusion of the elements belong to object
     #  @param theObject object wich elements should be processed
     #  @param StepVector vector, defining the direction and value of extrusion 
     #  @param NbOfSteps the number of steps
-    def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
+    #  @param MakeGroups to generate new groups from existing ones
+    def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
             StepVector = GetDirStruct(StepVector)
+        if MakeGroups:
+            return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
         self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
+        return []
     
     ## Generate new elements by extrusion of the elements belong to object
     #  @param theObject object wich elements should be processed
     #  @param StepVector vector, defining the direction and value of extrusion 
     #  @param NbOfSteps the number of steps    
-    def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
+    #  @param MakeGroups to generate new groups from existing ones
+    def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
             StepVector = GetDirStruct(StepVector)
+        if MakeGroups:
+            return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
         self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
+        return []
 
     ## Generate new elements by extrusion of the given elements
     #  A path of extrusion must be a meshed edge.
@@ -2571,16 +2793,22 @@ class Mesh:
     #  @param HasRefPoint allows to use base point 
     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
+    #  @param MakeGroups to generate new groups from existing ones
     #  @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
     def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
-                           HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
+                           HasAngles, Angles, HasRefPoint, RefPoint,
+                           MakeGroups=False, LinearVariation=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
             RefPoint = GetPointStruct(RefPoint)
             pass
-        return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
-                                              HasAngles, Angles, HasRefPoint, RefPoint)
+        if MakeGroups:
+            return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(),
+                                                            PathShape, NodeStart, HasAngles,
+                                                            Angles, HasRefPoint, RefPoint)
+        return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape,
+                                              NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
 
     ## Generate new elements by extrusion of the elements belong to object
     #  A path of extrusion must be a meshed edge.
@@ -2593,13 +2821,22 @@ class Mesh:
     #  @param HasRefPoint allows to use base point 
     #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
     #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
+    #  @param MakeGroups to generate new groups from existing ones
     #  @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps
     def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
-                                 HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False):
+                                 HasAngles, Angles, HasRefPoint, RefPoint,
+                                 MakeGroups=False, LinearVariation=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
             RefPoint = GetPointStruct(RefPoint) 
-        return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
-                                                    HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation)
+        if MakeGroups:
+            return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(),
+                                                                  PathShape, NodeStart, HasAngles,
+                                                                  Angles, HasRefPoint, RefPoint)
+        return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape,
+                                                    NodeStart, HasAngles, Angles, HasRefPoint,
+                                                    RefPoint)
     
     ## Symmetrical copy of mesh elements
     #  @param IDsOfElements list of elements ids
@@ -2607,12 +2844,32 @@ class Mesh:
     #  @param theMirrorType is  POINT, AXIS or PLANE
     #  If the Mirror is geom object this parameter is unnecessary
     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
-    def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
             Mirror = GetAxisStruct(Mirror)
+        if Copy and MakeGroups:
+            return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
         self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
+        return []
+
+    ## Create a new mesh by symmetrical copy of mesh elements
+    #  @param IDsOfElements list of elements ids
+    #  @param Mirror is AxisStruct or geom object(point, line, plane)
+    #  @param theMirrorType is  POINT, AXIS or PLANE
+    #  If the Mirror is geom object this parameter is unnecessary
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
+        if IDsOfElements == []:
+            IDsOfElements = self.GetElementsId()
+        if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
+            Mirror = GetAxisStruct(Mirror)
+        mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
+                                          MakeGroups, NewMeshName)
+        return Mesh(mesh)
 
     ## Symmetrical copy of object
     #  @param theObject mesh, submesh or group
@@ -2620,50 +2877,150 @@ class Mesh:
     #  @param theMirrorType is  POINT, AXIS or PLANE
     #  If the Mirror is geom object this parameter is unnecessary
     #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
-    def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
             Mirror = GetAxisStruct(Mirror)
+        if Copy and MakeGroups:
+            return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
         self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
+        return []
+
+    ## Create a new mesh by symmetrical copy of object
+    #  @param theObject mesh, submesh or group
+    #  @param Mirror is AxisStruct or geom object(point, line, plane)
+    #  @param theMirrorType is  POINT, AXIS or PLANE
+    #  If the Mirror is geom object this parameter is unnecessary
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
+        if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
+            Mirror = GetAxisStruct(Mirror)
+        mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
+                                                MakeGroups, NewMeshName)
+        return Mesh( mesh )
 
     ## Translates the elements
     #  @param IDsOfElements list of elements ids
     #  @param Vector direction of translation(DirStruct or vector)
     #  @param Copy allows to copy the translated elements
-    def Translate(self, IDsOfElements, Vector, Copy):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
             Vector = GetDirStruct(Vector)
+        if Copy and MakeGroups:
+            return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
         self.editor.Translate(IDsOfElements, Vector, Copy)
+        return []
+
+    ## Create a new mesh of translated elements
+    #  @param IDsOfElements list of elements ids
+    #  @param Vector direction of translation(DirStruct or vector)
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
+        if IDsOfElements == []:
+            IDsOfElements = self.GetElementsId()
+        if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
+            Vector = GetDirStruct(Vector)
+        mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
+        return Mesh ( mesh )
 
     ## Translates the object
     #  @param theObject object to translate(mesh, submesh, or group)
     #  @param Vector direction of translation(DirStruct or geom vector)
     #  @param Copy allows to copy the translated elements
-    def TranslateObject(self, theObject, Vector, Copy):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
         if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
             Vector = GetDirStruct(Vector)
+        if Copy and MakeGroups:
+            return self.editor.TranslateObjectMakeGroups(theObject, Vector)
         self.editor.TranslateObject(theObject, Vector, Copy)
+        return []
+
+    ## Create a new mesh from translated object
+    #  @param theObject object to translate(mesh, submesh, or group)
+    #  @param Vector direction of translation(DirStruct or geom vector)
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
+        if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
+            Vector = GetDirStruct(Vector)
+        mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
+        return Mesh( mesh )
 
     ## Rotates the elements
     #  @param IDsOfElements list of elements ids
     #  @param Axis axis of rotation(AxisStruct or geom line)
     #  @param AngleInRadians angle of rotation(in radians)
     #  @param Copy allows to copy the rotated elements   
-    def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
         if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
             Axis = GetAxisStruct(Axis)
+        if Copy and MakeGroups:
+            return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
         self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
+        return []
+
+    ## Create a new mesh of rotated elements
+    #  @param IDsOfElements list of element ids
+    #  @param Axis axis of rotation(AxisStruct or geom line)
+    #  @param AngleInRadians angle of rotation(in radians)
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
+        if IDsOfElements == []:
+            IDsOfElements = self.GetElementsId()
+        if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
+            Axis = GetAxisStruct(Axis)
+        mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
+                                          MakeGroups, NewMeshName)
+        return Mesh( mesh )
 
     ## Rotates the object
     #  @param theObject object to rotate(mesh, submesh, or group)
     #  @param Axis axis of rotation(AxisStruct or geom line)
     #  @param AngleInRadians angle of rotation(in radians)
     #  @param Copy allows to copy the rotated elements
-    def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
+    #  @param MakeGroups to generate new groups from existing ones (if Copy)
+    def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
+        if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
+            Axis = GetAxisStruct(Axis)
+        if Copy and MakeGroups:
+            return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
+        return []
+
+    ## Create a new mesh from a rotated object
+    #  @param theObject object to rotate (mesh, submesh, or group)
+    #  @param Axis axis of rotation(AxisStruct or geom line)
+    #  @param AngleInRadians angle of rotation(in radians)
+    #  @param MakeGroups to generate new groups from existing ones
+    #  @param NewMeshName is a name of new mesh to create
+    def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
+        if ( isinstance( theObject, Mesh )):
+            theObject = theObject.GetMesh()
+        if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
+            Axis = GetAxisStruct(Axis)
+        mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
+                                                       MakeGroups, NewMeshName)
+        return Mesh( mesh )
 
     ## Find group of nodes close to each other within Tolerance.
     #  @param Tolerance tolerance value
@@ -2739,13 +3096,13 @@ class Mesh:
         return self.editor.ChangeElemNodes(ide, newIDs)
     
     ## If during last operation of MeshEditor some nodes were
-    #  created this method returns list of it's IDs, \n
+    #  created this method returns list of its IDs, \n
     #  if new nodes not created - returns empty list
     def GetLastCreatedNodes(self):
         return self.editor.GetLastCreatedNodes()
 
     ## If during last operation of MeshEditor some elements were
-    #  created this method returns list of it's IDs, \n
+    #  created this method returns list of its IDs, \n
     #  if new elements not creared - returns empty list
     def GetLastCreatedElems(self):
         return self.editor.GetLastCreatedElems()