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