Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / idl / SMESH_Filter.idl
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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_FreeFaces,
53     FT_MultiConnection,
54     FT_MultiConnection2D,
55     FT_Length,
56     FT_Length2D,
57     FT_BelongToGeom,
58     FT_BelongToPlane,
59     FT_BelongToCylinder,
60     FT_BelongToGenSurface,
61     FT_LyingOnGeom,
62     FT_RangeOfIds,
63     FT_BadOrientedVolume,
64     FT_LinearOrQuadratic,
65     FT_GroupColor,
66     FT_ElemGeomType,
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     /*! The tolerance is used only if there is no submesh on the shape
160      */
161     void    SetTolerance( in double theToler );
162     double  GetTolerance();
163
164     void   SetShapeName( in string theName );
165     void   SetShape( in string theID, in string theName );
166     string GetShapeName();
167     string GetShapeID();
168   };
169
170   /*!
171   * Logical functor (predicate) "Belong To Surface".
172   * Base interface for "belong to plane" and "belong to cylinder"
173   * and "Belong To Generic Surface" interfaces
174   */
175   interface BelongToSurface: Predicate
176   {
177     void    SetTolerance( in double theToler );
178     double  GetTolerance();
179     void    SetShapeName( in string theName, in ElementType theType );
180     void    SetShape( in string theID, in string theName, in ElementType theType );
181     string  GetShapeName();
182     string  GetShapeID();
183     /*!
184     * Limit surface extent to bounding box of boundaries (edges)
185     * in surface parametric space. Boundaries are ignored by default
186     */
187     void    SetUseBoundaries( in boolean theUseBndRestrictions );
188     boolean GetUseBoundaries();
189   };
190
191   /*!
192   * Logical functor (predicate) "Belong To Plane".
193   * Verify whether mesh element lie on pointed Geom planar object
194   */
195   interface BelongToPlane: BelongToSurface
196   {
197     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
198   };
199
200   /*!
201   * Logical functor (predicate) "Belong To Cylinder".
202   * Verify whether mesh element lie on pointed Geom cylindrical object
203   */
204   interface BelongToCylinder: BelongToSurface
205   {
206     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
207   };
208
209   /*!
210   * Logical functor (predicate) "Belong To Generic Surface".
211   * Verify whether mesh element lie in pointed Geom cylindrical object
212   */
213   interface BelongToGenSurface: BelongToSurface
214   {
215     void   SetSurface( in GEOM::GEOM_Object theGeom, in ElementType theType );
216   };
217
218   /*!
219   * Logical functor (predicate) "Lying On Geometry".
220   * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
221   */
222   interface LyingOnGeom: Predicate
223   {
224     void SetGeom( in GEOM::GEOM_Object theGeom );
225     void SetElementType( in ElementType theType );
226
227     /*! The tolerance is used only if there is no submesh on the shape
228      */
229     void    SetTolerance( in double theToler );
230     double  GetTolerance();
231
232     void   SetShapeName( in string theName );
233     void   SetShape( in string theID, in string theName );
234     string GetShapeName();    
235     string GetShapeID(); 
236   };
237  
238   /*!
239   * Logical functor (predicate) "Free borders".
240   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
241   */
242   interface FreeBorders: Predicate{};
243
244   /*!
245   * Logical functor (predicate) "Free edges".
246   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
247   */
248   interface FreeEdges: Predicate
249   {
250     struct Border
251     {
252       long myElemId;
253       long myPnt1, myPnt2;
254     };
255     typedef sequence<Border> Borders;
256     Borders GetBorders();
257   };
258
259   /*!
260   * Logical functor (predicate) "Free nodes".
261   * Verify whether mesh has free nodes( i.e. nodes are not connected to any element )
262   */
263   interface FreeNodes: Predicate{};
264  
265   /*!
266   * Logical functor (predicate) "Free faces".
267   * Verify whether 2D mesh element is free ( i.e. connected to one volume only )
268   */
269   interface FreeFaces: Predicate{};
270
271   /*!
272   * Abstract logical functor (predicate) "RangeOfIds".
273   * Verify whether an Entity Id belongs to defined sequence of id's
274   */
275   interface RangeOfIds: Predicate
276   {
277     void            SetRange( in long_array theIds );
278     boolean         SetRangeStr( in string theRange );
279     string          GetRangeStr();
280
281     void            SetElementType( in ElementType theType );
282   };
283
284   /*!
285   * Comparator. Predicate for compare value calculated
286   *             by numerical functor with threshold value
287   */
288   interface Comparator: Predicate
289   {
290     void    SetMargin( in double theValue );
291     void    SetNumFunctor( in NumericalFunctor theFunct );
292     double  GetMargin();
293   };
294   interface LessThan: Comparator{};
295   interface MoreThan: Comparator{};
296   interface EqualTo : Comparator
297   {
298     void    SetTolerance( in double theToler );
299     double  GetTolerance();
300   };
301
302   /*!
303   * Logical predicates are intended for compose predicates using boolean operations
304   */
305   interface Logical: Predicate{};
306
307   interface LogicalNOT: Logical
308   {
309     void SetPredicate(in Predicate thePredicate);
310   };
311
312   interface LogicalBinary: Logical
313 {
314     void SetPredicate1( in Predicate thePredicate );
315     void SetPredicate2( in Predicate thePredicate );
316   };
317
318   interface LogicalAND: LogicalBinary{};
319   interface LogicalOR : LogicalBinary{};
320
321   /*!
322    * Logical functor (predicate) "Is element Linear or Quadratic".
323    * Verify whether a mesh element is linear
324    */
325   interface LinearOrQuadratic: Predicate {
326     void            SetElementType( in ElementType theType );
327   };
328
329   /*!
330   * Functor "Group Color"
331   * Returns color of group to which mesh element belongs to
332   */
333   interface GroupColor : Predicate{
334     void            SetElementType( in ElementType theType );
335     void            SetColorStr( in string theColor );
336     string          GetColorStr();
337   };
338
339   /*!
340   * Functor "Element geometry type"
341   * Returns is element has indicated geometry type
342   */
343   interface ElemGeomType : Predicate{
344     void            SetElementType ( in ElementType  theType );
345     void            SetGeometryType( in GeometryType theType );
346   };
347
348   /*!
349   *  Filter
350   */
351   interface Filter: SALOME::GenericObj, SMESH_IDSource
352   {
353     /*!
354     * Structure containing information about one criterion
355     *   Type          - FT_Taper, FT_Skew ...
356     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
357     *   Threshold     - threshold value
358     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
359     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
360     *                   (FT_Undefined must be for the last criterion)
361     *   ThresholdStr  - Threshold value defined as string. Used for:
362     *                   1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
363     *                   2. BelongToGeom predicate for storing name of shape
364     *                   3. GroupColor predicate for storing group color "0.2;0;0.5"
365     *   ThresholdID   - One more threshold value defined as string. Used for:
366     *                   1. BelongToGeom predicate for storing id of shape
367     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
368     *                   "Belong to plane" and "Belong to cylinder" predicates
369     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
370     *   Precision     - Precision of numerical functors
371     */
372     struct Criterion
373     {
374       long        Type;
375       long        Compare;
376       double      Threshold;
377       string      ThresholdStr;
378       string      ThresholdID;
379       long        UnaryOp;
380       long        BinaryOp;
381       double      Tolerance;
382       ElementType TypeOfElement;
383       long        Precision;
384     };
385
386     typedef sequence<Criterion> Criteria;
387
388     void          SetPredicate( in Predicate thePredicate );
389     void          SetMesh( in SMESH_Mesh theMesh );
390
391     long_array    GetElementsId( in SMESH_Mesh theMesh );
392     ElementType   GetElementType();
393     Predicate     GetPredicate();
394
395     boolean       GetCriteria( out Criteria theCriteria );
396     boolean       SetCriteria( in Criteria theCriteria );
397   };
398
399
400   /*!
401   *  Interface for working with library of filters
402   */
403   interface FilterLibrary : SALOME::GenericObj
404   {
405     /*!
406     *  Copy filter from library by name (new filter is created)
407     */
408     Filter        Copy( in string theFilterName );
409
410     /*!
411     * Methods for editing library
412     */
413     boolean       Add     ( in string theFilterName, in Filter theFilter );
414     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
415     boolean       Delete  ( in string theFilterName );
416     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
417
418     /*!
419     *  Save library on disk
420     */
421     boolean       Save();
422     boolean       SaveAs( in string aFileName );
423
424     /*!
425     * Query methods
426     */
427     boolean       IsPresent( in string aFilterName );
428     long          NbFilters( in ElementType aType );
429     string_array  GetNames( in ElementType aType );
430     string_array  GetAllNames();
431     void          SetFileName( in string aFilterName );
432     string        GetFileName();
433   };
434
435
436   /*!
437   * Interface of Filter manager
438   */
439   interface FilterManager: SALOME::GenericObj
440   {
441     /*!
442     *  Create numerical functors
443     */
444     MinimumAngle      CreateMinimumAngle();
445     AspectRatio       CreateAspectRatio();
446     AspectRatio3D     CreateAspectRatio3D();
447     Warping           CreateWarping();
448     Taper             CreateTaper();
449     Skew              CreateSkew();
450     Area              CreateArea();
451     Volume3D          CreateVolume3D();
452     Length            CreateLength();
453     Length2D          CreateLength2D();
454     MultiConnection   CreateMultiConnection();
455     MultiConnection2D CreateMultiConnection2D();
456
457     /*!
458     *  Create logical functors ( predicates )
459     */
460     BelongToGeom      CreateBelongToGeom();
461     BelongToPlane     CreateBelongToPlane();
462     BelongToCylinder  CreateBelongToCylinder();
463     BelongToGenSurface CreateBelongToGenSurface();
464
465     LyingOnGeom       CreateLyingOnGeom();
466
467     FreeBorders       CreateFreeBorders();
468     FreeEdges         CreateFreeEdges();
469     FreeNodes         CreateFreeNodes();
470     FreeFaces         CreateFreeFaces();
471
472     RangeOfIds        CreateRangeOfIds();
473
474     BadOrientedVolume CreateBadOrientedVolume();
475     LinearOrQuadratic CreateLinearOrQuadratic();
476
477     GroupColor        CreateGroupColor();
478     ElemGeomType      CreateElemGeomType();
479
480     /*!
481     *  Create comparators ( predicates )
482     */
483     LessThan          CreateLessThan();
484     MoreThan          CreateMoreThan();
485     EqualTo           CreateEqualTo();
486
487     /*!
488     *  Create boolean operations ( predicates )
489     */
490     LogicalNOT        CreateLogicalNOT();
491     LogicalAND        CreateLogicalAND();
492     LogicalOR         CreateLogicalOR();
493
494     /*!
495     *  Create filter
496     */
497     Filter            CreateFilter();
498
499     /*!
500     *  Load filter library. If libary does not exist it is created
501     */
502     FilterLibrary     LoadLibrary( in string aFileName );
503
504     /*!
505     *  Create new library
506     */
507     FilterLibrary     CreateLibrary();
508
509     /*!
510     *  Delete library
511     */
512     boolean           DeleteLibrary( in string aFileName );
513   };
514 };
515
516
517 #endif