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