Back to index

salome-smesh  6.5.0
Functions
Quality controls and Filtering

Functions

def smeshDC.smeshDC.EnumToLong
 Returns a long value from enumeration Should be used for SMESH.FunctorType enumeration.
def smeshDC.smeshDC.ColorToString
 Returns a string representation of the color.
def smeshDC.smeshDC.GetEmptyCriterion
 Creates an empty criterion.
def smeshDC.smeshDC.GetCriterion
 Creates a criterion by the given parameters
Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
def smeshDC.smeshDC.GetFilter
 Creates a filter with the given parameters.
def smeshDC.smeshDC.GetFilterFromCriteria
 Creates a filter from criteria.
def smeshDC.smeshDC.GetFunctor
 Creates a numerical functor by its type.
def smeshDC.Mesh.GetIdsFromFilter
 Passes mesh elements through the given filter and return IDs of fitting elements.
def smeshDC.Mesh.GetFreeBorders
 Verifies whether a 2D mesh element has free edges (edges connected to one face only)
Returns a list of special structures (borders).

Function Documentation

def smeshDC.smeshDC.ColorToString (   self,
  c 
)

Returns a string representation of the color.

To be used with filters.

Parameters:
ccolor value (SALOMEDS.Color)

Definition at line 343 of file smeshDC.py.

00343 
00344     def ColorToString(self,c):
00345         val = ""
00346         if isinstance(c, SALOMEDS.Color):
00347             val = "%s;%s;%s" % (c.R, c.G, c.B)
00348         elif isinstance(c, str):
00349             val = c
00350         else:
00351             raise ValueError, "Color value should be of string or SALOMEDS.Color type"
00352         return val

Here is the caller graph for this function:

def smeshDC.smeshDC.EnumToLong (   self,
  theItem 
)

Returns a long value from enumeration Should be used for SMESH.FunctorType enumeration.

Definition at line 336 of file smeshDC.py.

00336 
00337     def EnumToLong(self,theItem):
00338         return theItem._v

Here is the caller graph for this function:

def smeshDC.smeshDC.GetCriterion (   self,
  elementType,
  CritType,
  Compare = FT_EqualTo,
  Threshold = "",
  UnaryOp = FT_Undefined,
  BinaryOp = FT_Undefined,
  Tolerance = 1e-07 
)

Creates a criterion by the given parameters
Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)

Parameters:
elementTypethe type of elements(NODE, EDGE, FACE, VOLUME)
CritTypethe type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
Comparebelongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
Thresholdthe threshold value (range of ids as string, shape, numeric)
UnaryOpFT_LogicalNOT or FT_Undefined
BinaryOpa binary logical operation FT_LogicalAND, FT_LogicalOR or FT_Undefined (must be for the last criterion of all criteria)
Tolerancethe tolerance used by FT_BelongToGeom, FT_BelongToSurface, FT_LyingOnGeom, FT_CoplanarFaces criteria
Returns:
SMESH.Filter.Criterion

Example of Criteria usage

Definition at line 609 of file smeshDC.py.

