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