Filters allow picking only the mesh elements satisfying to a specific condition or a set of conditions. Filters can be used to create or edit mesh groups, remove elements from the mesh, control mesh quality by different parameters, etc.
Several filtering criteria can be combined together by using logical operators AND and OR. In addition, a filtering criterion can be reverted using logical operator NOT.
Mesh filters can use the functionality of mesh quality controls to filter mesh nodes / elements by a specific characteristic (Area, Length, etc).
This page provides a short description of the existing mesh filters, describes required parameters and gives simple examples of usage in Python scripts.
- See Also
- Quality Controls
Aspect ratio
filters 2D mesh elements (faces) according to the aspect ratio value:
- element type should be SMESH.FACE
- functor type should be SMESH.FT_AspectRatio
- threshold is floating point value (aspect ratio)
5 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of faces with aspect ratio > 2.5:", len(ids)
13 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio,
'>', 1.5, mesh=mesh)
15 print "Number of faces with aspect ratio > 1.5:", len(ids)
19 filter.SetMesh( mesh.GetMesh() )
20 mesh2 = smesh.CopyMesh( filter,
"AR > 1.5" )
21 print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
24 group = mesh.MakeGroup(
"AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio,
'<', 1.5)
25 print "Number of faces with aspect ratio < 1.5:", group.Size()
29 crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio,
'<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
30 smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,
'=', SMESH.Geom_TRIANGLE ) ]
31 triaGroup = mesh.MakeGroupByCriteria(
"Tria AR < 1.5", crit )
32 print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
35 aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
36 print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
39 grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
40 print "GROUP: Max aspect = %s" % grAspects[1]
43 aspect = mesh.FunctorValue( SMESH.FT_AspectRatio, ids[0] )
44 print "Aspect ratio of the face %s = %s" % ( ids[0], aspect )
Download this script
- See Also
- Aspect Ratio
Aspect ratio 3D
filters 3D mesh elements (volumes) according to the aspect ratio value:
- element type is SMESH.VOLUME
- functor type is SMESH.FT_AspectRatio3D
- threshold is floating point value (aspect ratio)
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of volumes with aspect ratio < 2.0:", len(ids)
Download this script
- See Also
- Aspect Ratio 3D
Warping angle
filters 2D mesh elements (faces) according to the warping angle value:
- element type is SMESH.FACE
- functor type is SMESH.FT_Warping
- threshold is floating point value (warping angle)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping,
"=", 2.0e-13, Tolerance=5.0e-14)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)
Download this script
- See Also
- Warping
Minimum angle
filters 2D mesh elements (faces) according to the minimum angle value:
- element type is SMESH.FACE
- functor type is SMESH.FT_MinimumAngle
- threshold is floating point value (minimum angle)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,
">", 75)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with minimum angle > 75:", len(ids)
Download this script
- See Also
- Minimum Angle
Taper
filters 2D mesh elements (faces) according to the taper value:
- element type is SMESH.FACE
- functor type is SMESH.FT_Taper
- threshold is floating point value (taper)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with taper < 1.e-15:", len(ids)
Download this script
- See Also
- Taper
Skew
filters 2D mesh elements (faces) according to the skew value:
- element type is SMESH.FACE
- functor type is SMESH.FT_Skew
- threshold is floating point value (skew)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with skew > 50:", len(ids)
Download this script
- See Also
- Skew
Area
filters 2D mesh elements (faces) according to the area value:
- element type is SMESH.FACE
- functor type is SMESH.FT_Area
- threshold is floating point value (area)
4 from SMESH_mechanic
import *
6 criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60)
7 criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90)
8 filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of faces with area in range (60,90):", len(ids)
Download this script
- See Also
- Area
Volume
filters 3D mesh elements (volumes) according to the volume value:
- element type is SMESH.VOLUME
- functor type is SMESH.FT_Volume3D
- threshold is floating point value (volume)
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of volumes with volume > 100:", len(ids)
Download this script
- See Also
- Volume
Free borders
filters 1D mesh elements (edges) which represent free borders of a mesh:
- element type is SMESH.EDGE
- functor type is SMESH.FT_FreeBorders
- threshold value is not required
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 from salome.smesh
import smeshBuilder
9 smesh = smeshBuilder.New(salome.myStudy)
12 face = geompy.MakeFaceHW(100, 100, 1, theName=
"quadrangle")
13 mesh = smesh.Mesh(face)
19 filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
20 ids = mesh.GetIdsFromFilter(filter)
21 print "Number of edges on free borders:", len(ids)
Download this script
- See Also
- Free Borders
Free edges
filters 2D mesh elements (faces) having edges (i.e. links between nodes, not mesh segments) belonging to one face of mesh only:
- element type is SMESH.FACE
- functor type is SMESH.FT_FreeEdges
- threshold value is not required
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 from salome.smesh
import smeshBuilder
9 smesh = smeshBuilder.New(salome.myStudy)
12 face = geompy.MakeFaceHW(100, 100, 1)
13 geompy.addToStudy( face,
"quadrangle" )
14 mesh = smesh.Mesh(face)
20 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges)
21 ids = mesh.GetIdsFromFilter(filter)
22 print "Number of faces with free edges:", len(ids)
Download this script
- See Also
- Free Edges
Free nodes
filters free nodes:
- element type is SMESH.NODE
- functor type is SMESH.FT_FreeNodes
- threshold value is not required
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of free nodes:", len(ids)
Download this script
- See Also
- Free Nodes
Free faces
filters free faces:
- element type is SMESH.FACE
- functor type is SMESH.FT_FreeFaces
- threshold value is not required
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of free faces:", len(ids)
Download this script
- See Also
- Free Faces
Bare border faces
filters faces with bare borders:
- element type is SMESH.FACE
- functor type is SMESH.FT_BareBorderFace
- threshold value is not required
4 from SMESH_mechanic
import *
6 mesh.RemoveElements( mesh.GetElementsByType(SMESH.FACE)[0:5] )
8 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Faces with bare borders:", ids
Download this script
- See Also
- Bare border faces
Coplanar faces
filters coplanar faces:
- element type is SMESH.FACE
- functor type is SMESH.FT_CoplanarFaces
- threshold value is the face ID
- tolerance is in degrees
4 from SMESH_mechanic
import *
5 faceID = mesh.GetElementsByType(SMESH.FACE)[0]
7 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0)
8 ids = mesh.GetIdsFromFilter(filter)
9 print "Number of faces coplanar with the first one:", len(ids)
Download this script
Over-constrained faces
filters over-constrained faces:
- element type is SMESH.FACE
- functor type is SMESH.FT_OverConstrainedFace
- threshold value is not required
3 from SMESH_mechanic
import *
5 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace)
6 ids = mesh.GetIdsFromFilter(filter)
7 print "Over-constrained faces:", ids
Download this script
- See Also
- Over-constrained faces
Double edges, Double faces, Double volumes
filters mesh elements basing on the same set of nodes:
- element type is either SMESH.EGDE, SMESH.FACE or SMESH.VOLUME
- functor type is either SMESH.FT_EqualEdges, SMESH.FT_EqualFaces or SMESH.FT_EqualVolumes,
- threshold value is not required
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
16 box = geompy.MakeBoxDXDYDZ(100,100,100)
17 mesh = smesh.Mesh( box,
"Box" )
23 mesh.TranslateObject( mesh, smesh.MakeDirStruct( 10,0,0), Copy=
True )
24 mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
26 equalEdgesFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges)
27 equalFacesFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces)
28 equalVolumesFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes)
30 print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))
31 print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))
32 print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter ))
Download this script
Double nodes
filters mesh nodes which are coincident with other nodes (within a given tolerance):
- element type is SMESH.NODE
- functor type is SMESH.FT_EqualNodes
- threshold value is not required
- default tolerance is 1.0e-7
5 from salome.geom
import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
8 from salome.smesh
import smeshBuilder
9 smesh = smeshBuilder.New(salome.myStudy)
12 box = geompy.MakeBoxDXDYDZ(100,100,100)
13 mesh = smesh.Mesh( box,
"Box" )
19 mesh.TranslateObject( mesh, [10,0,0], Copy=
True )
21 filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5)
23 print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
Download this script
Node connectivity number
filters nodes according to a number of elements of highest dimension connected to a node:
- element type should be SMESH.NODE
- functor type should be SMESH.FT_NodeConnectivityNumber
- threshold is an integer value (number of elements)
4 from SMESH_mechanic
import *
7 conn_nb_filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,
'>', 6 )
8 ids = mesh.GetIdsFromFilter( conn_nb_filter )
9 print "Number of nodes connected to more than 6 tetrahedra:", len(ids)
Download this script
Borders at multi-connection
filters 1D mesh elements (segments) according to the specified number of connections (faces and volumes on whose border the segment lies):
- element type is SMESH.EDGE
- functor type is SMESH.FT_MultiConnection
- threshold is integer value (number of connections)
5 from salome.geom
import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
8 from salome.smesh
import smeshBuilder
9 smesh = smeshBuilder.New(salome.myStudy)
12 box = geompy.MakeBoxDXDYDZ(100,100,100)
13 mesh = smesh.Mesh( box,
"Box" )
19 mesh.TranslateObject( mesh, [10,0,0], Copy=
True )
20 mesh.MergeNodes( mesh.FindCoincidentNodes( 1e-5 ))
23 filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3)
24 ids = mesh.GetIdsFromFilter(filter)
25 print "Number of border edges with 3 faces connected:", len(ids)
Download this script
- See Also
- Borders at Multiconnection
Borders at multi-connection 2D
filters 2D mesh elements (faces) with the specified maximal number of faces connected to a border (link between nodes, not mesh segment):
- element type is SMESH.FACE
- functor type is SMESH.FT_MultiConnection2D
- threshold is integer value (number of connections)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces consisting of edges belonging to 2 faces:", len(ids)
Download this script
- See Also
- Borders at Multiconnection 2D
Length
filters 1D mesh elements (edges) according to the edge length value:
- element type should be SMESH.EDGE
- functor type should be SMESH.FT_Length
- threshold is floating point value (length)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of edges with length > 14:", len(ids)
Download this script
- See Also
- Length 1D
Length 2D
filters 2D mesh elements (faces) according to the maximum length of its edges (links between nodes):
- element type should be SMESH.FACE
- functor type should be SMESH.FT_Length2D
- threshold is floating point value (edge length)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, 14)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with maximum edge length > 14:", len(ids)
Download this script
- See Also
- Length 2D
Element Diameter 2D
filters 2D mesh elements (faces) according to the maximum length of its edges and diagonals:
- element type should be SMESH.FACE
- functor type should be SMESH.FT_MaxElementLength2D
- threshold is floating point value (length)
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces with maximum element length > 10:", len(ids)
Download this script
- See Also
- Element Diameter 2D
Element Diameter 3D
filters 3D mesh elements (volumes) according to the maximum length of its edges and diagonals:
- element type should be SMESH.VOLUME
- functor type should be SMESH.FT_MaxElementLength3D
- threshold is floating point value (edge/diagonal length)
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of volumes with maximum element length > 10:", len(ids)
Download this script
- See Also
- Element Diameter 3D
Bare border volumes
filters 3D mesh elements with bare borders, i.e. having a facet not shared with other volumes and without a face on it:
- element type is SMESH.VOLUME
- functor type is SMESH.FT_BareBorderVolume
- threshold value is not required
4 from SMESH_mechanic
import *
8 mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] )
10 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume)
11 ids = mesh.GetIdsFromFilter(filter)
12 print "Volumes with bare borders:", ids
Download this script
- See Also
- Bare border volumes
Over-constrained volumes
filters over-constrained volumes, whose all nodes are on the mesh boundary:
- element type is SMESH.VOLUME
- functor type is SMESH.FT_OverConstrainedVolume
- threshold value is not required
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Over-constrained volumes:", ids
Download this script
- See Also
- Over-constrained faces
Belong to Mesh Group
filters mesh entities (nodes or elements) included in a mesh group defined by threshold value:
- element type can be any, from SMESH.NODE to SMESH.BALL
- functor type should be SMESH.FT_BelongToMeshGroup
- threshold is mesh group object
4 from SMESH_mechanic
import *
8 quads_on_face3 = mesh.MakeGroup(
"quads_on_face3", SMESH.FACE, SMESH.FT_BelongToGeom,
'=',sub_face3)
9 print "There are %s quadrangles generated on '%s' and included in the group '%s'" % ( quads_on_face3.Size(), sub_face3.GetName(), quads_on_face3.GetName() )
14 not_on_face3 = smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,
'=',quads_on_face3, SMESH.FT_LogicalNOT )
15 quadrangles = smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,
'=',SMESH.Geom_QUADRANGLE )
17 rest_quads = mesh.MakeGroupByCriteria(
"rest_quads", [ not_on_face3, quadrangles ])
18 print "'%s' group includes all the rest %s quadrangles" % ( rest_quads.GetName(), rest_quads.Size() )
Download this script
Belong to Geom
filters mesh entities (nodes or elements) which all nodes lie on the shape defined by threshold value:
- element type can be any, from SMESH.NODE to SMESH.BALL
- functor type should be SMESH.FT_BelongToGeom
- threshold is geometrical object
- tolerance is a distance between a node and the geometrical object; it is used if an node is not associated to any geometry.
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces which nodes lie on sub_face3:", len(ids)
Download this script
Lying on Geom
filters mesh entities (nodes or elements) at least one node of which lies on the shape defined by threshold value:
- element type can be any, from SMESH.NODE to SMESH.BALL
- functor type should be SMESH.FT_LyingOnGeom
- threshold is geometrical object
- tolerance is a distance between a node and the geometrical object; it is used if an node is not associated to any geometry.
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces at least one node of each lies on sub_face3:", len(ids)
Download this script
Belong to Plane
filters mesh entities (nodes or elements) which all nodes belong to the plane defined by threshold value with the given tolerance:
- element type can be any except SMESH.VOLUME
- functor type should be SMESH.FT_BelongToPlane
- threshold is geometrical object (plane)
- default tolerance is 1.0e-7
4 from SMESH_mechanic
import *
6 plane_1 = geompy.MakePlane(p3,seg1,2000)
7 geompy.addToStudy(plane_1,
"plane_1")
9 filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1)
10 ids = mesh.GetIdsFromFilter(filter)
11 print "Number of nodes which lie on the plane plane_1:", len(ids)
Download this script
Belong to Cylinder
filters mesh entities (nodes or elements) which all nodes belong to the cylindrical face defined by threshold value with the given tolerance:
- element type can be any except SMESH.VOLUME
- functor type should be SMESH.FT_BelongToCylinder
- threshold is geometrical object (cylindrical face)
- default tolerance is 1.0e-7
4 from SMESH_mechanic
import *
6 filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1)
7 ids = mesh.GetIdsFromFilter(filter)
8 print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids)
Download this script
Belong to Surface
filters mesh entities (nodes or elements) which all nodes belong to the arbitrary surface defined by threshold value with the given tolerance:
- element type can be any except SMESH.VOLUME
- functor type should be SMESH.FT_BelongToGenSurface
- threshold is geometrical object (arbitrary surface)
- default tolerance is 1.0e-7
4 from SMESH_mechanic
import *
6 spline_1 = geompy.MakeInterpol([p4,p6,p3,p1])
7 surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 )
8 geompy.addToStudy(surface_1,
"surface_1")
10 filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1)
11 ids = mesh.GetIdsFromFilter(filter)
12 print "Number of nodes which lie on the surface surface_1:", len(ids)
Download this script
Range of IDs
filters mesh entities elements (nodes or elements) according to the specified identifiers range:
- element type can be any, from SMESH.NODE to SMESH.BALL
- functor type is SMESH.FT_RangeOfIds
- threshold is string listing required IDs and/or ranges of IDs, e.g."1,2,3,50-60,63,67,70-78"
4 from SMESH_mechanic
import *
6 criterion1 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold=
"5-10",\
7 BinaryOp=SMESH.FT_LogicalOR)
8 criterion2 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold=
"15-30")
9 filter = smesh.CreateFilterManager().CreateFilter()
10 filter.SetCriteria([criterion1,criterion2])
11 ids = mesh.GetIdsFromFilter(filter)
12 print "Number of nodes in ranges [5-10] and [15-30]:", len(ids)
Download this script
Badly oriented volume
filters 3D mesh elements (volumes), which are incorrectly oriented from the point of view of MED convention.
- element type should be SMESH.VOLUME
- functor type is SMESH.FT_BadOrientedVolume
- threshold is not required
4 from SMESH_mechanic
import *
8 filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume)
9 ids = mesh.GetIdsFromFilter(filter)
10 print "Number of badly oriented volumes:", len(ids)
Download this script
Linear / quadratic
filters linear / quadratic mesh elements:
- element type should be either SMESH.EDGE, SMESH.FACE or SMESH.VOLUME
- functor type is SMESH.FT_LinearOrQuadratic
- threshold is not required
- if unary operator is set to SMESH.FT_LogicalNOT, the quadratic elements are selected, otherwise (by default) linear elements are selected
4 from SMESH_mechanic
import *
7 filter_linear = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic)
8 filter_quadratic = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT)
9 ids_linear = mesh.GetIdsFromFilter(filter_linear)
10 ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
11 print "Number of linear edges:", len(ids_linear),
"; number of quadratic edges:", len(ids_quadratic)
14 print "Convert to quadratic..."
15 mesh.ConvertToQuadratic()
18 ids_linear = mesh.GetIdsFromFilter(filter_linear)
19 ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
20 print "Number of linear edges:", len(ids_linear),
"; number of quadratic edges:", len(ids_quadratic)
Download this script
Group color
filters mesh entities, belonging to the group with the color defined by the threshold value.
- element type can be any, from SMESH.NODE to SMESH.BALL
- functor type is SMESH.FT_GroupColor
- threshold should be of SALOMEDS.Color type
4 from SMESH_mechanic
import *
6 all_edges = mesh.GetElementsByType(SMESH.EDGE)
7 grp = mesh.MakeGroupByIds(
"edges group", SMESH.EDGE, all_edges[:len(all_edges)/4])
9 c = SALOMEDS.Color(0.1, 0.5, 1.0)
12 filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT)
13 ids = mesh.GetIdsFromFilter(filter)
14 print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids)
Download this script
Geometry type
filters mesh elements by the geometric type defined with the threshold value. The list of available geometric types depends on the element entity type.
- element type can be any, e.g.: SMESH.EDGE, SMESH.FACE, SMESH.VOLUME, etc.
- functor type should be SMESH.FT_ElemGeomType
- threshold is either of smesh.GeometryType values. Type SMESH.GeometryType._items in the Python Console to see all geometric types.
4 from SMESH_mechanic
import *
8 filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_TRIANGLE)
9 filter_qua = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE)
10 filter_tet = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_TETRA)
11 filter_pyr = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_PYRAMID)
12 ids_tri = mesh.GetIdsFromFilter(filter_tri)
13 ids_qua = mesh.GetIdsFromFilter(filter_qua)
14 ids_tet = mesh.GetIdsFromFilter(filter_tet)
15 ids_pyr = mesh.GetIdsFromFilter(filter_pyr)
16 print "Number of triangles:", len(ids_tri)
17 print "Number of quadrangles:", len(ids_qua)
18 print "Number of tetrahedrons:", len(ids_tet)
19 print "Number of pyramids:", len(ids_pyr)
Download this script
Entity type
filters mesh elements by the geometric type and number of nodes.
- element type can be any, e.g.: SMESH.EDGE, SMESH.FACE, SMESH.VOLUME, etc.
- functor type should be SMESH.FT_EntityType
- threshold is either of SMESH.EntityType values. Type SMESH.EntityType._items in the Python Console to see all entity types.
4 from SMESH_mechanic
import *
7 mesh.ConvertToQuadratic()
9 for face
in SubFaceL[: len(SubFaceL)/2]:
10 mesh.ConvertToQuadratic( theSubMesh=mesh.Group( face ), theToBiQuad=
True )
13 filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_EntityType,
'=', SMESH.Entity_BiQuad_Triangle )
14 ids_tri = mesh.GetIdsFromFilter(filter_tri)
15 print "Number of bi-quadratic triangles:", len(ids_tri)
Download this script
Ball diameter
filters ball elements by diameter.
- element type should be SMESH.BALL
- functor type should be SMESH.FT_BallDiameter
- threshold is floating point value (ball diameter)
4 from SMESH_mechanic
import *
9 mesh.AddBall( i, diameter )
13 diam_filter = smesh.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,
'>', 5. )
14 ids = mesh.GetIdsFromFilter( diam_filter )
15 print "Number of balls with diameter > 5:", len(ids)
Download this script
Elements of a domain
filters elements of a specified domain.
- element type can be any, e.g.: SMESH.EDGE, SMESH.FACE, SMESH.VOLUME, etc.
- functor type should be SMESH.FT_ConnectedElements
- threshold is either (1) node ID or (2) geometrical vertex or (3) 3 coordinates of a point.
5 from salome.geom
import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
7 from salome.smesh
import smeshBuilder
8 smesh = smeshBuilder.New(salome.myStudy)
12 box1 = geompy.MakeBoxDXDYDZ( 100,100,100 )
13 box2 = geompy.MakeTranslation( box1, 200, 0, 0 )
14 boxes = geompy.MakeCompound( [box1, box2] )
15 box1, box2 = geompy.SubShapeAll( boxes, geompy.ShapeType[
"SHAPE"],
"box")
17 vertex = geompy.SubShape( box1, geompy.ShapeType[
"VERTEX"], [1] )
21 mesh = smesh.Mesh( boxes )
31 nodeFilter = smesh.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements,
"=",
"1.,2,10", mesh=mesh )
32 print "Nb. nodes in box_1:", len( nodeFilter.GetIDs())
35 edgeFilter = smesh.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements,
"=", [202,1,1 ], mesh=mesh )
36 print "Nb. segments in box_2:", len( edgeFilter.GetIDs())
39 faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements,
"=", vertex, mesh=mesh )
40 print "Nb. faces in box_1:", len( edgeFilter.GetIDs())
43 voluFilter = smesh.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements,
"=", 10, mesh=mesh )
44 print "Nb. volumes in box_2:", len( voluFilter.GetIDs())
Download this script
How to combine several criteria into a filter?
Several criteria can be combined into a filter.
Example :
4 from SMESH_mechanic
import *
7 criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND)
9 criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT)
11 quadFilter = smesh.GetFilterFromCriteria([criterion1,criterion2])
14 ids = mesh.GetIdsFromFilter(quadFilter)
17 myGroup = mesh.GroupOnFilter(SMESH.FACE,
"Quads_on_cylindrical_faces",quadFilter)
Download this script