3 \page tui_filters_page Filters usage
5 Filters allow picking only the mesh elements satisfying to a
6 specific condition or a set of conditions. Filters can be used to create
7 or edit mesh groups, remove elements from the mesh object, control
8 mesh quality by different parameters, etc.
10 Several filters can be combined together by using logical operators \a
11 AND and \a OR. In addition, applied filter criterion can be reverted
12 using logical operator \a NOT.
14 Mesh filters use the functionality of mesh quality controls to filter
15 mesh nodes / elements by a specific characteristic (Area, Length, etc).
17 This page provides a short description of the existing mesh filters,
18 describes required parameters and gives simple examples of usage in
21 \sa \ref tui_quality_controls_page
23 \section filter_aspect_ratio Aspect ratio
25 Filter 2D mesh elements (faces) according to the aspect ratio value:
26 - element type should be \a smesh.FACE
27 - functor type should be \a smesh.FT_AspectRatio
28 - threshold is floating point value (aspect ratio)
32 from SMESH_mechanic import *
33 # get faces with aspect ratio > 6.5
34 filter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 6.5)
35 ids = mesh.GetIdsFromFilter(filter)
36 print "Number of faces with aspect ratio > 6.5:", len(ids)
39 \sa \ref tui_aspect_ratio
41 \section filter_aspect_ratio_3d Aspect ratio 3D
43 Filter 3D mesh elements (volumes) according to the aspect ratio value:
44 - element type is \a smesh.VOLUME
45 - functor type is \a smesh.FT_AspectRatio3D
46 - threshold is floating point value (aspect ratio)
49 # create mesh with volumes
50 from SMESH_mechanic import *
53 # get volumes with aspect ratio < 2.0
54 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_LessThan, 2.0)
55 ids = mesh.GetIdsFromFilter(filter)
56 print "Number of volumes with aspect ratio < 2.0:", len(ids)
59 \sa \ref tui_aspect_ratio_3d
61 \section filter_warping_angle Warping angle
63 Filter 2D mesh elements (faces) according to the warping angle value:
64 - element type is \a smesh.FACE
65 - functor type is \a smesh.FT_Warping
66 - threshold is floating point value (warping angle)
70 from SMESH_mechanic import *
71 # get faces with warping angle = 2.0e-13 with tolerance 5.0e-14
72 criterion = smesh.GetCriterion(smesh.FACE, smesh.FT_Warping, smesh.FT_EqualTo, 2.0e-13)
73 criterion.Tolerance = 5.0e-14
74 filter = smesh.CreateFilterManager().CreateFilter()
75 filter.SetCriteria([criterion])
76 ids = mesh.GetIdsFromFilter(filter)
77 print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)
82 \section filter_minimum_angle Minimum angle
84 Filter 2D mesh elements (faces) according to the minimum angle value:
85 - element type is \a smesh.FACE
86 - functor type is \a smesh.FT_MinimumAngle
87 - threshold is floating point value (minimum angle)
91 from SMESH_mechanic import *
92 # get faces with minimum angle > 75
93 filter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle,">", 75)
94 ids = mesh.GetIdsFromFilter(filter)
95 print "Number of faces with minimum angle > 75:", len(ids)
98 \sa \ref tui_minimum_angle
100 \section filter_taper Taper
102 Filter 2D mesh elements (faces) according to the taper value:
103 - element type is \a smesh.FACE
104 - functor type is \a smesh.FT_Taper
105 - threshold is floating point value (taper)
109 from SMESH_mechanic import *
110 # get faces with taper < 1.e-15
111 filter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_LessThan, 1.e-15)
112 ids = mesh.GetIdsFromFilter(filter)
113 print "Number of faces with taper < 1.e-15:", len(ids)
118 \section filter_skew Skew
120 Filter 2D mesh elements (faces) according to the skew value:
121 - element type is \a smesh.FACE
122 - functor type is \a smesh.FT_Skew
123 - threshold is floating point value (skew)
127 from SMESH_mechanic import *
128 # get faces with skew > 50
129 filter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 50)
130 ids = mesh.GetIdsFromFilter(filter)
131 print "Number of faces with skew > 50:", len(ids)
136 \section filter_area Area
138 Filter 2D mesh elements (faces) according to the area value:
139 - element type is \a smesh.FACE
140 - functor type is \a smesh.FT_Area
141 - threshold is floating point value (area)
145 from SMESH_mechanic import *
146 # get faces with area > 60 and < 90
147 criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 60,\
148 smesh.FT_Undefined, smesh.FT_LogicalAND)
149 criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 90)
150 filter = smesh.CreateFilterManager().CreateFilter()
151 filter.SetCriteria([criterion1,criterion2])
152 ids = mesh.GetIdsFromFilter(filter)
153 print "Number of faces with area in range (60,90):", len(ids)
158 \section filter_volume Volume
160 Filter 3D mesh elements (volumes) according to the volume value:
161 - element type is \a smesh.VOLUME
162 - functor type is \a smesh.FT_Volume3D
163 - threshold is floating point value (volume)
166 # create mesh with volumes
167 from SMESH_mechanic import *
170 # get volumes faces with volume > 100
171 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_MoreThan, 100)
172 ids = mesh.GetIdsFromFilter(filter)
173 print "Number of volumes with volume > 100:", len(ids)
178 \section filter_free_borders Free borders
180 Filter 1D mesh elements (edges) which represent free borders of a mesh:
181 - element type is \a smesh.EDGE
182 - functor type is \a smesh.FT_FreeBorders
183 - threshold value is not required
187 import geompy, smesh, StdMeshers
188 face = geompy.MakeFaceHW(100, 100, 1)
189 geompy.addToStudy( face, "quadrangle" )
190 mesh = smesh.Mesh(face)
191 mesh.Segment().NumberOfSegments(10)
192 mesh.Triangle().MaxElementArea(25)
194 # get all free borders
195 filter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)
196 ids = mesh.GetIdsFromFilter(filter)
197 print "Number of edges on free borders:", len(ids)
200 \sa \ref tui_free_borders
202 \section filter_free_edges Free edges
204 Filter 2D mesh elements (faces) consisting of edges belonging to one
205 element of mesh only:
206 - element type is \a smesh.FACE
207 - functor type is \a smesh.FT_FreeEdges
208 - threshold value is not required
212 import geompy, smesh, StdMeshers
213 face = geompy.MakeFaceHW(100, 100, 1)
214 geompy.addToStudy( face, "quadrangle" )
215 mesh = smesh.Mesh(face)
216 mesh.Segment().NumberOfSegments(10)
217 mesh.Triangle().MaxElementArea(25)
219 # get all faces with free edges
220 filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeEdges)
221 ids = mesh.GetIdsFromFilter(filter)
222 print "Number of faces with free edges:", len(ids)
225 \sa \ref tui_free_edges
227 \section filter_free_nodes Free nodes
230 - element type is \a smesh.NODE
231 - functor type is \a smesh.FT_FreeNodes
232 - threshold value is not required
236 from SMESH_mechanic import *
240 filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
241 ids = mesh.GetIdsFromFilter(filter)
242 print "Number of free nodes:", len(ids)
245 \sa \ref tui_free_nodes
247 \section filter_free_faces Free faces
250 - element type is \a smesh.FACE
251 - functor type is \a smesh.FT_FreeFaces
252 - threshold value is not required
256 from SMESH_mechanic import *
258 filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces)
259 ids = mesh.GetIdsFromFilter(filter)
260 print "Number of free faces:", len(ids)
263 \sa \ref tui_free_faces
265 \section filter_bare_border_faces Bare border faces
267 Filter faces with bare borders:
268 - element type is \a smesh.FACE
269 - functor type is \a smesh.FT_BareBorderFace
270 - threshold value is not required
274 from SMESH_mechanic import *
275 # remove some faces to have faces with bare borders
276 mesh.RemoveElements( mesh.GetElementsByType(FACE)[0:5] )
277 # get all faces bare borders
278 filter = smesh.GetFilter(smesh.FACE, smesh.FT_BareBorderFace)
279 ids = mesh.GetIdsFromFilter(filter)
280 print "Faces with bare borders:", ids
283 \sa \ref tui_bare_border_faces
285 \section filter_coplanar_faces Coplanar faces
287 Filter faces with bare borders:
288 - element type is \a smesh.FACE
289 - functor type is \a smesh.FT_CoplanarFaces
290 - threshold value is the face ID
291 - tolerance is in degrees
295 from SMESH_mechanic import *
296 faceID = mesh.GetElementsByType(FACE)[0]
297 # get all faces co-planar to the first face with tolerance 5 degrees
298 filter = smesh.GetFilter(smesh.FACE, smesh.FT_CoplanarFaces,faceID,Tolerance=5.0)
299 ids = mesh.GetIdsFromFilter(filter)
300 print "Number of faces coplanar with the first one:", len(ids)
303 \section filter_over_constrained_faces Over-constrained faces
305 Filter over-constrained faces:
306 - element type is \a smesh.FACE
307 - functor type is \a smesh.FT_OverConstrainedFace
308 - threshold value is not required
312 from SMESH_mechanic import *
313 # get all over-constrained faces
314 filter = smesh.GetFilter(smesh.FACE, smesh.FT_OverConstrainedFace)
315 ids = mesh.GetIdsFromFilter(filter)
316 print "Over-constrained faces:", ids
319 \sa \ref tui_over_constrained_faces
321 \section filter_double_elements Double edges, Double faces, Double volumes
323 filter mesh elements basing on the same set of nodes:
324 - element type is either \a smesh.EGDE, \a smesh.FACE or \a smesh.VOLUME
325 - functor type is either \a smesh.FT_EqualEdges, \a
326 smesh.FT_EqualFaces or \a smesh.FT_EqualVolumes,
327 - threshold value is not required
331 # make a mesh on a box
332 box = geompy.MakeBoxDXDYDZ(100,100,100)
333 mesh = Mesh( box, "Box" )
334 mesh.Segment().NumberOfSegments(10)
338 # copy all elements with translation and Merge nodes
339 mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
340 mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
341 # create filters to find equal elements
342 equalEdgesFilter = GetFilter(SMESH.EDGE, FT_EqualEdges)
343 equalFacesFilter = GetFilter(SMESH.FACE, FT_EqualFaces)
344 equalVolumesFilter = GetFilter(SMESH.VOLUME, FT_EqualVolumes)
346 print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))
347 print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))
348 print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter ))
352 \section tui_double_nodes_control Double nodes
354 filters mesh nodes which are coincident with other nodes (within a given tolerance):
355 - element type is \a smesh.NODE
356 - functor type is \a smesh.FT_EqualNodes
357 - threshold value is not required
358 - default tolerance is 1.0e-7
362 # make a mesh on a box
363 box = geompy.MakeBoxDXDYDZ(100,100,100)
364 mesh = Mesh( box, "Box" )
365 mesh.Segment().NumberOfSegments(10)
369 # copy all elements with translation
370 mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
371 # create filters to find nodes equal within tolerance of 1e-5
372 filter = GetFilter(SMESH.NODE, FT_EqualNodes, Tolerance=1e-5)
374 print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
378 \section filter_borders_multiconnection Borders at multi-connection
380 Filter border 1D mesh elements (edges) according to the specified number of
381 connections (faces belonging the border edges)
382 - element type is \a smesh.EDGE
383 - functor type is \a smesh.FT_MultiConnection
384 - threshold is integer value (number of connections)
388 from SMESH_mechanic import *
389 # get border edges with number of connected faces = 5
390 filter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, 5)
391 ids = mesh.GetIdsFromFilter(filter)
392 print "Number of border edges with 5 faces connected:", len(ids)
395 \sa \ref tui_borders_at_multiconnection
397 \section filter_borders_multiconnection_2d Borders at multi-connection 2D
399 Filter 2D mesh elements (faces) which consist of edges belonging
400 to the specified number of mesh elements
401 - element type is \a smesh.FACE
402 - functor type is \a smesh.FT_MultiConnection2D
403 - threshold is integer value (number of connections)
407 from SMESH_mechanic import *
408 # get faces which consist of edges belonging to 2 mesh elements
409 filter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, 2)
410 ids = mesh.GetIdsFromFilter(filter)
411 print "Number of faces consisting of edges belonging to 2 faces:", len(ids)
414 \sa \ref tui_borders_at_multiconnection_2d
416 \section filter_length Length
418 Filter 1D mesh elements (edges) according to the edge length value:
419 - element type should be \a smesh.EDGE
420 - functor type should be \a smesh.FT_Length
421 - threshold is floating point value (length)
425 from SMESH_mechanic import *
426 # get edges with length > 14
427 filter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, 14)
428 ids = mesh.GetIdsFromFilter(filter)
429 print "Number of edges with length > 14:", len(ids)
432 \sa \ref tui_length_1d
434 \section filter_length_2d Length 2D
436 Filter 2D mesh elements (faces) corresponding to the maximum length.
438 - element type should be \a smesh.FACE
439 - functor type should be \a smesh.FT_Length2D
440 - threshold is floating point value (edge length)
444 from SMESH_mechanic import *
445 # get all faces that have edges with length > 14
446 filter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, 14)
447 ids = mesh.GetIdsFromFilter(filter)
448 print "Number of faces with maximum edge length > 14:", len(ids)
451 \sa \ref tui_length_2d
453 \section filter_max_element_length_2d Element Diameter 2D
455 Filter 2D mesh elements (faces) corresponding to the maximum length
456 value of its edges and diagonals:
457 - element type should be \a smesh.FACE
458 - functor type should be \a smesh.FT_MaxElementLength2D
459 - threshold is floating point value (edge/diagonal length)
463 from SMESH_mechanic import *
464 # get all faces that have elements with length > 10
465 filter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, 10)
466 ids = mesh.GetIdsFromFilter(filter)
467 print "Number of faces with maximum element length > 10:", len(ids)
470 \sa \ref tui_max_element_length_2d
472 \section filter_max_element_length_3d Element Diameter 3D
474 Filter 3D mesh elements (volumes) corresponding to the maximum length
475 value of its edges and diagonals:
476 - element type should be \a smesh.VOLUME
477 - functor type should be \a smesh.FT_MaxElementLength3D
478 - threshold is floating point value (edge/diagonal length)
481 # create mesh with volumes
482 from SMESH_mechanic import *
485 # get all volumes that have elements with length > 10
486 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, 10)
487 ids = mesh.GetIdsFromFilter(filter)
488 print "Number of volumes with maximum element length > 10:", len(ids)
491 \sa \ref tui_max_element_length_3d
493 \section filter_bare_border_volumes Bare border volumes
495 Filter 3D mesh elements with bare borders:
496 - element type is \a smesh.VOLUME
497 - functor type is \a smesh.FT_BareBorderVolume
498 - threshold value is not required
502 from SMESH_mechanic import *
505 # remove some volumes to have volumes with bare borders
506 mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] )
507 # get all volumes with bare borders
508 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BareBorderVolume)
509 ids = mesh.GetIdsFromFilter(filter)
510 print "Volumes with bare borders:", ids
513 \sa \ref tui_bare_border_volumes
515 \section filter_over_constrained_volumes Over-constrained volumes
517 Filter over-constrained volumes:
518 - element type is \a smesh.VOLUME
519 - functor type is \a smesh.FT_OverConstrainedVolume
520 - threshold value is not required
524 from SMESH_mechanic import *
527 # get all over-constrained volumes
528 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_OverConstrainedVolume)
529 ids = mesh.GetIdsFromFilter(filter)
530 print "Over-constrained volumes:", ids
533 \sa \ref tui_over_constrained_faces
535 \section filter_belong_to_geom Belong to Geom
537 Filter mesh entities (nodes or elements) which all nodes lie on the
538 shape defined by threshold value:
539 - element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME
540 - functor type should be \a smesh.FT_BelongToGeom
541 - threshold is geometrical object
545 from SMESH_mechanic import *
546 # get all faces which nodes lie on the face sub_face3
547 filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToGeom, sub_face3)
548 ids = mesh.GetIdsFromFilter(filter)
549 print "Number of faces which nodes lie on sub_face3:", len(ids)
552 \section filter_lying_on_geom Lying on Geom
554 Filter mesh entities (nodes or elements) at least one node of which lies on the
555 shape defined by threshold value:
556 - element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME
557 - functor type should be \a smesh.FT_LyingOnGeom
558 - threshold is geometrical object
562 from SMESH_mechanic import *
563 # get all faces at least one node of each lies on the face sub_face3
564 filter = smesh.GetFilter(smesh.FACE, smesh.FT_LyingOnGeom, sub_face3)
565 ids = mesh.GetIdsFromFilter(filter)
566 print "Number of faces at least one node of each lies on sub_face3:", len(ids)
569 \section filter_belong_to_plane Belong to Plane
571 Filter mesh entities (nodes or elements) which all nodes belong to the
572 plane defined by threshold value with the given tolerance:
573 - element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE
574 - functor type should be \a smesh.FT_BelongToPlane
575 - threshold is geometrical object (plane)
576 - default tolerance is 1.0e-7
580 from SMESH_mechanic import *
583 plane_1 = geompy.MakePlane(p3,seg1,2000)
584 geompy.addToStudy(plane_1, "plane_1")
585 # get all nodes which lie on the plane \a plane_1
586 filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToPlane, plane_1)
587 ids = mesh.GetIdsFromFilter(filter)
588 print "Number of nodes which lie on the plane plane_1:", len(ids)
591 \section filter_belong_to_cylinder Belong to Cylinder
593 Filter mesh entities (nodes or elements) which all nodes belong to the
594 cylindrical face defined by threshold value with the given tolerance:
595 - element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE
596 - functor type should be \a smesh.FT_BelongToCylinder
597 - threshold is geometrical object (cylindrical face)
598 - default tolerance is 1.0e-7
602 from SMESH_mechanic import *
603 # get all faces which lie on the cylindrical face \a sub_face1
604 filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToCylinder, sub_face1)
605 ids = mesh.GetIdsFromFilter(filter)
606 print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids)
609 \section filter_belong_to_surface Belong to Surface
611 Filter mesh entities (nodes or elements) which all nodes belong to the
612 arbitrary surface defined by threshold value with the given tolerance:
613 - element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE
614 - functor type should be \a smesh.FT_BelongToGenSurface
615 - threshold is geometrical object (arbitrary surface)
616 - default tolerance is 1.0e-7
620 from SMESH_mechanic import *
622 spline_1 = geompy.MakeInterpol([p4,p6,p3,p1])
623 surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 )
624 geompy.addToStudy(surface_1, "surface_1")
625 # get all nodes which lie on the surface \a surface_1
626 filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToGenSurface, surface_1)
627 ids = mesh.GetIdsFromFilter(filter)
628 print "Number of nodes which lie on the surface surface_1:", len(ids)
631 \section filter_range_of_ids Range of IDs
633 Filter mesh entities elements (nodes or elements) according to the
634 specified identifiers range:
635 - element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME
636 - functor type is \a smesh.FT_RangeOfIds
637 - threshold is string listing required IDs and/or ranges of IDs, e.g."1,2,3,50-60,63,67,70-78"
641 from SMESH_mechanic import *
642 # get nodes with identifiers [5-10] and [15-30]
643 criterion1 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="5-10",\
644 BinaryOp=smesh.FT_LogicalOR)
645 criterion2 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="15-30")
646 filter = smesh.CreateFilterManager().CreateFilter()
647 filter.SetCriteria([criterion1,criterion2])
648 ids = mesh.GetIdsFromFilter(filter)
649 print "Number of nodes in ranges [5-10] and [15-30]:", len(ids)
652 \section filter_bad_oriented_volume Badly oriented volume
654 Filter 3D mesh elements (volumes), which are incorrectly oriented from
655 the point of view of MED convention.
656 - element type should be \a smesh.VOLUME
657 - functor type is \a smesh.FT_BadOrientedVolume
658 - threshold is not required
661 # create mesh with volumes
662 from SMESH_mechanic import *
665 # get all badly oriented volumes
666 filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BadOrientedVolume)
667 ids = mesh.GetIdsFromFilter(filter)
668 print "Number of badly oriented volumes:", len(ids)
671 \section filter_linear_or_quadratic Linear / quadratic
673 Filter linear / quadratic mesh elements:
674 - element type should be any element type, e.g.: \a smesh.EDGE, \a smesh.FACE, \a smesh.VOLUME
675 - functor type is \a smesh.FT_LinearOrQuadratic
676 - threshold is not required
677 - if unary operator is set to smesh.FT_LogicalNOT, the quadratic
678 elements are selected, otherwise (by default) linear elements are selected
682 from SMESH_mechanic import *
683 # get number of linear and quadratic edges
684 filter_linear = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic)
685 filter_quadratic = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic, smesh.FT_LogicalNOT)
686 ids_linear = mesh.GetIdsFromFilter(filter_linear)
687 ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
688 print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
689 # convert mesh to quadratic
690 print "Convert to quadratic..."
691 mesh.ConvertToQuadratic(True)
692 # get number of linear and quadratic edges
693 ids_linear = mesh.GetIdsFromFilter(filter_linear)
694 ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
695 print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
698 \section filter_group_color Group color
700 Filter mesh entities, belonging to the group with the color defined by the threshold value.
701 - element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME
702 - functor type is \a smesh.FT_GroupColor
703 - threshold should be of SALOMEDS.Color type
707 from SMESH_mechanic import *
708 # create group of edges
709 all_edges = mesh.GetElementsByType(smesh.EDGE)
710 grp = mesh.MakeGroupByIds("edges group", smesh.EDGE, all_edges[:len(all_edges)/4])
712 c = SALOMEDS.Color(0.1, 0.5, 1.0)
714 # get number of the edges not belonging to the group with the given color
715 filter = smesh.GetFilter(smesh.EDGE, smesh.FT_GroupColor, c, smesh.FT_LogicalNOT)
716 ids = mesh.GetIdsFromFilter(filter)
717 print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids)
720 \section filter_geom_type Geometry type
722 Filter mesh elements by the geometric type defined with the threshold
723 value. The list of available geometric types depends on the element
725 - element type should be any element type, e.g.: \a smesh.EDGE, \a smesh.FACE, \a smesh.VOLUME
726 - functor type should be \a smesh.FT_ElemGeomType
727 - threshold is of smesh.GeometryType value
730 # create mesh with volumes
731 from SMESH_mechanic import *
734 # get all triangles, quadrangles, tetrahedrons, pyramids
735 filter_tri = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_TRIANGLE)
736 filter_qua = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE)
737 filter_tet = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_TETRA)
738 filter_pyr = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_PYRAMID)
739 ids_tri = mesh.GetIdsFromFilter(filter_tri)
740 ids_qua = mesh.GetIdsFromFilter(filter_qua)
741 ids_tet = mesh.GetIdsFromFilter(filter_tet)
742 ids_pyr = mesh.GetIdsFromFilter(filter_pyr)
743 print "Number of triangles:", len(ids_tri)
744 print "Number of quadrangles:", len(ids_qua)
745 print "Number of tetrahedrons:", len(ids_tet)
746 print "Number of pyramids:", len(ids_pyr)
749 \section combining_filters How to combine filters with Criterion structures?
751 Filters can be combined by making use of "criteria".
757 from SMESH_mechanic import *
758 # get all the quadrangle faces ...
759 criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE, smesh.FT_LogicalAND)
760 # ... AND do NOT get those from sub_face3
761 criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_BelongToGeom, sub_face3, smesh.FT_LogicalNOT)
762 filter = smesh.CreateFilterManager().CreateFilter()
763 filter.SetCriteria([criterion1,criterion2])
764 ids = mesh.GetIdsFromFilter(filter)
766 myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids)