mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-30 00:50:32 +05:00
Add several methods.
This commit is contained in:
parent
2d1ed8ae65
commit
5c2e18f329
@ -160,6 +160,11 @@ def CreateMeshesFromSTL( theFileName ):
|
|||||||
def GetSubShapesId( theMainObject, theListOfSubObjects ):
|
def GetSubShapesId( theMainObject, theListOfSubObjects ):
|
||||||
return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
|
return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
|
||||||
|
|
||||||
|
## From SMESH_Gen interface. Creates pattern
|
||||||
|
def GetPattern():
|
||||||
|
return smesh.GetPattern()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Filtering. Auxiliary functions:
|
## Filtering. Auxiliary functions:
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
@ -251,7 +256,61 @@ def GetCriterion(elementType,
|
|||||||
aCriterion.BinaryOp = EnumToLong(BinaryOp)
|
aCriterion.BinaryOp = EnumToLong(BinaryOp)
|
||||||
|
|
||||||
return aCriterion
|
return aCriterion
|
||||||
|
|
||||||
|
## Creates filter by given parameters of criterion
|
||||||
|
# @param elementType is the type of elements in the group
|
||||||
|
# @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
|
||||||
|
# @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
|
||||||
|
# @param Treshold is threshold value (range of id ids as string, shape, numeric)
|
||||||
|
# @param UnaryOp is FT_LogicalNOT or FT_Undefined
|
||||||
|
# @return SMESH_Filter
|
||||||
|
def GetFilter(elementType,
|
||||||
|
CritType=FT_Undefined,
|
||||||
|
Compare=FT_EqualTo,
|
||||||
|
Treshold="",
|
||||||
|
UnaryOp=FT_Undefined):
|
||||||
|
aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
|
||||||
|
aFilterMgr = smesh.CreateFilterManager()
|
||||||
|
aFilter = aFilterMgr.CreateFilter()
|
||||||
|
aCriteria = []
|
||||||
|
aCriteria.append(aCriterion)
|
||||||
|
aFilter.SetCriteria(aCriteria)
|
||||||
|
return aFilter
|
||||||
|
|
||||||
|
## Creates numerical functor by its type
|
||||||
|
# @param theCrierion is FT_...; functor type
|
||||||
|
# @return SMESH_NumericalFunctor
|
||||||
|
def GetFunctor(theCriterion):
|
||||||
|
aFilterMgr = smesh.CreateFilterManager()
|
||||||
|
if theCriterion == FT_AspectRatio:
|
||||||
|
return aFilterMgr.CreateAspectRatio()
|
||||||
|
elif theCriterion == FT_AspectRatio3D:
|
||||||
|
return aFilterMgr.CreateAspectRatio3D()
|
||||||
|
elif theCriterion == FT_Warping:
|
||||||
|
return aFilterMgr.CreateWarping()
|
||||||
|
elif theCriterion == FT_MinimumAngle:
|
||||||
|
return aFilterMgr.CreateMinimumAngle()
|
||||||
|
elif theCriterion == FT_Taper:
|
||||||
|
return aFilterMgr.CreateTaper()
|
||||||
|
elif theCriterion == FT_Skew:
|
||||||
|
return aFilterMgr.CreateSkew()
|
||||||
|
elif theCriterion == FT_Area:
|
||||||
|
return aFilterMgr.CreateArea()
|
||||||
|
elif theCriterion == FT_Volume3D:
|
||||||
|
return aFilterMgr.CreateVolume3D()
|
||||||
|
elif theCriterion == FT_MultiConnection:
|
||||||
|
return aFilterMgr.CreateMultiConnection()
|
||||||
|
elif theCriterion == FT_MultiConnection2D:
|
||||||
|
return aFilterMgr.CreateMultiConnection2D()
|
||||||
|
elif theCriterion == FT_Length:
|
||||||
|
return aFilterMgr.CreateLength()
|
||||||
|
elif theCriterion == FT_Length2D:
|
||||||
|
return aFilterMgr.CreateLength2D()
|
||||||
|
else:
|
||||||
|
print "Error: given parameter is not numerucal functor type."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Mother class to define algorithm, recommended to don't use directly.
|
## Mother class to define algorithm, recommended to don't use directly.
|
||||||
#
|
#
|
||||||
@ -363,7 +422,8 @@ class Mesh_Algorithm:
|
|||||||
status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
|
status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
|
||||||
self.TreatHypoStatus( status, hyp, name, 0 )
|
self.TreatHypoStatus( status, hyp, name, 0 )
|
||||||
return hypo
|
return hypo
|
||||||
|
|
||||||
|
|
||||||
# Public class: Mesh_Segment
|
# Public class: Mesh_Segment
|
||||||
# --------------------------
|
# --------------------------
|
||||||
|
|
||||||
@ -1130,27 +1190,22 @@ class Mesh:
|
|||||||
group = self.MakeGroupByIds(groupName, anElemType, anIds)
|
group = self.MakeGroupByIds(groupName, anElemType, anIds)
|
||||||
return group
|
return group
|
||||||
|
|
||||||
## Creates filter by given parameters of criterion
|
## Pass mesh elements through the given filter and return ids
|
||||||
# @param elementType is the type of elements in the group
|
# @param theFilter is SMESH_Filter
|
||||||
# @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
|
# @return list of ids
|
||||||
# @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
|
def GetIdsFromFilter(self, theFilter):
|
||||||
# @param Treshold is threshold value (range of id ids as string, shape, numeric)
|
return theFilter.GetElementsId(self.mesh)
|
||||||
# @param UnaryOp is FT_LogicalNOT or FT_Undefined
|
|
||||||
# @return SMESH_Filter
|
## Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
|
||||||
def GetFilter(self,
|
# Returns list of special structures(borders).
|
||||||
elementType,
|
# @return list of SMESH.FreeEdges.Border structure: edge id and two its nodes ids.
|
||||||
CritType=FT_Undefined,
|
def GetFreeBorders(self):
|
||||||
Compare=FT_EqualTo,
|
|
||||||
Treshold="",
|
|
||||||
UnaryOp=FT_Undefined):
|
|
||||||
aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
|
|
||||||
aFilterMgr = smesh.CreateFilterManager()
|
aFilterMgr = smesh.CreateFilterManager()
|
||||||
aFilter = aFilterMgr.CreateFilter()
|
aPredicate = aFilterMgr.CreateFreeEdges()
|
||||||
aCriteria = []
|
aPredicate.SetMesh(self.mesh)
|
||||||
aCriteria.append(aCriterion)
|
aBorders = aPredicate.GetBorders()
|
||||||
aFilter.SetCriteria(aCriteria)
|
return aBorders
|
||||||
return aFilter
|
|
||||||
|
|
||||||
## Remove a group
|
## Remove a group
|
||||||
def RemoveGroup(self, group):
|
def RemoveGroup(self, group):
|
||||||
self.mesh.RemoveGroup(group)
|
self.mesh.RemoveGroup(group)
|
||||||
@ -1396,13 +1451,18 @@ class Mesh:
|
|||||||
# If there is not node for given ID - returns empty list
|
# If there is not node for given ID - returns empty list
|
||||||
def GetNodeInverseElements(self, id):
|
def GetNodeInverseElements(self, id):
|
||||||
return self.mesh.GetNodeInverseElements(id)
|
return self.mesh.GetNodeInverseElements(id)
|
||||||
|
|
||||||
## If given element is node returns IDs of shape from position
|
## If given element is node returns IDs of shape from position
|
||||||
# else - return ID of result shape after Mesh.FindShape()
|
# If there is not node for given ID - returns -1
|
||||||
# If there is not element for given ID - returns -1
|
|
||||||
def GetShapeID(self, id):
|
def GetShapeID(self, id):
|
||||||
return self.mesh.GetShapeID(id)
|
return self.mesh.GetShapeID(id)
|
||||||
|
|
||||||
|
## For given element returns ID of result shape after
|
||||||
|
# FindShape() from SMESH_MeshEditor
|
||||||
|
# If there is not element for given ID - returns -1
|
||||||
|
def GetShapeIDForElem(id):
|
||||||
|
return self.mesh.GetShapeIDForElem(id)
|
||||||
|
|
||||||
## Returns number of nodes for given element
|
## Returns number of nodes for given element
|
||||||
# If there is not element for given ID - returns -1
|
# If there is not element for given ID - returns -1
|
||||||
def GetElemNbNodes(self, id):
|
def GetElemNbNodes(self, id):
|
||||||
@ -1549,37 +1609,38 @@ class Mesh:
|
|||||||
|
|
||||||
## Fuse neighbour triangles into quadrangles.
|
## Fuse neighbour triangles into quadrangles.
|
||||||
# @param IDsOfElements The triangles to be fused,
|
# @param IDsOfElements The triangles to be fused,
|
||||||
# @param Criterion is used to choose a neighbour to fuse with.
|
# @param theCriterion is FT_...; used to choose a neighbour to fuse with.
|
||||||
# @param MaxAngle is a max angle between element normals at which fusion
|
# @param MaxAngle is a max angle between element normals at which fusion
|
||||||
# is still performed; theMaxAngle is mesured in radians.
|
# is still performed; theMaxAngle is mesured in radians.
|
||||||
# @return TRUE in case of success, FALSE otherwise.
|
# @return TRUE in case of success, FALSE otherwise.
|
||||||
def TriToQuad(self, IDsOfElements, Criterion, MaxAngle):
|
def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
|
||||||
if IDsOfElements == []:
|
if IDsOfElements == []:
|
||||||
IDsOfElements = self.GetElementsId()
|
IDsOfElements = self.GetElementsId()
|
||||||
return self.editor.TriToQuad(IDsOfElements, Criterion, MaxAngle)
|
return self.editor.TriToQuad(IDsOfElements, GetFunctor(theCriterion), MaxAngle)
|
||||||
|
|
||||||
## Fuse neighbour triangles of the object into quadrangles
|
## Fuse neighbour triangles of the object into quadrangles
|
||||||
# @param theObject is mesh, submesh or group
|
# @param theObject is mesh, submesh or group
|
||||||
# @param Criterion is used to choose a neighbour to fuse with.
|
# @param theCriterion is FT_...; used to choose a neighbour to fuse with.
|
||||||
# @param MaxAngle is a max angle between element normals at which fusion
|
# @param MaxAngle is a max angle between element normals at which fusion
|
||||||
# is still performed; theMaxAngle is mesured in radians.
|
# is still performed; theMaxAngle is mesured in radians.
|
||||||
# @return TRUE in case of success, FALSE otherwise.
|
# @return TRUE in case of success, FALSE otherwise.
|
||||||
def TriToQuadObject (self, theObject, Criterion, MaxAngle):
|
def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
|
||||||
return self.editor.TriToQuadObject(theObject, Criterion, MaxAngle)
|
return self.editor.TriToQuadObject(theObject, GetFunctor(theCriterion), MaxAngle)
|
||||||
|
|
||||||
## Split quadrangles into triangles.
|
## Split quadrangles into triangles.
|
||||||
# @param IDsOfElements the faces to be splitted.
|
# @param IDsOfElements the faces to be splitted.
|
||||||
# @param theCriterion is used to choose a diagonal for splitting.
|
# @param theCriterion is FT_...; used to choose a diagonal for splitting.
|
||||||
# @param @return TRUE in case of success, FALSE otherwise.
|
# @param @return TRUE in case of success, FALSE otherwise.
|
||||||
def QuadToTri (self, IDsOfElements, Criterion):
|
def QuadToTri (self, IDsOfElements, theCriterion):
|
||||||
if IDsOfElements == []:
|
if IDsOfElements == []:
|
||||||
IDsOfElements = self.GetElementsId()
|
IDsOfElements = self.GetElementsId()
|
||||||
return self.editor.QuadToTri(IDsOfElements, Criterion)
|
return self.editor.QuadToTri(IDsOfElements, GetFunctor(theCriterion))
|
||||||
|
|
||||||
## Split quadrangles into triangles.
|
## Split quadrangles into triangles.
|
||||||
# @param theObject object to taking list of elements from, is mesh, submesh or group
|
# @param theObject object to taking list of elements from, is mesh, submesh or group
|
||||||
def QuadToTriObject (self, theObject, Criterion):
|
# @param theCriterion is FT_...; used to choose a diagonal for splitting.
|
||||||
return self.editor.QuadToTriObject(theObject, Criterion)
|
def QuadToTriObject (self, theObject, theCriterion):
|
||||||
|
return self.editor.QuadToTriObject(theObject, GetFunctor(theCriterion))
|
||||||
|
|
||||||
## Split quadrangles into triangles.
|
## Split quadrangles into triangles.
|
||||||
# @param theElems The faces to be splitted
|
# @param theElems The faces to be splitted
|
||||||
@ -1597,11 +1658,11 @@ class Mesh:
|
|||||||
|
|
||||||
## Find better splitting of the given quadrangle.
|
## Find better splitting of the given quadrangle.
|
||||||
# @param IDOfQuad ID of the quadrangle to be splitted.
|
# @param IDOfQuad ID of the quadrangle to be splitted.
|
||||||
# @param Criterion is a criterion to choose a diagonal for splitting.
|
# @param theCriterion is FT_...; a criterion to choose a diagonal for splitting.
|
||||||
# @return 1 if 1-3 diagonal is better, 2 if 2-4
|
# @return 1 if 1-3 diagonal is better, 2 if 2-4
|
||||||
# diagonal is better, 0 if error occurs.
|
# diagonal is better, 0 if error occurs.
|
||||||
def BestSplit (self, IDOfQuad, Criterion):
|
def BestSplit (self, IDOfQuad, theCriterion):
|
||||||
return self.editor.BestSplit(IDOfQuad, Criterion)
|
return self.editor.BestSplit(IDOfQuad, GetFunctor(theCriterion))
|
||||||
|
|
||||||
## Smooth elements
|
## Smooth elements
|
||||||
# @param IDsOfElements list if ids of elements to smooth
|
# @param IDsOfElements list if ids of elements to smooth
|
||||||
@ -1765,7 +1826,7 @@ class Mesh:
|
|||||||
IDsOfElements = self.GetElementsId()
|
IDsOfElements = self.GetElementsId()
|
||||||
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
|
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
|
||||||
RefPoint = GetPointStruct(RefPoint)
|
RefPoint = GetPointStruct(RefPoint)
|
||||||
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape, NodeStart,
|
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart,
|
||||||
HasAngles, Angles, HasRefPoint, RefPoint)
|
HasAngles, Angles, HasRefPoint, RefPoint)
|
||||||
|
|
||||||
## Generate new elements by extrusion of the elements belong to object
|
## Generate new elements by extrusion of the elements belong to object
|
||||||
@ -1783,7 +1844,7 @@ class Mesh:
|
|||||||
HasAngles, Angles, HasRefPoint, RefPoint):
|
HasAngles, Angles, HasRefPoint, RefPoint):
|
||||||
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
|
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
|
||||||
RefPoint = GetPointStruct(RefPoint)
|
RefPoint = GetPointStruct(RefPoint)
|
||||||
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape, NodeStart,
|
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart,
|
||||||
HasAngles, Angles, HasRefPoint, RefPoint)
|
HasAngles, Angles, HasRefPoint, RefPoint)
|
||||||
|
|
||||||
## Symmetrical copy of mesh elements
|
## Symmetrical copy of mesh elements
|
||||||
|
Loading…
Reference in New Issue
Block a user