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