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