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