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