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