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