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