Salome HOME
d6cfc5ed86e515fcc23459038e1b7eecbb2808ad
[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_Length,
58     FT_Length2D,
59     FT_BelongToGeom,
60     FT_BelongToPlane,
61     FT_BelongToCylinder,
62     FT_RangeOfIds,
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 Length          : NumericalFunctor{};
106   interface Length2D        : NumericalFunctor
107   {
108     struct Value
109     {
110       double myLength;
111       long myElemId;
112       long myPnt1, myPnt2;
113     };
114     typedef sequence<Value> Values;
115     Values GetValues();
116   };
117   interface MultiConnection : NumericalFunctor{};
118
119   /*!
120   * Predicates are intended for verification of criteria,
121   *            must return bool value by mesh id
122   */
123   interface Predicate: Functor
124   {
125     boolean IsSatisfy( in long thEntityId );
126   };
127
128   /*!
129   * Logical functor (predicate) "Belong To Geometry".
130   * Verify whether mesh element or node belong to pointed Geom Object
131   */
132   interface BelongToGeom: Predicate
133   {
134     void SetGeom( in GEOM::GEOM_Object theGeom );
135     void SetElementType( in ElementType theType );
136
137     void   SetShapeName( in string theName );
138     string GetShapeName();    
139   };
140
141   /*!
142   * Logical functor (predicate) "Belong To Surface".
143   * Base interface for "belong to plane" and "belong to cylinder interfaces"
144   */
145   interface BelongToSurface: Predicate
146   {
147     void   SetTolerance( in double theToler );
148     double GetTolerance();
149     void   SetShapeName( in string theName, in ElementType theType );
150     string GetShapeName();
151   };
152
153
154   /*!
155   * Logical functor (predicate) "Belong To Plane".
156   * Verify whether mesh element lie in pointed Geom planar object
157   */
158   interface BelongToPlane: BelongToSurface
159   {
160     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
161   };
162
163   /*!
164   * Logical functor (predicate) "Belong To Culinder".
165   * Verify whether mesh element lie in pointed Geom cylindrical object
166   */
167   interface BelongToCylinder: BelongToSurface
168   {
169     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
170   };
171
172   /*!
173   * Logical functor (predicate) "Free borders".
174   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
175   */
176   interface FreeBorders: Predicate{};
177
178   /*!
179   * Logical functor (predicate) "Free edges".
180   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
181   */
182   interface FreeEdges: Predicate
183
184   {
185     struct Border
186     {
187       long myElemId;
188       long myPnt1, myPnt2;
189     };
190     typedef sequence<Border> Borders;
191     Borders GetBorders();
192   };
193
194
195   /*!
196   * Abstract logical functor (predicate) "RangeOfIds".
197   * Verify whether an Entity Id belongs to defined sequence of id's
198   */
199   interface RangeOfIds: Predicate
200   {
201     void            SetRange( in long_array theIds );
202     boolean         SetRangeStr( in string theRange );
203     string          GetRangeStr();
204
205     void            SetElementType( in ElementType theType );
206   };
207
208   /*!
209   * Comparator. Predicate for compare value calculated
210   *             by numerical functor with threshold value
211   */
212   interface Comparator: Predicate
213   {
214     void    SetMargin( in double theValue );
215     void    SetNumFunctor( in NumericalFunctor theFunct );
216     double  GetMargin();
217   };
218   interface LessThan: Comparator{};
219   interface MoreThan: Comparator{};
220   interface EqualTo : Comparator
221   {
222     void    SetTolerance( in double theToler );
223     double  GetTolerance();
224   };
225
226   /*!
227   * Logical predicates are intended for compose predicates using boolean operations
228   */
229   interface Logical: Predicate{};
230
231   interface LogicalNOT: Logical
232   {
233     void SetPredicate(in Predicate thePredicate);
234   };
235
236   interface LogicalBinary: Logical
237 {
238     void SetPredicate1( in Predicate thePredicate );
239     void SetPredicate2( in Predicate thePredicate );
240   };
241
242   interface LogicalAND: LogicalBinary{};
243   interface LogicalOR : LogicalBinary{};
244
245   /*!
246   *  Filter
247   */
248   interface Filter: SALOME::GenericObj
249   {
250     /*!
251     * Structure containing information about one criterion
252     *   Type          - FT_Taper, FT_Skew ...
253     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
254     *   Threshold     - threshold value
255     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
256     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
257     *                   (FT_Undefined must be for the last criterion)
258     *   ThresholdStr  - Threshold value defined as string. Used for:
259     *                   1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
260     *                   2. BelongToGeom predicate for storing name of shape
261     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
262     *                   "Belong to plane" and "Belong to cylinder" predicates
263     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
264     *   Precision     - Precision of numerical functors
265     */
266     struct Criterion
267     {
268       long        Type;
269       long        Compare;
270       double      Threshold;
271       string      ThresholdStr;
272       long        UnaryOp;
273       long        BinaryOp;
274       double      Tolerance;
275       ElementType TypeOfElement;
276       long        Precision;
277     };
278
279     typedef sequence<Criterion> Criteria;
280
281     void          SetPredicate( in Predicate thePredicate );
282     long_array    GetElementsId( in SMESH_Mesh theMesh );
283     ElementType   GetElementType();
284     Predicate     GetPredicate();
285
286     boolean       GetCriteria( out Criteria theCriteria );
287     boolean       SetCriteria( in Criteria theCriteria );
288   };
289
290
291   /*!
292   *  Interface for working with library of filters
293   */
294   interface FilterLibrary : SALOME::GenericObj
295   {
296     /*!
297     *  Copy filter from library by name (new filter is created)
298     */
299     Filter        Copy( in string theFilterName );
300
301     /*!
302     * Methods for editing library
303     */
304     boolean       Add     ( in string theFilterName, in Filter theFilter );
305     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
306     boolean       Delete  ( in string theFilterName );
307     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
308
309     /*!
310     *  Save library on disk
311     */
312     boolean       Save();
313     boolean       SaveAs( in string aFileName );
314
315     /*!
316     * Query methods
317     */
318     boolean       IsPresent( in string aFilterName );
319     long          NbFilters( in ElementType aType );
320     string_array  GetNames( in ElementType aType );
321     string_array  GetAllNames();
322     void          SetFileName( in string aFilterName );
323     string        GetFileName();
324   };
325
326
327   /*!
328   * Interface of Filter manager
329   */
330   interface FilterManager: SALOME::GenericObj
331   {
332     /*!
333     *  Create numerical functors
334     */
335     MinimumAngle      CreateMinimumAngle();
336     AspectRatio       CreateAspectRatio();
337     AspectRatio3D     CreateAspectRatio3D();
338     Warping           CreateWarping();
339     Taper             CreateTaper();
340     Skew              CreateSkew();
341     Area              CreateArea();
342     Length            CreateLength();
343     Length2D          CreateLength2D();
344     MultiConnection   CreateMultiConnection();
345
346     /*!
347     *  Create logical functors ( predicates )
348     */
349     BelongToGeom      CreateBelongToGeom();
350     BelongToPlane     CreateBelongToPlane();
351     BelongToCylinder  CreateBelongToCylinder();
352
353     FreeBorders       CreateFreeBorders();
354     FreeEdges         CreateFreeEdges();
355
356     RangeOfIds        CreateRangeOfIds();
357
358     /*!
359     *  Create comparators ( predicates )
360     */
361     LessThan          CreateLessThan();
362     MoreThan          CreateMoreThan();
363     EqualTo           CreateEqualTo();
364
365     /*!
366     *  Create boolean operations ( predicates )
367     */
368     LogicalNOT        CreateLogicalNOT();
369     LogicalAND        CreateLogicalAND();
370     LogicalOR         CreateLogicalOR();
371
372     /*!
373     *  Create filter
374     */
375     Filter            CreateFilter();
376
377     /*!
378     *  Load filter library. If libary does not exist it is created
379     */
380     FilterLibrary     LoadLibrary( in string aFileName );
381
382     /*!
383     *  Create new library
384     */
385     FilterLibrary     CreateLibrary();
386
387     /*!
388     *  Delete library
389     */
390     boolean           DeleteLibrary( in string aFileName );
391   };
392 };
393
394
395 #endif