Salome HOME
0022098: EDF 2036 SMESH: Create groups from none conected parts of a mesh
[modules/smesh.git] / idl / SMESH_Filter.idl
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SMESH_Filter.idl
24 //  Author : Alexey Petrov, OCC
25 //
26 #ifndef _SMESH_FILTER_IDL_
27 #define _SMESH_FILTER_IDL_
28
29 #include "SALOME_Exception.idl"
30 #include "SALOME_GenericObj.idl"
31 #include "GEOM_Gen.idl"
32 #include "SMESH_Mesh.idl"
33
34 module SMESH
35 {
36
37   /*!
38   * Enumeration of functor types
39   */
40   enum FunctorType
41   {
42     FT_AspectRatio,
43     FT_AspectRatio3D,
44     FT_Warping,   
45     FT_MinimumAngle,
46     FT_Taper,       
47     FT_Skew,         
48     FT_Area,          
49     FT_Volume3D,          
50     FT_MaxElementLength2D,
51     FT_MaxElementLength3D,
52     FT_FreeBorders,
53     FT_FreeEdges,
54     FT_FreeNodes,
55     FT_FreeFaces,
56     FT_EqualNodes,  // IMPORTANT: when a new item is added, please
57     FT_EqualEdges,  // 1) update getFunctNames() in SMESH_Filter_i.cxx: line 3910
58     FT_EqualFaces,  // 2) update fixFunctorType() in SMESH_2smeshpy.cxx: line 234
59     FT_EqualVolumes,
60     FT_MultiConnection,
61     FT_MultiConnection2D,
62     FT_Length,
63     FT_Length2D,
64     FT_BelongToGeom,
65     FT_BelongToPlane,
66     FT_BelongToCylinder,
67     FT_BelongToGenSurface,
68     FT_LyingOnGeom,
69     FT_RangeOfIds,
70     FT_BadOrientedVolume,
71     FT_BareBorderVolume,
72     FT_BareBorderFace,
73     FT_OverConstrainedVolume,
74     FT_OverConstrainedFace,
75     FT_LinearOrQuadratic,
76     FT_GroupColor,
77     FT_ElemGeomType,
78     FT_EntityType,
79     FT_CoplanarFaces,
80     FT_BallDiameter,
81     FT_LessThan,
82     FT_MoreThan,
83     FT_EqualTo,
84     FT_LogicalNOT,
85     FT_LogicalAND,
86     FT_LogicalOR,
87     FT_Undefined
88   };
89
90   /*!
91   * Parameters of a reclangle of histogram
92   */
93   struct HistogramRectangle
94   {
95     long nbEvents;
96     double min;
97     double max;
98   };
99   typedef sequence<HistogramRectangle> Histogram;
100
101
102   /*!
103   * Base interface for all functors ( i.e. numerical functors and predicates )
104   */
105   interface Functor: SALOME::GenericObj
106   {
107     void            SetMesh( in SMESH_Mesh theMesh );
108     FunctorType     GetFunctorType();
109     ElementType     GetElementType();
110   };
111
112   /*!
113   * Numerical functors are intended for calculating value by Id of mesh entity
114   */
115   interface NumericalFunctor: Functor
116   {
117     double GetValue( in long theElementId );
118
119     Histogram GetHistogram( in short nbIntervals, in boolean isLogarithmic );
120
121     /*!
122     * Set precision for calculation. It is a position after point which is
123     * used to functor value after calculation.
124     */
125     void   SetPrecision( in long thePrecision );
126     long   GetPrecision();
127   };
128   interface MinimumAngle    : NumericalFunctor{};
129   interface AspectRatio     : NumericalFunctor{};
130   interface AspectRatio3D   : NumericalFunctor{};
131   interface Warping         : NumericalFunctor{};
132   interface Taper           : NumericalFunctor{};
133   interface Skew            : NumericalFunctor{};
134   interface Area            : NumericalFunctor{};
135   interface Volume3D        : NumericalFunctor{};
136   interface MaxElementLength2D : NumericalFunctor{};
137   interface MaxElementLength3D : NumericalFunctor{};
138   interface Length          : NumericalFunctor{};
139   interface Length2D        : NumericalFunctor
140   {
141     struct Value
142     {
143       double myLength;
144       long myPnt1, myPnt2;
145     };
146     typedef sequence<Value> Values;
147     Values GetValues();
148   };
149   interface MultiConnection   : NumericalFunctor{};
150   interface MultiConnection2D : NumericalFunctor
151   {
152     struct Value
153     {
154       long myNbConnects;
155       long myPnt1, myPnt2;
156     };
157     
158     typedef sequence<Value> Values;
159     Values GetValues();
160   };
161   interface BallDiameter    : NumericalFunctor{};
162   
163
164   /*!
165   * Predicates are intended for verification of criteria,
166   *            must return bool value by mesh id
167   */
168   interface Predicate: Functor
169   {
170     boolean IsSatisfy( in long thEntityId );
171   };
172
173   /*!
174    * Logical functor (predicate) "Bad Oriented Volume".
175    * Verify whether a mesh volume is incorrectly oriented from
176    * the point of view of MED convention
177    */
178   interface BadOrientedVolume: Predicate {};
179
180   /*!
181    * Logical functor (predicate) "Volumes with bare border".
182    * Verify whether a mesh volume has a free facet without a mesh face on it
183    */
184   interface BareBorderVolume: Predicate {};
185   /*!
186    * Logical functor (predicate) "Faces with bare border".
187    * Verify whether a mesh face has a side not shared with another face
188    * and without a mesh edge on it
189    */
190   interface BareBorderFace: Predicate {};
191
192   /*!
193    * Logical functor (predicate) "Over-constrained Volume"
194    * Verify whether a mesh volume has only one facet shared with other volumes
195    */
196   interface OverConstrainedVolume: Predicate {};
197   /*!
198    * Logical functor (predicate) "Over-constrained Face".
199    * Verify whether a mesh face has only one border shared with other faces
200    */
201   interface OverConstrainedFace: Predicate {};
202
203   /*!
204    * Logical functor (predicate) "Equal Nodes".
205    * Verify whether there is another mesh node with same coordinates
206    */
207   interface EqualNodes: Predicate 
208   {
209     void    SetTolerance( in double theToler );
210     double  GetTolerance();
211   };
212   /*!
213    * Logical functor (predicate) "Equal Edges".
214    * Verify whether there is another mesh edge basing on the same nodes
215    */
216   interface EqualEdges: Predicate {};
217   /*!
218    * Logical functor (predicate) "Equal Faces".
219    * Verify whether there is another mesh face basing on the same nodes
220    */
221   interface EqualFaces: Predicate {};
222   /*!
223    * Logical functor (predicate) "Equal Volumes".
224    * Verify whether there is another mesh volumes basing on the same nodes
225    */
226   interface EqualVolumes: Predicate {};
227
228   /*!
229    * Logical functor (predicate) "Belong To Geometry".
230    * Verify whether mesh element or node belong to pointed Geom Object
231    */
232   interface BelongToGeom: Predicate
233   {
234     void SetGeom( in GEOM::GEOM_Object theGeom );
235     void SetElementType( in ElementType theType );
236
237     /*! The tolerance is used only if there is no submesh on the shape
238      */
239     void    SetTolerance( in double theToler );
240     double  GetTolerance();
241
242     void   SetShapeName( in string theName );
243     void   SetShape( in string theID, in string theName );
244     string GetShapeName();
245     string GetShapeID();
246   };
247
248   /*!
249   * Logical functor (predicate) "Belong To Surface".
250   * Base interface for "belong to plane" and "belong to cylinder"
251   * and "Belong To Generic Surface" interfaces
252   */
253   interface BelongToSurface: Predicate
254   {
255     void    SetTolerance( in double theToler );
256     double  GetTolerance();
257     void    SetShapeName( in string theName, in ElementType theType );
258     void    SetShape( in string theID, in string theName, in ElementType theType );
259     string  GetShapeName();
260     string  GetShapeID();
261     /*!
262     * Limit surface extent to bounding box of boundaries (edges)
263     * in surface parametric space. Boundaries are ignored by default
264     */
265     void    SetUseBoundaries( in boolean theUseBndRestrictions );
266     boolean GetUseBoundaries();
267   };
268
269   /*!
270   * Logical functor (predicate) "Belong To Plane".
271   * Verify whether mesh element lie on pointed Geom planar object
272   */
273   interface BelongToPlane: BelongToSurface
274   {
275     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
276   };
277
278   /*!
279   * Logical functor (predicate) "Belong To Cylinder".
280   * Verify whether mesh element lie on pointed Geom cylindrical object
281   */
282   interface BelongToCylinder: BelongToSurface
283   {
284     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
285   };
286
287   /*!
288   * Logical functor (predicate) "Belong To Generic Surface".
289   * Verify whether mesh element lie in pointed Geom cylindrical object
290   */
291   interface BelongToGenSurface: BelongToSurface
292   {
293     void   SetSurface( in GEOM::GEOM_Object theGeom, in ElementType theType );
294   };
295
296   /*!
297   * Logical functor (predicate) "Lying On Geometry".
298   * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
299   */
300   interface LyingOnGeom: Predicate
301   {
302     void SetGeom( in GEOM::GEOM_Object theGeom );
303     void SetElementType( in ElementType theType );
304
305     /*! The tolerance is used only if there is no submesh on the shape
306      */
307     void    SetTolerance( in double theToler );
308     double  GetTolerance();
309
310     void   SetShapeName( in string theName );
311     void   SetShape( in string theID, in string theName );
312     string GetShapeName();    
313     string GetShapeID(); 
314   };
315  
316   /*!
317   * Logical functor (predicate) "Free borders".
318   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
319   */
320   interface FreeBorders: Predicate{};
321
322   /*!
323   * Logical functor (predicate) "Free edges".
324   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
325   */
326   interface FreeEdges: Predicate
327   {
328     struct Border
329     {
330       long myElemId;
331       long myPnt1, myPnt2;
332     };
333     typedef sequence<Border> Borders;
334     Borders GetBorders();
335   };
336
337   /*!
338   * Logical functor (predicate) "Free nodes".
339   * Verify whether mesh has free nodes( i.e. nodes are not connected to any element )
340   */
341   interface FreeNodes: Predicate{};
342  
343   /*!
344   * Logical functor (predicate) "Free faces".
345   * Verify whether 2D mesh element is free ( i.e. connected to one volume only )
346   */
347   interface FreeFaces: Predicate{};
348
349   /*!
350   * Abstract logical functor (predicate) "RangeOfIds".
351   * Verify whether an Entity Id belongs to defined sequence of id's
352   */
353   interface RangeOfIds: Predicate
354   {
355     void            SetRange( in long_array theIds );
356     boolean         SetRangeStr( in string theRange );
357     string          GetRangeStr();
358
359     void            SetElementType( in ElementType theType );
360   };
361
362   /*!
363   * Comparator. Predicate for compare value calculated
364   *             by numerical functor with threshold value
365   */
366   interface Comparator: Predicate
367   {
368     void    SetMargin( in double theValue );
369     void    SetNumFunctor( in NumericalFunctor theFunct );
370     double  GetMargin();
371   };
372   interface LessThan: Comparator{};
373   interface MoreThan: Comparator{};
374   interface EqualTo : Comparator
375   {
376     void    SetTolerance( in double theToler );
377     double  GetTolerance();
378   };
379
380   /*!
381   * Logical predicates are intended for compose predicates using boolean operations
382   */
383   interface Logical: Predicate{};
384
385   interface LogicalNOT: Logical
386   {
387     void SetPredicate(in Predicate thePredicate);
388   };
389
390   interface LogicalBinary: Logical
391 {
392     void SetPredicate1( in Predicate thePredicate );
393     void SetPredicate2( in Predicate thePredicate );
394   };
395
396   interface LogicalAND: LogicalBinary{};
397   interface LogicalOR : LogicalBinary{};
398
399   /*!
400    * Logical functor (predicate) "Is element Linear or Quadratic".
401    * Verify whether a mesh element is linear
402    */
403   interface LinearOrQuadratic: Predicate {
404     void            SetElementType( in ElementType theType );
405   };
406
407   /*!
408   * Functor "Group Color"
409   * Returns color of group to which mesh element belongs to
410   */
411   interface GroupColor : Predicate{
412     void            SetElementType( in ElementType theType );
413     void            SetColorStr( in string theColor );
414     string          GetColorStr();
415   };
416
417   /*!
418   * Functor "Element geometry type"
419   * Returns is element has indicated geometry type
420   */
421   interface ElemGeomType : Predicate{
422     void            SetElementType ( in ElementType  theType );
423     void            SetGeometryType( in GeometryType theType );
424   };
425
426   /*!
427   * Functor "Element entity type"
428   * Returns is element has indicated entity type
429   */
430   interface ElemEntityType : Predicate{
431     void            SetElementType ( in ElementType  theType );
432     void            SetEntityType( in EntityType theSetEntityType );
433   };
434
435   /*!
436   * Functor "Coplanar faces"
437   * Returns true if a mesh face is a coplanar neighbour to a given one. It checks
438   * if normal of a face has angle with the threshold face less than a tolerance.
439   */
440   interface CoplanarFaces : Predicate{
441     void            SetFace ( in long theFaceID );
442     void            SetTolerance( in double theToler );
443   };
444
445   /*!
446   *  Filter
447   */
448   interface Filter: SALOME::GenericObj, SMESH_IDSource
449   {
450     /*!
451     * Structure containing information about one criterion
452     *   Type          - FT_Taper, FT_Skew ...
453     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
454     *   Threshold     - threshold value
455     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
456     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
457     *                   (FT_Undefined must be for the last criterion)
458     *   ThresholdStr  - Threshold value defined as string. Used for:
459     *                   1. Diapason of identifiers. Example: "1,2,3,5-10,12,27-29"
460     *                   2. BelongToGeom predicate for storing name of shape
461     *                   3. GroupColor predicate for storing group color "0.2;0;0.5"
462     *   ThresholdID   - One more threshold value defined as string. Used for:
463     *                   1. BelongToGeom predicate for storing id of shape
464     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
465     *                   "Belong to plane", "Belong to cylinder" etc predicates
466     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
467     *   Precision     - Precision of numerical functors
468     */
469     struct Criterion
470     {
471       long        Type;
472       long        Compare;
473       double      Threshold;
474       string      ThresholdStr;
475       string      ThresholdID;
476       long        UnaryOp;
477       long        BinaryOp;
478       double      Tolerance;
479       ElementType TypeOfElement;
480       long        Precision;
481     };
482
483     typedef sequence<Criterion> Criteria;
484
485     void          SetPredicate( in Predicate thePredicate );
486     void          SetMesh( in SMESH_Mesh theMesh );
487
488     long_array    GetElementsId( in SMESH_Mesh theMesh );
489     ElementType   GetElementType();
490     Predicate     GetPredicate();
491
492     boolean       GetCriteria( out Criteria theCriteria );
493     boolean       SetCriteria( in Criteria theCriteria );
494   };
495
496
497   /*!
498   *  Interface for working with library of filters
499   */
500   interface FilterLibrary : SALOME::GenericObj
501   {
502     /*!
503     *  Copy filter from library by name (new filter is created)
504     */
505     Filter        Copy( in string theFilterName );
506
507     /*!
508     * Methods for editing library
509     */
510     boolean       Add     ( in string theFilterName, in Filter theFilter );
511     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
512     boolean       Delete  ( in string theFilterName );
513     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
514
515     /*!
516     *  Save library on disk
517     */
518     boolean       Save();
519     boolean       SaveAs( in string aFileName );
520
521     /*!
522     * Query methods
523     */
524     boolean       IsPresent( in string aFilterName );
525     long          NbFilters( in ElementType aType );
526     string_array  GetNames( in ElementType aType );
527     string_array  GetAllNames();
528     void          SetFileName( in string aFilterName );
529     string        GetFileName();
530   };
531
532
533   /*!
534   * Interface of Filter manager
535   */
536   interface FilterManager: SALOME::GenericObj
537   {
538     /*!
539     *  Create numerical functors
540     */
541     MinimumAngle      CreateMinimumAngle();
542     AspectRatio       CreateAspectRatio();
543     AspectRatio3D     CreateAspectRatio3D();
544     Warping           CreateWarping();
545     Taper             CreateTaper();
546     Skew              CreateSkew();
547     Area              CreateArea();
548     Volume3D          CreateVolume3D();
549     MaxElementLength2D CreateMaxElementLength2D();
550     MaxElementLength3D CreateMaxElementLength3D();
551     Length            CreateLength();
552     Length2D          CreateLength2D();
553     MultiConnection   CreateMultiConnection();
554     MultiConnection2D CreateMultiConnection2D();
555     BallDiameter      CreateBallDiameter();
556     /*!
557     *  Create logical functors ( predicates )
558     */
559     BelongToGeom      CreateBelongToGeom();
560     BelongToPlane     CreateBelongToPlane();
561     BelongToCylinder  CreateBelongToCylinder();
562     BelongToGenSurface CreateBelongToGenSurface();
563
564     LyingOnGeom       CreateLyingOnGeom();
565
566     FreeBorders       CreateFreeBorders();
567     FreeEdges         CreateFreeEdges();
568     FreeNodes         CreateFreeNodes();
569     FreeFaces         CreateFreeFaces();
570
571     EqualNodes        CreateEqualNodes();
572     EqualEdges        CreateEqualEdges();
573     EqualFaces        CreateEqualFaces();
574     EqualVolumes      CreateEqualVolumes();
575
576     RangeOfIds        CreateRangeOfIds();
577
578     BadOrientedVolume CreateBadOrientedVolume();
579     BareBorderVolume  CreateBareBorderVolume();
580     BareBorderFace    CreateBareBorderFace();
581     OverConstrainedVolume CreateOverConstrainedVolume();
582     OverConstrainedFace   CreateOverConstrainedFace();
583     LinearOrQuadratic CreateLinearOrQuadratic();
584
585     GroupColor        CreateGroupColor();
586     ElemGeomType      CreateElemGeomType();
587     ElemEntityType    CreateElemEntityType();
588     CoplanarFaces     CreateCoplanarFaces();
589
590     /*!
591     *  Create comparators ( predicates )
592     */
593     LessThan          CreateLessThan();
594     MoreThan          CreateMoreThan();
595     EqualTo           CreateEqualTo();
596
597     /*!
598     *  Create boolean operations ( predicates )
599     */
600     LogicalNOT        CreateLogicalNOT();
601     LogicalAND        CreateLogicalAND();
602     LogicalOR         CreateLogicalOR();
603
604     /*!
605     *  Create filter
606     */
607     Filter            CreateFilter();
608
609     /*!
610     *  Load filter library. If libary does not exist it is created
611     */
612     FilterLibrary     LoadLibrary( in string aFileName );
613
614     /*!
615     *  Create new library
616     */
617     FilterLibrary     CreateLibrary();
618
619     /*!
620     *  Delete library
621     */
622     boolean           DeleteLibrary( in string aFileName );
623   };
624 };
625
626
627 #endif