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