Salome HOME
RNC: Completed the documentation of GetElementsByType with the values taken by Elemen...
[modules/smesh.git] / src / SMESH_SWIG / smeshDC.py
index 693b1c3a843704c65218c2163619bb200a043e49..7f17127c23f9570a997bde68f3dc3a1a485f026d 100644 (file)
@@ -513,6 +513,20 @@ class smeshDC(SMESH._objref_SMESH_Gen):
     def EnumToLong(self,theItem):
         return theItem._v
 
+    ## Returns a string representation of the color.
+    #  To be used with filters.
+    #  @param c color value (SALOMEDS.Color)
+    #  @ingroup l1_controls
+    def ColorToString(self,c):
+        val = ""
+        if isinstance(c, SALOMEDS.Color):
+            val = "%s;%s;%s" % (c.R, c.G, c.B)
+        elif isinstance(c, str):
+            val = c
+        else:
+            raise ValueError, "Color value should be of string or SALOMEDS.Color type"
+        return val
+
     ## Gets PointStruct from vertex
     #  @param theVertex a GEOM object(vertex)
     #  @return SMESH.PointStruct
@@ -753,8 +767,28 @@ class smeshDC(SMESH._objref_SMESH_Gen):
             else:
                 print "Error: The treshold should be a string."
                 return None
+        elif CritType == FT_ElemGeomType:
+            # Checks the treshold
+            try:
+                aCriterion.Threshold = self.EnumToLong(aTreshold)
+            except:
+                if isinstance(aTreshold, int):
+                    aCriterion.Threshold = aTreshold
+                else:
+                    print "Error: The treshold should be an integer or SMESH.GeometryType."
+                    return None
+                pass
+            pass
+        elif CritType == FT_GroupColor:
+            # Checks the treshold
+            try:
+                aCriterion.ThresholdStr = self.ColorToString(aTreshold)
+            except:
+                print "Error: The threshold value should be of SALOMEDS.Color type"
+                return None
+            pass
         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
-                          FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
+                          FT_FreeFaces, FT_LinearOrQuadratic]:
             # At this point the treshold is unnecessary
             if aTreshold ==  FT_LogicalNOT:
                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
@@ -1165,6 +1199,7 @@ class Mesh:
 
 
     ## Computes the mesh and returns the status of the computation
+    #  @param geom geomtrical shape on which mesh data should be computed
     #  @param discardModifs if True and the mesh has been edited since
     #         a last total re-compute and that may prevent successful partial re-compute,
     #         then the mesh is cleaned before Compute()
@@ -1965,7 +2000,7 @@ class Mesh:
         return self.mesh.GetElementsId()
 
     ## Returns the list of IDs of mesh elements with the given type
-    #  @param elementType  the required type of elements
+    #  @param elementType  the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
     #  @return list of integer values
     #  @ingroup l1_meshinfo
     def GetElementsByType(self, elementType):
@@ -2733,6 +2768,9 @@ 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
+    #         1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
     #  @ingroup l2_modif_tofromqu
     def ConvertToQuadratic(self, theForce3d):
         self.editor.ConvertToQuadratic(theForce3d)
@@ -3536,10 +3574,17 @@ class Mesh:
     ## Finds groups of ajacent nodes within Tolerance.
     #  @param Tolerance the value of tolerance
     #  @param SubMeshOrGroup SubMesh or Group
+    #  @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
     #  @return the list of groups of nodes
     #  @ingroup l2_modif_trsf
-    def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
-        return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
+    def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
+        if (isinstance( SubMeshOrGroup, Mesh )):
+            SubMeshOrGroup = SubMeshOrGroup.GetMesh()
+        if not isinstance( ExceptSubMeshOrGroups, list):
+            ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
+        if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
+            ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
+        return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
 
     ## Merges nodes
     #  @param GroupsOfNodes the list of groups of nodes
@@ -3655,11 +3700,15 @@ class Mesh:
     #  This method provided for convenience works as DoubleNodes() described above.
     #  @param theNodes group of nodes to be doubled
     #  @param theModifiedElems group of elements to be updated.
-    #  @return TRUE if operation has been completed successfully, FALSE otherwise
+    #  @param theMakeGroup forces the generation of a group containing new nodes.
+    #  @return TRUE or a created group if operation has been completed successfully,
+    #          FALSE or None otherwise
     #  @ingroup l2_modif_edit
-    def DoubleNodeGroup(self, theNodes, theModifiedElems):
+    def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
+        if theMakeGroup:
+            return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
         return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
-        
+
     ## Creates a hole in a mesh by doubling the nodes of some particular elements
     #  This method provided for convenience works as DoubleNodes() described above.
     #  @param theNodes list of groups of nodes to be doubled
@@ -3698,10 +3747,13 @@ class Mesh:
     #  @param theNodesNot - group of nodes not to replicated
     #  @param theAffectedElems - group of elements to which the replicated nodes
     #         should be associated to.
+    #  @param theMakeGroup forces the generation of a group containing new elements.
     #  @ingroup l2_modif_edit
-    def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
+    def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
+        if theMakeGroup:
+            return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
         return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
-        
+
     ## Creates a hole in a mesh by doubling the nodes of some particular elements
     #  This method provided for convenience works as DoubleNodes() described above.
     #  @param theElems - group of of elements (edges or faces) to be replicated
@@ -4395,7 +4447,7 @@ class Mesh_Triangle(Mesh_Algorithm):
         self.Parameters().SetPhyMax(theVal)
 
     ## Sets a way to define maximum angular deflection of mesh from CAD model.
-    #  @param theGeometricMesh is: DefaultGeom or Custom
+    #  @param theGeometricMesh is: 0 (None) or 1 (Custom)
     #  @ingroup l3_hypos_blsurf
     def SetGeometricMesh(self, theGeometricMesh=0):
         #  Parameter of BLSURF algo