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