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