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