Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/smesh.git] / doc / salome / gui / SMESH / input / tui_filters.doc
1 /*!
2
3 \page tui_filters_page Filters usage
4
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.
9
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.
13
14 Mesh filters use the functionality of mesh quality controls to filter
15 mesh nodes / elements by a specific characteristic (Area, Length, etc).
16
17 This page provides a short description of the existing mesh filters,
18 describes required parameters and gives simple examples of usage in
19 Python scripts.
20
21 \sa \ref tui_quality_controls_page
22
23 \section filter_aspect_ratio Aspect ratio
24
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)
29
30 \code
31 # create mesh
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)
37 \endcode
38
39 \sa \ref tui_aspect_ratio
40
41 \section filter_aspect_ratio_3d Aspect ratio 3D
42
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)
47
48 \code
49 # create mesh with volumes
50 from SMESH_mechanic import *
51 mesh.Tetrahedron()
52 mesh.Compute()
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)
57 \endcode
58
59 \sa \ref tui_aspect_ratio_3d
60
61 \section filter_warping_angle Warping angle
62
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)
67
68 \code
69 # create mesh
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)
78 \endcode
79
80 \sa \ref tui_warping
81
82 \section filter_minimum_angle Minimum angle
83
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)
88
89 \code
90 # create mesh
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)
96 \endcode
97
98 \sa \ref tui_minimum_angle
99
100 \section filter_taper Taper
101
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)
106
107 \code
108 # create mesh
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)
114 \endcode
115
116 \sa \ref tui_taper
117
118 \section filter_skew Skew
119
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)
124
125 \code
126 # create mesh
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)
132 \endcode
133
134 \sa \ref tui_skew
135
136 \section filter_area Area
137
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)
142
143 \code
144 # create mesh
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)
154 \endcode
155
156 \sa \ref tui_area
157
158 \section filter_volume Volume
159
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)
164
165 \code
166 # create mesh with volumes
167 from SMESH_mechanic import *
168 mesh.Tetrahedron()
169 mesh.Compute()
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)
174 \endcode
175
176 \sa \ref tui_volume
177
178 \section filter_free_borders Free borders
179
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
184
185 \code
186 # create mesh
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)
193 mesh.Compute()
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)
198 \endcode
199
200 \sa \ref tui_free_borders
201
202 \section filter_free_edges Free edges
203
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
209
210 \code
211 # create mesh
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)
218 mesh.Compute()
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)
223 \endcode
224
225 \sa \ref tui_free_edges
226
227 \section filter_free_nodes Free nodes
228
229 Filter free nodes:
230 - element type is \a smesh.NODE
231 - functor type is \a smesh.FT_FreeNodes
232 - threshold value is not required
233
234 \code
235 # create mesh
236 from SMESH_mechanic import *
237 # add node
238 mesh.AddNode(0,0,0)
239 # get all free nodes
240 filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
241 ids = mesh.GetIdsFromFilter(filter)
242 print "Number of free nodes:", len(ids)
243 \endcode
244
245 \sa \ref tui_free_nodes
246
247 \section filter_free_faces Free faces
248
249 Filter free faces:
250 - element type is \a smesh.FACE
251 - functor type is \a smesh.FT_FreeFaces
252 - threshold value is not required
253
254 \code
255 # create mesh
256 from SMESH_mechanic import *
257 # get all free faces
258 filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces)
259 ids = mesh.GetIdsFromFilter(filter)
260 print "Number of free faces:", len(ids)
261 \endcode
262
263 \sa \ref tui_free_faces
264
265 \section filter_bare_border_faces Bare border faces
266
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
271
272 \code
273 # create mesh
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
281 \endcode
282
283 \sa \ref tui_bare_border_faces
284
285 \section filter_coplanar_faces Coplanar faces
286
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
292
293 \code
294 # create mesh
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)
301 \endcode
302
303 \section filter_over_constrained_faces Over-constrained faces
304
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
309
310 \code
311 # create mesh
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
317 \endcode
318
319 \sa \ref tui_over_constrained_faces
320
321 \section filter_double_elements Double edges, Double faces, Double volumes
322
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
328
329 \code
330 from smesh import *
331 # make a mesh on a box
332 box = geompy.MakeBoxDXDYDZ(100,100,100)
333 mesh = Mesh( box, "Box" )
334 mesh.Segment().NumberOfSegments(10)
335 mesh.Quadrangle()
336 mesh.Hexahedron()
337 mesh.Compute()
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)
345 # get equal elements
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 ))
349 \endcode
350
351
352 \section tui_double_nodes_control Double nodes
353
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
359
360 \code
361 from smesh import *
362 # make a mesh on a box
363 box = geompy.MakeBoxDXDYDZ(100,100,100)
364 mesh = Mesh( box, "Box" )
365 mesh.Segment().NumberOfSegments(10)
366 mesh.Quadrangle()
367 mesh.Hexahedron()
368 mesh.Compute()
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)
373 # get equal nodes
374 print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
375 \endcode
376
377
378 \section filter_borders_multiconnection Borders at multi-connection
379
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)
385
386 \code
387 # create mesh
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)
393 \endcode
394
395 \sa \ref tui_borders_at_multiconnection
396
397 \section filter_borders_multiconnection_2d Borders at multi-connection 2D
398
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)
404
405 \code
406 # create mesh
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)
412 \endcode
413
414 \sa \ref tui_borders_at_multiconnection_2d
415
416 \section filter_length Length
417
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)
422
423 \code
424 # create mesh
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)
430 \endcode
431
432 \sa \ref tui_length_1d
433
434 \section filter_length_2d Length 2D
435
436 Filter 2D mesh elements (faces) corresponding to the maximum length.
437 value of its edges:
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)
441
442 \code
443 # create mesh
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)
449 \endcode
450
451 \sa \ref tui_length_2d
452
453 \section filter_max_element_length_2d Element Diameter 2D
454
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)
460
461 \code
462 # create mesh
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)
468 \endcode
469
470 \sa \ref tui_max_element_length_2d
471
472 \section filter_max_element_length_3d Element Diameter 3D
473
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)
479
480 \code
481 # create mesh with volumes
482 from SMESH_mechanic import *
483 mesh.Tetrahedron()
484 mesh.Compute()
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)
489 \endcode
490
491 \sa \ref tui_max_element_length_3d
492
493 \section filter_bare_border_volumes Bare border volumes
494
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
499
500 \code
501 # create mesh
502 from SMESH_mechanic import *
503 mesh.Tetrahedron()
504 mesh.Compute()
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
511 \endcode
512
513 \sa \ref tui_bare_border_volumes
514
515 \section filter_over_constrained_volumes Over-constrained volumes
516
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
521
522 \code
523 # create mesh
524 from SMESH_mechanic import *
525 mesh.Tetrahedron()
526 mesh.Compute()
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
531 \endcode
532
533 \sa \ref tui_over_constrained_faces
534
535 \section filter_belong_to_geom Belong to Geom
536
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
542
543 \code
544 # create mesh
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)
550 \endcode
551
552 \section filter_lying_on_geom Lying on Geom
553
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
559
560 \code
561 # create mesh
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)
567 \endcode
568
569 \section filter_belong_to_plane Belong to Plane
570
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
577
578 \code
579 # create mesh
580 from SMESH_mechanic import *
581 # create plane
582 import geompy
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)
589 \endcode
590
591 \section filter_belong_to_cylinder Belong to Cylinder
592
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
599
600 \code
601 # create mesh
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)
607 \endcode
608
609 \section filter_belong_to_surface Belong to Surface
610
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
617
618 \code
619 # create mesh
620 from SMESH_mechanic import *
621 # create b-spline
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)
629 \endcode
630
631 \section filter_range_of_ids Range of IDs
632
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"  
638
639 \code
640 # create mesh
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)
650 \endcode
651
652 \section filter_bad_oriented_volume Badly oriented volume
653
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
659
660 \code
661 # create mesh with volumes
662 from SMESH_mechanic import *
663 mesh.Tetrahedron()
664 mesh.Compute()
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)
669 \endcode
670
671 \section filter_linear_or_quadratic Linear / quadratic
672
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
679
680 \code
681 # create mesh
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)
696 \endcode
697
698 \section filter_group_color Group color
699
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
704
705 \code
706 # create mesh
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])
711 import SALOMEDS
712 c = SALOMEDS.Color(0.1, 0.5, 1.0)
713 grp.SetColor(c)
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)
718 \endcode
719
720 \section filter_geom_type Geometry type
721
722 Filter mesh elements by the geometric type defined with the threshold
723 value. The list of available geometric types depends on the element
724 entity type.
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
728
729 \code
730 # create mesh with volumes
731 from SMESH_mechanic import *
732 mesh.Tetrahedron()
733 mesh.Compute()
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)
747 \endcode
748
749 \section combining_filters How to combine filters with Criterion structures?
750
751 Filters can be combined by making use of "criteria".
752
753 Example :
754
755 \code
756 # create mesh
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)
765
766 myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids)
767 \endcode
768
769
770 */