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