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