Salome HOME
0020978: EDF 1475 SMESH: Convert linear to quadratic on a submesh
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index a5dce4df87e8f919fb2f6a386958c7a2a6ef76cd..88591ffa79330365461999ac3f6012c6e9f849f2 100644 (file)
@@ -884,7 +884,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         aCriteria = []
         aCriteria.append(aCriterion)
         aFilter.SetCriteria(aCriteria)
-        aFilterMgr.Destroy()
+        aFilterMgr.UnRegister()
         return aFilter
 
     ## Creates a numerical functor by its type
@@ -1009,7 +1009,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             pass
         aMeasurements = self.CreateMeasurements()
         result = aMeasurements.MinDistance(src1, src2)
-        aMeasurements.Destroy()
+        aMeasurements.UnRegister()
         return result
 
     ## Get bounding box of the specified object(s)
@@ -1046,7 +1046,7 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             pass
         aMeasurements = self.CreateMeasurements()
         result = aMeasurements.BoundingBox(srclist)
-        aMeasurements.Destroy()
+        aMeasurements.UnRegister()
         return result
 
 import omniORB
@@ -1091,8 +1091,8 @@ class Mesh:
                     if studyID != geompyD.myStudyId:
                         geompyD.init_geom( smeshpyD.GetCurrentStudy())
                         pass
-                    name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
-                    geompyD.addToStudy( self.geom, name )
+                    geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
+                    geompyD.addToStudy( self.geom, geo_name )
                 self.mesh = self.smeshpyD.CreateMesh(self.geom)
 
             elif isinstance(obj, SMESH._objref_SMESH_Mesh):
@@ -1807,7 +1807,7 @@ class Mesh:
         aCriteria.append(Criterion)
         aFilter.SetCriteria(aCriteria)
         group = self.MakeGroupByFilter(groupName, aFilter)
-        aFilterMgr.Destroy()
+        aFilterMgr.UnRegister()
         return group
 
     ## Creates a mesh group by the given criteria (list of criteria)
@@ -1820,7 +1820,7 @@ class Mesh:
         aFilter = aFilterMgr.CreateFilter()
         aFilter.SetCriteria(theCriteria)
         group = self.MakeGroupByFilter(groupName, aFilter)
-        aFilterMgr.Destroy()
+        aFilterMgr.UnRegister()
         return group
 
     ## Creates a mesh group by the given filter
@@ -1851,7 +1851,7 @@ class Mesh:
         aPredicate = aFilterMgr.CreateFreeEdges()
         aPredicate.SetMesh(self.mesh)
         aBorders = aPredicate.GetBorders()
-        aFilterMgr.Destroy()
+        aFilterMgr.UnRegister()
         return aBorders
 
     ## Removes a group
@@ -2415,7 +2415,7 @@ class Mesh:
 
         aMeasurements = self.smeshpyD.CreateMeasurements()
         aMeasure = aMeasurements.MinDistance(id1, id2)
-        aMeasurements.Destroy()
+        aMeasurements.UnRegister()
         return aMeasure
 
     ## Get bounding box of the specified object(s)
@@ -2464,7 +2464,7 @@ class Mesh:
             pass
         aMeasurements = self.smeshpyD.CreateMeasurements()
         aMeasure = aMeasurements.BoundingBox(srclist)
-        aMeasurements.Destroy()
+        aMeasurements.UnRegister()
         return aMeasure
 
     # Mesh edition (SMESH_MeshEditor functionality):
@@ -3059,19 +3059,26 @@ class Mesh:
     ## Converts the mesh to 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 edge from which the mesh element is built
+    #         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
     #  @ingroup l2_modif_tofromqu
-    def ConvertToQuadratic(self, theForce3d):
-        self.editor.ConvertToQuadratic(theForce3d)
+    def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
+        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.
-    #  @return TRUE in case of success, FALSE otherwise.
+    #  @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
     #  @ingroup l2_modif_tofromqu
-    def ConvertFromQuadratic(self):
-        return self.editor.ConvertFromQuadratic()
+    def ConvertFromQuadratic(self, theSubMesh=None):
+        if theSubMesh:
+            self.editor.ConvertFromQuadraticObject(theSubMesh)
+        else:
+            return self.editor.ConvertFromQuadratic()
 
     ## Creates 2D mesh as skin on boundary faces of a 3D mesh
     #  @return TRUE if operation has been completed successfully, FALSE otherwise
@@ -3082,15 +3089,18 @@ class Mesh:
     ## Creates missing boundary elements
     #  @param elements - elements whose boundary is to be checked:
     #                    mesh, group, sub-mesh or list of elements
+    #   if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
     #  @param dimension - defines type of boundary elements to create:
     #                     SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
+    #    SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
     #  @param groupName - a name of group to store created boundary elements in,
     #                     "" means not to create the group
     #  @param meshName - a name of new mesh to store created boundary elements in,
     #                     "" means not to create the new mesh
-    #  @param toCopyElements - if true, the checked elements will be copied into the new mesh
+    #  @param toCopyElements - if true, the checked elements will be copied into
+    #     the new mesh else only boundary elements will be copied into the new mesh
     #  @param toCopyExistingBondary - if true, not only new but also pre-existing
-    #                                boundary elements will be copied into the new mesh
+    #     boundary elements will be copied into the new mesh
     #  @return tuple (mesh, group) where bondary elements were added to
     #  @ingroup l2_modif_edit
     def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
@@ -3106,6 +3116,29 @@ class Mesh:
         if mesh: mesh = self.smeshpyD.Mesh(mesh)
         return mesh, group
 
+    ##
+    # @brief Creates missing boundary elements around either the whole mesh or 
+    #    groups of 2D elements
+    #  @param dimension - defines type of boundary elements to create
+    #  @param groupName - a name of group to store all boundary elements in,
+    #    "" means not to create the group
+    #  @param meshName - a name of a new mesh, which is a copy of the initial 
+    #    mesh + created boundary elements; "" means not to create the new mesh
+    #  @param toCopyAll - if true, the whole initial mesh will be copied into
+    #    the new mesh else only boundary elements will be copied into the new mesh
+    #  @param groups - groups of 2D elements to make boundary around
+    #  @retval tuple( long, mesh, groups )
+    #                 long - number of added boundary elements
+    #                 mesh - the mesh where elements were added to
+    #                 group - the group of boundary elements or None
+    #
+    def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
+                             toCopyAll=False, groups=[]):
+        nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
+                                                           toCopyAll,groups)
+        if mesh: mesh = self.smeshpyD.Mesh(mesh)
+        return nb, mesh, group
+
     ## Renumber mesh nodes
     #  @ingroup l2_modif_renumber
     def RenumberNodes(self):