00609 
00610                      Tolerance=1e-07):
00611         if not CritType in SMESH.FunctorType._items:
00612             raise TypeError, "CritType should be of SMESH.FunctorType"
00613         aCriterion = self.GetEmptyCriterion()
00614         aCriterion.TypeOfElement = elementType
00615         aCriterion.Type = self.EnumToLong(CritType)
00616         aCriterion.Tolerance = Tolerance
00617 
00618         aThreshold = Threshold
00619 
00620         if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
00621             aCriterion.Compare = self.EnumToLong(Compare)
00622         elif Compare == "=" or Compare == "==":
00623             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00624         elif Compare == "<":
00625             aCriterion.Compare = self.EnumToLong(FT_LessThan)
00626         elif Compare == ">":
00627             aCriterion.Compare = self.EnumToLong(FT_MoreThan)
00628         elif Compare != FT_Undefined:
00629             aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00630             aThreshold = Compare
00631 
00632         if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
00633                         FT_BelongToCylinder, FT_LyingOnGeom]:
00634             # Checks the Threshold
00635             if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
00636                 aCriterion.ThresholdStr = GetName(aThreshold)
00637                 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
00638             else:
00639                 print "Error: The Threshold should be a shape."
00640                 return None
00641             if isinstance(UnaryOp,float):
00642                 aCriterion.Tolerance = UnaryOp
00643                 UnaryOp = FT_Undefined
00644                 pass
00645         elif CritType == FT_RangeOfIds:
00646             # Checks the Threshold
00647             if isinstance(aThreshold, str):
00648                 aCriterion.ThresholdStr = aThreshold
00649             else:
00650                 print "Error: The Threshold should be a string."
00651                 return None
00652         elif CritType == FT_CoplanarFaces:
00653             # Checks the Threshold
00654             if isinstance(aThreshold, int):
00655                 aCriterion.ThresholdID = "%s"%aThreshold
00656             elif isinstance(aThreshold, str):
00657                 ID = int(aThreshold)
00658                 if ID < 1:
00659                     raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
00660                 aCriterion.ThresholdID = aThreshold
00661             else:
00662                 raise ValueError,\
00663                       "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
00664         elif CritType == FT_ElemGeomType:
00665             # Checks the Threshold
00666             try:
00667                 aCriterion.Threshold = self.EnumToLong(aThreshold)
00668                 assert( aThreshold in SMESH.GeometryType._items )
00669             except:
00670                 if isinstance(aThreshold, int):
00671                     aCriterion.Threshold = aThreshold
00672                 else:
00673                     print "Error: The Threshold should be an integer or SMESH.GeometryType."
00674                     return None
00675                 pass
00676             pass
00677         elif CritType == FT_GroupColor:
00678             # Checks the Threshold
00679             try:
00680                 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
00681             except:
00682                 print "Error: The threshold value should be of SALOMEDS.Color type"
00683                 return None
00684             pass
00685         elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
00686                           FT_LinearOrQuadratic, FT_BadOrientedVolume,
00687                           FT_BareBorderFace, FT_BareBorderVolume,
00688                           FT_OverConstrainedFace, FT_OverConstrainedVolume,
00689                           FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
00690             # At this point the Threshold is unnecessary
00691             if aThreshold ==  FT_LogicalNOT:
00692                 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00693             elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
00694                 aCriterion.BinaryOp = aThreshold
00695         else:
00696             # Check Threshold
00697             try:
00698                 aThreshold = float(aThreshold)
00699                 aCriterion.Threshold = aThreshold
00700             except:
00701                 print "Error: The Threshold should be a number."
00702                 return None
00703 
00704         if Threshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
00705             aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00706 
00707         if Threshold in [FT_LogicalAND, FT_LogicalOR]:
00708             aCriterion.BinaryOp = self.EnumToLong(Threshold)
00709 
00710         if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
00711             aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
00712 
00713         if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
00714             aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
00715 
00716         return aCriterion

Here is the call graph for this function:

Here is the caller graph for this function:

Creates an empty criterion.

Returns:
SMESH.Filter.Criterion

Definition at line 574 of file smeshDC.py.

00574 
00575     def GetEmptyCriterion(self):
00576         Type = self.EnumToLong(FT_Undefined)
00577         Compare = self.EnumToLong(FT_Undefined)
00578         Threshold = 0
00579         ThresholdStr = ""
00580         ThresholdID = ""
00581         UnaryOp = self.EnumToLong(FT_Undefined)
00582         BinaryOp = self.EnumToLong(FT_Undefined)
00583         Tolerance = 1e-07
00584         TypeOfElement = ALL
00585         Precision = -1 ##@1e-07
00586         return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
00587                                 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)

Here is the call graph for this function:

Here is the caller graph for this function:

def smeshDC.smeshDC.GetFilter (   self,
  elementType,
  CritType = FT_Undefined,
  Compare = FT_EqualTo,
  Threshold = "",
  UnaryOp = FT_Undefined,
  Tolerance = 1e-07 
)

Creates a filter with the given parameters.

Parameters:
elementTypethe type of elements in the group
CritTypethe type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
Comparebelongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
Thresholdthe threshold value (range of id ids as string, shape, numeric)
UnaryOpFT_LogicalNOT or FT_Undefined
Tolerancethe tolerance used by FT_BelongToGeom, FT_BelongToSurface, FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
Returns:
SMESH_Filter

