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