Salome HOME
0020222: Quandrangle_2D meshing fail
[modules/smesh.git] / idl / SMESH_Filter.idl
1 //  Copyright (C) 2007-2008  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 //  File   : SMESH_Filter.idl
23 //  Author : Alexey Petrov, OCC
24 //
25 #ifndef _SMESH_FILTER_IDL_
26 #define _SMESH_FILTER_IDL_
27
28 #include "SALOME_Exception.idl"
29 #include "SALOME_GenericObj.idl"
30 #include "GEOM_Gen.idl"
31 #include "SMESH_Mesh.idl"
32
33 module SMESH
34 {
35
36   /*!
37   * Enumeration of functor types
38   */
39   enum FunctorType
40   {
41     FT_AspectRatio,
42     FT_AspectRatio3D,
43     FT_Warping,   
44     FT_MinimumAngle,
45     FT_Taper,       
46     FT_Skew,         
47     FT_Area,          
48     FT_Volume3D,          
49     FT_FreeBorders,
50     FT_FreeEdges,
51     FT_MultiConnection,
52     FT_MultiConnection2D,
53     FT_Length,
54     FT_Length2D,
55     FT_BelongToGeom,
56     FT_BelongToPlane,
57     FT_BelongToCylinder,
58     FT_BelongToGenSurface,
59     FT_LyingOnGeom,
60     FT_RangeOfIds,
61     FT_BadOrientedVolume,
62     FT_LessThan,
63     FT_MoreThan,
64     FT_EqualTo,
65     FT_LogicalNOT,
66     FT_LogicalAND,
67     FT_LogicalOR,
68     FT_Undefined
69   };
70
71   /*!
72   * Base interface for all functors ( i.e. numerical functors and predicates )
73   */
74   interface Functor: SALOME::GenericObj
75   {
76     void            SetMesh( in SMESH_Mesh theMesh );
77     FunctorType     GetFunctorType();
78     ElementType     GetElementType();
79   };
80
81
82
83   /*!
84   * Numerical functors are intended for calculating value by Id of mesh entity
85   */
86   interface NumericalFunctor: Functor
87   {
88     double GetValue( in long theElementId );
89
90     /*!
91     * Set precision for calculation. It is a position after point which is
92     * used to functor value after calculation.
93     */
94     void   SetPrecision( in long thePrecision );
95     long   GetPrecision();
96   };
97   interface MinimumAngle    : NumericalFunctor{};
98   interface AspectRatio     : NumericalFunctor{};
99   interface AspectRatio3D   : NumericalFunctor{};
100   interface Warping         : NumericalFunctor{};
101   interface Taper           : NumericalFunctor{};
102   interface Skew            : NumericalFunctor{};
103   interface Area            : NumericalFunctor{};
104   interface Volume3D        : NumericalFunctor{};
105   interface Length          : NumericalFunctor{};
106   interface Length2D        : NumericalFunctor
107   {
108     struct Value
109     {
110       double myLength;
111       long myPnt1, myPnt2;
112     };
113     typedef sequence<Value> Values;
114     Values GetValues();
115   };
116   interface MultiConnection   : NumericalFunctor{};
117   interface MultiConnection2D : NumericalFunctor
118   {
119     struct Value
120     {
121       long myNbConnects;
122       long myPnt1, myPnt2;
123     };
124     
125     typedef sequence<Value> Values;
126     Values GetValues();
127   };
128
129   /*!
130   * Predicates are intended for verification of criteria,
131   *            must return bool value by mesh id
132   */
133   interface Predicate: Functor
134   {
135     boolean IsSatisfy( in long thEntityId );
136   };
137
138   /*!
139   * Logical functor (predicate) "Bad Oriented Volume".
140   * Verify whether a mesh volume is incorrectly oriented from
141   * the point of view of MED convention
142   */
143   interface BadOrientedVolume: Predicate {};
144
145   /*!
146   * Logical functor (predicate) "Belong To Geometry".
147   * Verify whether mesh element or node belong to pointed Geom Object
148   */
149   interface BelongToGeom: Predicate
150   {
151     void SetGeom( in GEOM::GEOM_Object theGeom );
152     void SetElementType( in ElementType theType );
153
154     /*! The tolerance is used only if there is no submesh on the shape
155      */
156     void    SetTolerance( in double theToler );
157     double  GetTolerance();
158
159     void   SetShapeName( in string theName );
160     void   SetShape( in string theID, in string theName );
161     string GetShapeName();
162     string GetShapeID();
163   };
164
165   /*!
166   * Logical functor (predicate) "Belong To Surface".
167   * Base interface for "belong to plane" and "belong to cylinder"
168   * and "Belong To Generic Surface" interfaces
169   */
170   interface BelongToSurface: Predicate
171   {
172     void    SetTolerance( in double theToler );
173     double  GetTolerance();
174     void    SetShapeName( in string theName, in ElementType theType );
175     void    SetShape( in string theID, in string theName, in ElementType theType );
176     string  GetShapeName();
177     string  GetShapeID();
178     /*!
179     * Limit surface extent to bounding box of boundaries (edges)
180     * in surface parametric space. Boundaries are ignored by default
181     */
182     void    SetUseBoundaries( in boolean theUseBndRestrictions );
183     boolean GetUseBoundaries();
184   };
185
186   /*!
187   * Logical functor (predicate) "Belong To Plane".
188   * Verify whether mesh element lie on pointed Geom planar object
189   */
190   interface BelongToPlane: BelongToSurface
191   {
192     void   SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
193   };
194
195   /*!
196   * Logical functor (predicate) "Belong To Cylinder".
197   * Verify whether mesh element lie on pointed Geom cylindrical object
198   */
199   interface BelongToCylinder: BelongToSurface
200   {
201     void   SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
202   };
203
204   /*!
205   * Logical functor (predicate) "Belong To Generic Surface".
206   * Verify whether mesh element lie in pointed Geom cylindrical object
207   */
208   interface BelongToGenSurface: BelongToSurface
209   {
210     void   SetSurface( in GEOM::GEOM_Object theGeom, in ElementType theType );
211   };
212
213   /*!
214   * Logical functor (predicate) "Lying On Geometry".
215   * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
216   */
217   interface LyingOnGeom: Predicate
218   {
219     void SetGeom( in GEOM::GEOM_Object theGeom );
220     void SetElementType( in ElementType theType );
221
222     /*! The tolerance is used only if there is no submesh on the shape
223      */
224     void    SetTolerance( in double theToler );
225     double  GetTolerance();
226
227     void   SetShapeName( in string theName );
228     void   SetShape( in string theID, in string theName );
229     string GetShapeName();    
230     string GetShapeID(); 
231   };
232  
233   /*!
234   * Logical functor (predicate) "Free borders".
235   * Verify whether 1D mesh element is free ( i.e. connected to one face only )
236   */
237   interface FreeBorders: Predicate{};
238
239   /*!
240   * Logical functor (predicate) "Free edges".
241   * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
242   */
243   interface FreeEdges: Predicate
244
245   {
246     struct Border
247     {
248       long myElemId;
249       long myPnt1, myPnt2;
250     };
251     typedef sequence<Border> Borders;
252     Borders GetBorders();
253   };
254
255
256   /*!
257   * Abstract logical functor (predicate) "RangeOfIds".
258   * Verify whether an Entity Id belongs to defined sequence of id's
259   */
260   interface RangeOfIds: Predicate
261   {
262     void            SetRange( in long_array theIds );
263     boolean         SetRangeStr( in string theRange );
264     string          GetRangeStr();
265
266     void            SetElementType( in ElementType theType );
267   };
268
269   /*!
270   * Comparator. Predicate for compare value calculated
271   *             by numerical functor with threshold value
272   */
273   interface Comparator: Predicate
274   {
275     void    SetMargin( in double theValue );
276     void    SetNumFunctor( in NumericalFunctor theFunct );
277     double  GetMargin();
278   };
279   interface LessThan: Comparator{};
280   interface MoreThan: Comparator{};
281   interface EqualTo : Comparator
282   {
283     void    SetTolerance( in double theToler );
284     double  GetTolerance();
285   };
286
287   /*!
288   * Logical predicates are intended for compose predicates using boolean operations
289   */
290   interface Logical: Predicate{};
291
292   interface LogicalNOT: Logical
293   {
294     void SetPredicate(in Predicate thePredicate);
295   };
296
297   interface LogicalBinary: Logical
298 {
299     void SetPredicate1( in Predicate thePredicate );
300     void SetPredicate2( in Predicate thePredicate );
301   };
302
303   interface LogicalAND: LogicalBinary{};
304   interface LogicalOR : LogicalBinary{};
305
306   /*!
307   *  Filter
308   */
309   interface Filter: SALOME::GenericObj, SMESH_IDSource
310   {
311     /*!
312     * Structure containing information about one criterion
313     *   Type          - FT_Taper, FT_Skew ...
314     *   Compare       - FT_LessThan, FT_MoreThan, FT_EqualTo
315     *   Threshold     - threshold value
316     *   UnaryOp       - unary logical operation: FT_LogicalNOT or FT_Undefined
317     *   BinaryOp      - binary logical operation FT_LogicalAND, FT_LogicalOR or
318     *                   (FT_Undefined must be for the last criterion)
319     *   ThresholdStr  - Threshold value defined as string. Used for:
320     *                   1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
321     *                   2. BelongToGeom predicate for storing name of shape
322     *   ThresholdID   - One more threshold value defined as string. Used for:
323     *                   1. BelongToGeom predicate for storing id of shape
324     *   Tolerance     - Tolerance is used for comparators (EqualTo comparision) and for
325     *                   "Belong to plane" and "Belong to cylinder" predicates
326     *   TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
327     *   Precision     - Precision of numerical functors
328     */
329     struct Criterion
330     {
331       long        Type;
332       long        Compare;
333       double      Threshold;
334       string      ThresholdStr;
335       string      ThresholdID;
336       long        UnaryOp;
337       long        BinaryOp;
338       double      Tolerance;
339       ElementType TypeOfElement;
340       long        Precision;
341     };
342
343     typedef sequence<Criterion> Criteria;
344
345     void          SetPredicate( in Predicate thePredicate );
346     void          SetMesh( in SMESH_Mesh theMesh );
347
348     long_array    GetElementsId( in SMESH_Mesh theMesh );
349     ElementType   GetElementType();
350     Predicate     GetPredicate();
351
352     boolean       GetCriteria( out Criteria theCriteria );
353     boolean       SetCriteria( in Criteria theCriteria );
354   };
355
356
357   /*!
358   *  Interface for working with library of filters
359   */
360   interface FilterLibrary : SALOME::GenericObj
361   {
362     /*!
363     *  Copy filter from library by name (new filter is created)
364     */
365     Filter        Copy( in string theFilterName );
366
367     /*!
368     * Methods for editing library
369     */
370     boolean       Add     ( in string theFilterName, in Filter theFilter );
371     boolean       AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
372     boolean       Delete  ( in string theFilterName );
373     boolean       Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
374
375     /*!
376     *  Save library on disk
377     */
378     boolean       Save();
379     boolean       SaveAs( in string aFileName );
380
381     /*!
382     * Query methods
383     */
384     boolean       IsPresent( in string aFilterName );
385     long          NbFilters( in ElementType aType );
386     string_array  GetNames( in ElementType aType );
387     string_array  GetAllNames();
388     void          SetFileName( in string aFilterName );
389     string        GetFileName();
390   };
391
392
393   /*!
394   * Interface of Filter manager
395   */
396   interface FilterManager: SALOME::GenericObj
397   {
398     /*!
399     *  Create numerical functors
400     */
401     MinimumAngle      CreateMinimumAngle();
402     AspectRatio       CreateAspectRatio();
403     AspectRatio3D     CreateAspectRatio3D();
404     Warping           CreateWarping();
405     Taper             CreateTaper();
406     Skew              CreateSkew();
407     Area              CreateArea();
408     Volume3D          CreateVolume3D();
409     Length            CreateLength();
410     Length2D          CreateLength2D();
411     MultiConnection   CreateMultiConnection();
412     MultiConnection2D CreateMultiConnection2D();
413
414     /*!
415     *  Create logical functors ( predicates )
416     */
417     BelongToGeom      CreateBelongToGeom();
418     BelongToPlane     CreateBelongToPlane();
419     BelongToCylinder  CreateBelongToCylinder();
420     BelongToGenSurface CreateBelongToGenSurface();
421
422     LyingOnGeom       CreateLyingOnGeom();
423
424     FreeBorders       CreateFreeBorders();
425     FreeEdges         CreateFreeEdges();
426
427     RangeOfIds        CreateRangeOfIds();
428
429     BadOrientedVolume CreateBadOrientedVolume();
430
431     /*!
432     *  Create comparators ( predicates )
433     */
434     LessThan          CreateLessThan();
435     MoreThan          CreateMoreThan();
436     EqualTo           CreateEqualTo();
437
438     /*!
439     *  Create boolean operations ( predicates )
440     */
441     LogicalNOT        CreateLogicalNOT();
442     LogicalAND        CreateLogicalAND();
443     LogicalOR         CreateLogicalOR();
444
445     /*!
446     *  Create filter
447     */
448     Filter            CreateFilter();
449
450     /*!
451     *  Load filter library. If libary does not exist it is created
452     */
453     FilterLibrary     LoadLibrary( in string aFileName );
454
455     /*!
456     *  Create new library
457     */
458     FilterLibrary     CreateLibrary();
459
460     /*!
461     *  Delete library
462     */
463     boolean           DeleteLibrary( in string aFileName );
464   };
465 };
466
467
468 #endif