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