# TopAbs_State enumeration
[TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
+# Methods of splitting a hexahedron into tetrahedra
+Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
+
## Converts an angle from degrees to radians
def DegreesToRadians(AngleInDegrees):
def Concatenate( self, meshes, uniteIdenticalGroups,
mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
+ for i,m in enumerate(meshes):
+ if isinstance(m, Mesh):
+ meshes[i] = m.GetMesh()
if allGroups:
aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
else:
print "Error: The treshold should be a string."
return None
+ elif CritType == FT_CoplanarFaces:
+ # Checks the treshold
+ if isinstance(aTreshold, int):
+ aCriterion.ThresholdID = "%s"%aTreshold
+ elif isinstance(aTreshold, str):
+ ID = int(aTreshold)
+ if ID < 1:
+ raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
+ aCriterion.ThresholdID = aTreshold
+ else:
+ raise ValueError,\
+ "The treshold should be an ID of mesh face and not '%s'"%aTreshold
elif CritType == FT_ElemGeomType:
# Checks the treshold
try:
aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
aFilterMgr = self.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
+ aFilter.SetMesh( self.mesh )
aCriteria = []
aCriteria.append(aCriterion)
aFilter.SetCriteria(aCriteria)
def MakeGroupByCriterion(self, groupName, Criterion):
aFilterMgr = self.smeshpyD.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
+ aFilter.SetMesh( self.mesh )
aCriteria = []
aCriteria.append(Criterion)
aFilter.SetCriteria(aCriteria)
def MakeGroupByCriteria(self, groupName, theCriteria):
aFilterMgr = self.smeshpyD.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
+ aFilter.SetMesh( self.mesh )
aFilter.SetCriteria(theCriteria)
group = self.MakeGroupByFilter(groupName, aFilter)
return group
# @return SMESH_Group
# @ingroup l2_grps_create
def MakeGroupByFilter(self, groupName, theFilter):
- anIds = theFilter.GetElementsId(self.mesh)
- anElemType = theFilter.GetElementType()
- group = self.MakeGroupByIds(groupName, anElemType, anIds)
+ group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
+ group.AddFrom( theFilter )
return group
## Passes mesh elements through the given filter and return IDs of fitting elements
# @return a list of ids
# @ingroup l1_controls
def GetIdsFromFilter(self, theFilter):
- return theFilter.GetElementsId(self.mesh)
+ return theFilter.GetIDs()
## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
# Returns a list of special structures (borders).
## Splits volumic elements into tetrahedrons
# @param elemIDs either list of elements or mesh or group or submesh
- # @param method flags passing splitting method:
- # 1 - split the hexahedron into 5 tetrahedrons
- # 2 - split the hexahedron into 6 tetrahedrons
+ # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
+ # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
# @ingroup l2_modif_cutquadr
- def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
+ def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
if isinstance( elemIDs, Mesh ):
elemIDs = elemIDs.GetMesh()
+ if ( isinstance( elemIDs, list )):
+ elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
self.editor.SplitVolumesIntoTetra(elemIDs, method)
## Splits quadrangle faces near triangular facets of volumes
# @ingroup l2_modif_edit
def Make2DMeshFrom3D(self):
return self.editor. Make2DMeshFrom3D()
-
+
+ ## Creates missing boundary elements
+ # @param elements - elements whose boundary is to be checked:
+ # mesh, group, sub-mesh or list of elements
+ # @param dimension - defines type of boundary elements to create:
+ # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
+ # @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 toCopyExistingBondary - if true, not only new but also pre-existing
+ # 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="",
+ toCopyElements=False, toCopyExistingBondary=False):
+ if isinstance( elements, Mesh ):
+ elements = elements.GetMesh()
+ if ( isinstance( elements, list )):
+ elemType = SMESH.ALL
+ if elements: elemType = self.GetElementType( elements[0], iselem=True)
+ elements = self.editor.MakeIDSource(elements, elemType)
+ mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
+ toCopyElements,toCopyExistingBondary)
+ if mesh: mesh = self.smeshpyD.Mesh(mesh)
+ return mesh, group
+
## Renumber mesh nodes
# @ingroup l2_modif_renumber
def RenumberNodes(self):
if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
if ( isinstance( theObject, list )):
- theObject = self.editor.MakeIDSource(theObject)
+ theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
thePoint, Parameters = ParsePointStruct(thePoint)
self.mesh.SetParameters(Parameters)
if (isinstance(theObject, Mesh)):
theObject = theObject.GetMesh()
if ( isinstance( theObject, list )):
- theObject = self.editor.MakeIDSource(theObject)
+ theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
MakeGroups, NewMeshName)
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)
+ if not isinstance( exceptNodes, list):
+ exceptNodes = [ exceptNodes ]
+ if exceptNodes and isinstance( exceptNodes[0], int):
+ exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
+ return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
## Merges nodes
# @param GroupsOfNodes the list of groups of nodes