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