Salome HOME
Fix for improvement 0019927 (EDF770 SMESH: Analyzing the Mesh Quality: Orphan nodes...
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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_FreeNodes,
52     FT_MultiConnection,
53     FT_MultiConnection2D,
54     FT_Length,
55     FT_Length2D,
56     FT_BelongToGeom,
57     FT_BelongToPlane,
58     FT_BelongToCylinder,
59     FT_BelongToGenSurface,
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     /*! The tolerance is used only if there is no submesh on the shape
156      */
157     void    SetTolerance( in double theToler );
158     double  GetTolerance();
159
160     void   SetShapeName( in string theName );
161     void   SetShape( in string theID, in string theName );
162     string GetShapeName();
163     string GetShapeID();
164   };
165
166   /*!
167   * Logical functor (predicate) "Belong To Surface".
168   * Base interface for "belong to plane" and "belong to cylinder"
169   * and "Belong To Generic Surface" interfaces
170   */
171   interface BelongToSurface: Predicate
172   {
173     void    SetTolerance( in double theToler );
174     double  GetTolerance();
175     void    SetShapeName( in string theName, in ElementType theType );
176     void    SetShape( in string theID, in string theName, in ElementType theType );
177     string  GetShapeName();
178     string  GetShapeID();
179     /*!
180     * Limit surface extent to bounding box of boundaries (edges)
181     * in surface parametric space. Boundaries are ignored by default
182     */
183     void    SetUseBoundaries( in boolean theUseBndRestrictions );
184     boolean GetUseBoundaries();
185   };
186
187   /*!
188   * Logical functor (predicate) "Belong To Plane".
189   * Verify whether mesh element lie on pointed Geom planar object
190   */
191   interface BelongToPlane: BelongToSurface
192   {
193     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
194   };
195
196   /*!
197   * Logical functor (predicate) "Belong To Cylinder".
198   * Verify whether mesh element lie on pointed Geom cylindrical object
199   */
200   interface BelongToCylinder: BelongToSurface
201   {
202     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
203   };
204
205   /*!
206   * Logical functor (predicate) "Belong To Generic Surface".
207   * Verify whether mesh element lie in pointed Geom cylindrical object
208   */
209   interface BelongToGenSurface: BelongToSurface
210   {
211     void   SetSurface( in GEOM::GEOM_Object theGeom, in ElementType theType );
212   };
213
214   /*!
215   * Logical functor (predicate) "Lying On Geometry".
216   * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
217   */
218   interface LyingOnGeom: Predicate
219   {
220     void SetGeom( in GEOM::GEOM_Object theGeom );
221     void SetElementType( in ElementType theType );
222
223     /*! The tolerance is used only if there is no submesh on the shape
224      */
225     void    SetTolerance( in double theToler );
226     double  GetTolerance();
227
228     void   SetShapeName( in string theName );
229     void   SetShape( in string theID, in string theName );
230     string GetShapeName();    
231     string GetShapeID(); 
232   };
233  
234   /*!
235   * Logical functor (predicate) "Free borders".
236   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
237   */
238   interface FreeBorders: Predicate{};
239
240   /*!
241   * Logical functor (predicate) "Free edges".
242   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
243   */
244   interface FreeEdges: Predicate
245   {
246     struct Border
247     {
248       long myElemId;
249       long myPnt1, myPnt2;
250     };
251     typedef sequence<Border> Borders;
252     Borders GetBorders();
253   };
254
255   /*!
256   * Logical functor (predicate) "Free nodes".
257   * Verify whether mesh has free nodes( i.e. nodes are not connected to any element )
258   */
259   interface FreeNodes: Predicate{};
260  
261   /*!
262   * Abstract logical functor (predicate) "RangeOfIds".
263   * Verify whether an Entity Id belongs to defined sequence of id's
264   */
265   interface RangeOfIds: Predicate
266   {
267     void            SetRange( in long_array theIds );
268     boolean         SetRangeStr( in string theRange );
269     string          GetRangeStr();
270
271     void            SetElementType( in ElementType theType );
272   };
273
274   /*!
275   * Comparator. Predicate for compare value calculated
276   *             by numerical functor with threshold value
277   */
278   interface Comparator: Predicate
279   {
280     void    SetMargin( in double theValue );
281     void    SetNumFunctor( in NumericalFunctor theFunct );
282     double  GetMargin();
283   };
284   interface LessThan: Comparator{};
285   interface MoreThan: Comparator{};
286   interface EqualTo : Comparator
287   {
288     void    SetTolerance( in double theToler );
289     double  GetTolerance();
290   };
291
292   /*!
293   * Logical predicates are intended for compose predicates using boolean operations
294   */
295   interface Logical: Predicate{};
296
297   interface LogicalNOT: Logical
298   {
299     void SetPredicate(in Predicate thePredicate);
300   };
301
302   interface LogicalBinary: Logical
303 {
304     void SetPredicate1( in Predicate thePredicate );
305     void SetPredicate2( in Predicate thePredicate );
306   };
307
308   interface LogicalAND: LogicalBinary{};
309   interface LogicalOR : LogicalBinary{};
310
311   /*!
312   *  Filter
313   */
314   interface Filter: SALOME::GenericObj, SMESH_IDSource
315   {
316     /*!
317     * Structure containing information about one criterion
318     *   Type          - FT_Taper, FT_Skew ...
319     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
320     *   Threshold     - threshold value
321     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
322     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
323     *                   (FT_Undefined must be for the last criterion)
324     *   ThresholdStr  - Threshold value defined as string. Used for:
325     *                   1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
326     *                   2. BelongToGeom predicate for storing name of shape
327     *   ThresholdID   - One more threshold value defined as string. Used for:
328     *                   1. BelongToGeom predicate for storing id of shape
329     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
330     *                   "Belong to plane" and "Belong to cylinder" predicates
331     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
332     *   Precision     - Precision of numerical functors
333     */
334     struct Criterion
335     {
336       long        Type;
337       long        Compare;
338       double      Threshold;
339       string      ThresholdStr;
340       string      ThresholdID;
341       long        UnaryOp;
342       long        BinaryOp;
343       double      Tolerance;
344       ElementType TypeOfElement;
345       long        Precision;
346     };
347
348     typedef sequence<Criterion> Criteria;
349
350     void          SetPredicate( in Predicate thePredicate );
351     void          SetMesh( in SMESH_Mesh theMesh );
352
353     long_array    GetElementsId( in SMESH_Mesh theMesh );
354     ElementType   GetElementType();
355     Predicate     GetPredicate();
356
357     boolean       GetCriteria( out Criteria theCriteria );
358     boolean       SetCriteria( in Criteria theCriteria );
359   };
360
361
362   /*!
363   *  Interface for working with library of filters
364   */
365   interface FilterLibrary : SALOME::GenericObj
366   {
367     /*!
368     *  Copy filter from library by name (new filter is created)
369     */
370     Filter        Copy( in string theFilterName );
371
372     /*!
373     * Methods for editing library
374     */
375     boolean       Add     ( in string theFilterName, in Filter theFilter );
376     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
377     boolean       Delete  ( in string theFilterName );
378     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
379
380     /*!
381     *  Save library on disk
382     */
383     boolean       Save();
384     boolean       SaveAs( in string aFileName );
385
386     /*!
387     * Query methods
388     */
389     boolean       IsPresent( in string aFilterName );
390     long          NbFilters( in ElementType aType );
391     string_array  GetNames( in ElementType aType );
392     string_array  GetAllNames();
393     void          SetFileName( in string aFilterName );
394     string        GetFileName();
395   };
396
397
398   /*!
399   * Interface of Filter manager
400   */
401   interface FilterManager: SALOME::GenericObj
402   {
403     /*!
404     *  Create numerical functors
405     */
406     MinimumAngle      CreateMinimumAngle();
407     AspectRatio       CreateAspectRatio();
408     AspectRatio3D     CreateAspectRatio3D();
409     Warping           CreateWarping();
410     Taper             CreateTaper();
411     Skew              CreateSkew();
412     Area              CreateArea();
413     Volume3D          CreateVolume3D();
414     Length            CreateLength();
415     Length2D          CreateLength2D();
416     MultiConnection   CreateMultiConnection();
417     MultiConnection2D CreateMultiConnection2D();
418
419     /*!
420     *  Create logical functors ( predicates )
421     */
422     BelongToGeom      CreateBelongToGeom();
423     BelongToPlane     CreateBelongToPlane();
424     BelongToCylinder  CreateBelongToCylinder();
425     BelongToGenSurface CreateBelongToGenSurface();
426
427     LyingOnGeom       CreateLyingOnGeom();
428
429     FreeBorders       CreateFreeBorders();
430     FreeEdges         CreateFreeEdges();
431     FreeNodes         CreateFreeNodes();
432
433     RangeOfIds        CreateRangeOfIds();
434
435     BadOrientedVolume CreateBadOrientedVolume();
436
437     /*!
438     *  Create comparators ( predicates )
439     */
440     LessThan          CreateLessThan();
441     MoreThan          CreateMoreThan();
442     EqualTo           CreateEqualTo();
443
444     /*!
445     *  Create boolean operations ( predicates )
446     */
447     LogicalNOT        CreateLogicalNOT();
448     LogicalAND        CreateLogicalAND();
449     LogicalOR         CreateLogicalOR();
450
451     /*!
452     *  Create filter
453     */
454     Filter            CreateFilter();
455
456     /*!
457     *  Load filter library. If libary does not exist it is created
458     */
459     FilterLibrary     LoadLibrary( in string aFileName );
460
461     /*!
462     *  Create new library
463     */
464     FilterLibrary     CreateLibrary();
465
466     /*!
467     *  Delete library
468     */
469     boolean           DeleteLibrary( in string aFileName );
470   };
471 };
472
473
474 #endif