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