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