Salome HOME
BUG SWP13024
[modules/smesh.git] / idl / SMESH_Filter.idl
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //
21 //
22 //  File   : SMESH_Filter.idl
23 //  Author : Alexey Petrov, OCC
24
25 #ifndef _SMESH_FILTER_IDL_
26 #define _SMESH_FILTER_IDL_
27
28 #include "SALOME_Exception.idl"
29 #include "SALOME_GenericObj.idl"
30 #include "GEOM_Gen.idl"
31 #include "SMESH_Mesh.idl"
32
33 #include "GEOM_Gen.idl"
34
35
36 module SMESH
37 {
38
39   /*!
40   * Enumeration of functor types
41   */
42   enum FunctorType
43   {
44     FT_AspectRatio,
45     FT_AspectRatio3D,
46     FT_Warping,   
47     FT_MinimumAngle,
48     FT_Taper,       
49     FT_Skew,         
50     FT_Area,          
51     FT_Volume3D,          
52     FT_FreeBorders,
53     FT_FreeEdges,
54     FT_MultiConnection,
55     FT_MultiConnection2D,
56     FT_Length,
57     FT_Length2D,
58     FT_BelongToGeom,
59     FT_BelongToPlane,
60     FT_BelongToCylinder,
61     FT_LyingOnGeom,
62     FT_RangeOfIds,
63     FT_BadOrientedVolume,
64     FT_LessThan,
65     FT_MoreThan,
66     FT_EqualTo,
67     FT_LogicalNOT,
68     FT_LogicalAND,
69     FT_LogicalOR,
70     FT_Undefined
71   };
72
73   /*!
74   * Base interface for all functors ( i.e. numerical functors and predicates )
75   */
76   interface Functor: SALOME::GenericObj
77   {
78     void            SetMesh( in SMESH_Mesh theMesh );
79     FunctorType     GetFunctorType();
80     ElementType     GetElementType();
81   };
82
83
84
85   /*!
86   * Numerical functors are intended for calculating value by Id of mesh entity
87   */
88   interface NumericalFunctor: Functor
89   {
90     double GetValue( in long theElementId );
91
92     /*!
93     * Set precision for calculation. It is a position after point which is
94     * used to functor value after calculation.
95     */
96     void   SetPrecision( in long thePrecision );
97     long   GetPrecision();
98   };
99   interface MinimumAngle    : NumericalFunctor{};
100   interface AspectRatio     : NumericalFunctor{};
101   interface AspectRatio3D   : NumericalFunctor{};
102   interface Warping         : NumericalFunctor{};
103   interface Taper           : NumericalFunctor{};
104   interface Skew            : NumericalFunctor{};
105   interface Area            : NumericalFunctor{};
106   interface Volume3D        : NumericalFunctor{};
107   interface Length          : NumericalFunctor{};
108   interface Length2D        : NumericalFunctor
109   {
110     struct Value
111     {
112       double myLength;
113       long myPnt1, myPnt2;
114     };
115     typedef sequence<Value> Values;
116     Values GetValues();
117   };
118   interface MultiConnection   : NumericalFunctor{};
119   interface MultiConnection2D : NumericalFunctor
120   {
121     struct Value
122     {
123       long myNbConnects;
124       long myPnt1, myPnt2;
125     };
126     
127     typedef sequence<Value> Values;
128     Values GetValues();
129   };
130
131   /*!
132   * Predicates are intended for verification of criteria,
133   *            must return bool value by mesh id
134   */
135   interface Predicate: Functor
136   {
137     boolean IsSatisfy( in long thEntityId );
138   };
139
140   /*!
141   * Logical functor (predicate) "Bad Oriented Volume".
142   * Verify whether a mesh volume is incorrectly oriented from
143   * the point of view of MED convention
144   */
145   interface BadOrientedVolume: Predicate {};
146
147   /*!
148   * Logical functor (predicate) "Belong To Geometry".
149   * Verify whether mesh element or node belong to pointed Geom Object
150   */
151   interface BelongToGeom: Predicate
152   {
153     void SetGeom( in GEOM::GEOM_Object theGeom );
154     void SetElementType( in ElementType theType );
155
156     void   SetShapeName( in string theName );
157     void   SetShape( in string theID, in string theName );
158     string GetShapeName();
159     string GetShapeID();
160   };
161
162   /*!
163   * Logical functor (predicate) "Belong To Surface".
164   * Base interface for "belong to plane" and "belong to cylinder interfaces"
165   */
166   interface BelongToSurface: Predicate
167   {
168     void   SetTolerance( in double theToler );
169     double GetTolerance();
170     void   SetShapeName( in string theName, in ElementType theType );
171     void   SetShape( in string theID, in string theName, in ElementType theType );
172     string GetShapeName();
173     string GetShapeID();
174   };
175
176
177   /*!
178   * Logical functor (predicate) "Belong To Plane".
179   * Verify whether mesh element lie in pointed Geom planar object
180   */
181   interface BelongToPlane: BelongToSurface
182   {
183     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
184   };
185
186   /*!
187   * Logical functor (predicate) "Belong To Culinder".
188   * Verify whether mesh element lie in pointed Geom cylindrical object
189   */
190   interface BelongToCylinder: BelongToSurface
191   {
192     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
193   };
194
195   /*!
196   * Logical functor (predicate) "Lying On Geometry".
197   * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
198   */
199   interface LyingOnGeom: Predicate
200   {
201     void SetGeom( in GEOM::GEOM_Object theGeom );
202     void SetElementType( in ElementType theType );
203
204     void   SetShapeName( in string theName );
205     void   SetShape( in string theID, in string theName );
206     string GetShapeName();    
207     string GetShapeID(); 
208   };
209  
210   /*!
211   * Logical functor (predicate) "Free borders".
212   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
213   */
214   interface FreeBorders: Predicate{};
215
216   /*!
217   * Logical functor (predicate) "Free edges".
218   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
219   */
220   interface FreeEdges: Predicate
221
222   {
223     struct Border
224     {
225       long myElemId;
226       long myPnt1, myPnt2;
227     };
228     typedef sequence<Border> Borders;
229     Borders GetBorders();
230   };
231
232
233   /*!
234   * Abstract logical functor (predicate) "RangeOfIds".
235   * Verify whether an Entity Id belongs to defined sequence of id's
236   */
237   interface RangeOfIds: Predicate
238   {
239     void            SetRange( in long_array theIds );
240     boolean         SetRangeStr( in string theRange );
241     string          GetRangeStr();
242
243     void            SetElementType( in ElementType theType );
244   };
245
246   /*!
247   * Comparator. Predicate for compare value calculated
248   *             by numerical functor with threshold value
249   */
250   interface Comparator: Predicate
251   {
252     void    SetMargin( in double theValue );
253     void    SetNumFunctor( in NumericalFunctor theFunct );
254     double  GetMargin();
255   };
256   interface LessThan: Comparator{};
257   interface MoreThan: Comparator{};
258   interface EqualTo : Comparator
259   {
260     void    SetTolerance( in double theToler );
261     double  GetTolerance();
262   };
263
264   /*!
265   * Logical predicates are intended for compose predicates using boolean operations
266   */
267   interface Logical: Predicate{};
268
269   interface LogicalNOT: Logical
270   {
271     void SetPredicate(in Predicate thePredicate);
272   };
273
274   interface LogicalBinary: Logical
275 {
276     void SetPredicate1( in Predicate thePredicate );
277     void SetPredicate2( in Predicate thePredicate );
278   };
279
280   interface LogicalAND: LogicalBinary{};
281   interface LogicalOR : LogicalBinary{};
282
283   /*!
284   *  Filter
285   */
286   interface Filter: SALOME::GenericObj, SMESH_IDSource
287   {
288     /*!
289     * Structure containing information about one criterion
290     *   Type          - FT_Taper, FT_Skew ...
291     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
292     *   Threshold     - threshold value
293     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
294     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
295     *                   (FT_Undefined must be for the last criterion)
296     *   ThresholdStr  - Threshold value defined as string. Used for:
297     *                   1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
298     *                   2. BelongToGeom predicate for storing name of shape
299     *   ThresholdID   - One more threshold value defined as string. Used for:
300     *                   1. BelongToGeom predicate for storing id of shape
301     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
302     *                   "Belong to plane" and "Belong to cylinder" predicates
303     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
304     *   Precision     - Precision of numerical functors
305     */
306     struct Criterion
307     {
308       long        Type;
309       long        Compare;
310       double      Threshold;
311       string      ThresholdStr;
312       string      ThresholdID;
313       long        UnaryOp;
314       long        BinaryOp;
315       double      Tolerance;
316       ElementType TypeOfElement;
317       long        Precision;
318     };
319
320     typedef sequence<Criterion> Criteria;
321
322     void          SetPredicate( in Predicate thePredicate );
323     void          SetMesh( in SMESH_Mesh theMesh );
324
325     long_array    GetElementsId( in SMESH_Mesh theMesh );
326     ElementType   GetElementType();
327     Predicate     GetPredicate();
328
329     boolean       GetCriteria( out Criteria theCriteria );
330     boolean       SetCriteria( in Criteria theCriteria );
331   };
332
333
334   /*!
335   *  Interface for working with library of filters
336   */
337   interface FilterLibrary : SALOME::GenericObj
338   {
339     /*!
340     *  Copy filter from library by name (new filter is created)
341     */
342     Filter        Copy( in string theFilterName );
343
344     /*!
345     * Methods for editing library
346     */
347     boolean       Add     ( in string theFilterName, in Filter theFilter );
348     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
349     boolean       Delete  ( in string theFilterName );
350     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
351
352     /*!
353     *  Save library on disk
354     */
355     boolean       Save();
356     boolean       SaveAs( in string aFileName );
357
358     /*!
359     * Query methods
360     */
361     boolean       IsPresent( in string aFilterName );
362     long          NbFilters( in ElementType aType );
363     string_array  GetNames( in ElementType aType );
364     string_array  GetAllNames();
365     void          SetFileName( in string aFilterName );
366     string        GetFileName();
367   };
368
369
370   /*!
371   * Interface of Filter manager
372   */
373   interface FilterManager: SALOME::GenericObj
374   {
375     /*!
376     *  Create numerical functors
377     */
378     MinimumAngle      CreateMinimumAngle();
379     AspectRatio       CreateAspectRatio();
380     AspectRatio3D     CreateAspectRatio3D();
381     Warping           CreateWarping();
382     Taper             CreateTaper();
383     Skew              CreateSkew();
384     Area              CreateArea();
385     Volume3D          CreateVolume3D();
386     Length            CreateLength();
387     Length2D          CreateLength2D();
388     MultiConnection   CreateMultiConnection();
389     MultiConnection2D CreateMultiConnection2D();
390
391     /*!
392     *  Create logical functors ( predicates )
393     */
394     BelongToGeom      CreateBelongToGeom();
395     BelongToPlane     CreateBelongToPlane();
396     BelongToCylinder  CreateBelongToCylinder();
397
398     LyingOnGeom       CreateLyingOnGeom();
399
400     FreeBorders       CreateFreeBorders();
401     FreeEdges         CreateFreeEdges();
402
403     RangeOfIds        CreateRangeOfIds();
404
405     BadOrientedVolume CreateBadOrientedVolume();
406
407     /*!
408     *  Create comparators ( predicates )
409     */
410     LessThan          CreateLessThan();
411     MoreThan          CreateMoreThan();
412     EqualTo           CreateEqualTo();
413
414     /*!
415     *  Create boolean operations ( predicates )
416     */
417     LogicalNOT        CreateLogicalNOT();
418     LogicalAND        CreateLogicalAND();
419     LogicalOR         CreateLogicalOR();
420
421     /*!
422     *  Create filter
423     */
424     Filter            CreateFilter();
425
426     /*!
427     *  Load filter library. If libary does not exist it is created
428     */
429     FilterLibrary     LoadLibrary( in string aFileName );
430
431     /*!
432     *  Create new library
433     */
434     FilterLibrary     CreateLibrary();
435
436     /*!
437     *  Delete library
438     */
439     boolean           DeleteLibrary( in string aFileName );
440   };
441 };
442
443
444 #endif