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