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