Example of Filters usage

Definition at line 734 of file smeshDC.py.

00734 
00735                   Tolerance=1e-07):
00736         aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
00737         aFilterMgr = self.CreateFilterManager()
00738         aFilter = aFilterMgr.CreateFilter()
00739         aCriteria = []
00740         aCriteria.append(aCriterion)
00741         aFilter.SetCriteria(aCriteria)
00742         aFilterMgr.UnRegister()
00743         return aFilter

Here is the call graph for this function:

Here is the caller graph for this function:

def smeshDC.smeshDC.GetFilterFromCriteria (   self,
  criteria 
)

Creates a filter from criteria.

Parameters:
criteriaa list of criteria
Returns:
SMESH_Filter

Example of Filters usage

Definition at line 750 of file smeshDC.py.

00750 
00751     def GetFilterFromCriteria(self,criteria):
00752         aFilterMgr = self.CreateFilterManager()
00753         aFilter = aFilterMgr.CreateFilter()
00754         aFilter.SetCriteria(criteria)
00755         aFilterMgr.UnRegister()
00756         return aFilter

Here is the call graph for this function:

Verifies whether a 2D mesh element has free edges (edges connected to one face only)
Returns a list of special structures (borders).

Returns:
a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.

Definition at line 1621 of file smeshDC.py.

01621 
01622     def GetFreeBorders(self):
01623         aFilterMgr = self.smeshpyD.CreateFilterManager()
01624         aPredicate = aFilterMgr.CreateFreeEdges()
01625         aPredicate.SetMesh(self.mesh)
01626         aBorders = aPredicate.GetBorders()
01627         aFilterMgr.UnRegister()
01628         return aBorders

def smeshDC.smeshDC.GetFunctor (   self,
  theCriterion 
)

Creates a numerical functor by its type.

Parameters:
theCriterionFT_...; functor type
Returns:
SMESH_NumericalFunctor

Definition at line 761 of file smeshDC.py.

00761 
00762     def GetFunctor(self,theCriterion):
00763         aFilterMgr = self.CreateFilterManager()
00764         if theCriterion == FT_AspectRatio:
00765             return aFilterMgr.CreateAspectRatio()
00766         elif theCriterion == FT_AspectRatio3D:
00767             return aFilterMgr.CreateAspectRatio3D()
00768         elif theCriterion == FT_Warping:
00769             return aFilterMgr.CreateWarping()
00770         elif theCriterion == FT_MinimumAngle:
00771             return aFilterMgr.CreateMinimumAngle()
00772         elif theCriterion == FT_Taper:
00773             return aFilterMgr.CreateTaper()
00774         elif theCriterion == FT_Skew:
00775             return aFilterMgr.CreateSkew()
00776         elif theCriterion == FT_Area:
00777             return aFilterMgr.CreateArea()
00778         elif theCriterion == FT_Volume3D:
00779             return aFilterMgr.CreateVolume3D()
00780         elif theCriterion == FT_MaxElementLength2D:
00781             return aFilterMgr.CreateMaxElementLength2D()
00782         elif theCriterion == FT_MaxElementLength3D:
00783             return aFilterMgr.CreateMaxElementLength3D()
00784         elif theCriterion == FT_MultiConnection:
00785             return aFilterMgr.CreateMultiConnection()
00786         elif theCriterion == FT_MultiConnection2D:
00787             return aFilterMgr.CreateMultiConnection2D()
00788         elif theCriterion == FT_Length:
00789             return aFilterMgr.CreateLength()
00790         elif theCriterion == FT_Length2D:
00791             return aFilterMgr.CreateLength2D()
00792         else:
00793             print "Error: given parameter is not numerical functor type."

Here is the call graph for this function:

def smeshDC.Mesh.GetIdsFromFilter (   self,
  theFilter 
)

Passes mesh elements through the given filter and return IDs of fitting elements.

Parameters:
theFilterSMESH_Filter
Returns:
a list of ids

Definition at line 1613 of file smeshDC.py.

01613 
01614     def GetIdsFromFilter(self, theFilter):
01615         theFilter.SetMesh( self.mesh )
01616         return theFilter.GetIDs()