Salome HOME
Bug PAL7334 DEVELOPMENT : Control Improvement
[modules/smesh.git] / src / SMESH_I / SMESH_Filter_i.hxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Filter_i.hxx
25 //  Author : Alexey Petrov, OCC
26 //  Module : SMESH
27
28 #ifndef _SMESH_FILTER_I_HXX_
29 #define _SMESH_FILTER_I_HXX_
30
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(SMESH_Filter)
33
34 #include <LDOM_Document.hxx>
35 #include <TopoDS_Shape.hxx>
36
37 #include "SALOME_GenericObj_i.hh"
38 #include "SMESH_ControlsDef.hxx"
39
40 class SMESHDS_Mesh;
41
42 namespace SMESH
43 {
44
45 namespace Controls
46 {
47
48 /*
49   Class       : BelongToGeom
50   Description : Predicate for verifying whether entiy belong to
51                 specified geometrical support
52 */
53 class BelongToGeom: public virtual Predicate
54 {
55 public:
56                                   BelongToGeom();
57
58   virtual void                    SetMesh( SMDS_Mesh* theMesh );
59   virtual void                    SetGeom( const TopoDS_Shape& theShape );
60
61   virtual bool                    IsSatisfy( long theElementId );
62
63   virtual void                    SetType( SMDSAbs_ElementType theType );
64   virtual                         SMDSAbs_ElementType GetType() const;
65
66   TopoDS_Shape                    GetShape();
67   SMESHDS_Mesh*                   GetMeshDS();
68
69 private:
70   TopoDS_Shape                    myShape;
71   SMESHDS_Mesh*                   myMeshDS;
72   SMDSAbs_ElementType             myType;
73 };
74 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
75 }
76
77 /*
78                                 FUNCTORS
79 */
80
81 /*
82   Class       : Functor_i
83   Description : An abstact class for all functors 
84 */
85 class Functor_i: public virtual POA_SMESH::Functor,
86                  public virtual SALOME::GenericObj_i
87 {
88 public:
89   void                            SetMesh( SMESH_Mesh_ptr theMesh );
90   Controls::FunctorPtr            GetFunctor(){ return myFunctorPtr;}
91   ElementType                     GetElementType();
92   
93 protected:
94                                   Functor_i();
95 protected:                                
96   Controls::FunctorPtr            myFunctorPtr;
97 };
98
99
100 /*
101   Class       : NumericalFunctor_i
102   Description : Base class for numerical functors 
103 */
104 class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
105                           public virtual Functor_i
106 {
107 public:
108   CORBA::Double                   GetValue( CORBA::Long theElementId );
109   void                            SetPrecision( CORBA::Long thePrecision );
110   CORBA::Long                     GetPrecision();
111   Controls::NumericalFunctorPtr   GetNumericalFunctor();
112   
113 protected:
114   Controls::NumericalFunctorPtr   myNumericalFunctorPtr;
115 };
116
117
118 /*
119   Class       : SMESH_MinimumAngleFunct
120   Description : Functor for calculation of minimum angle
121 */
122 class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
123                       public virtual NumericalFunctor_i
124 {
125 public:
126                                   MinimumAngle_i();
127   FunctorType                     GetFunctorType();
128 };
129
130
131 /*
132   Class       : AspectRatio_i
133   Description : Functor for calculating aspect ratio
134 */
135 class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
136                      public virtual NumericalFunctor_i
137 {
138 public:
139                                   AspectRatio_i();
140   FunctorType                     GetFunctorType();
141 };
142
143
144 /*
145   Class       : AspectRatio3D_i
146   Description : Functor for calculating aspect ratio for 3D
147 */
148 class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
149                        public virtual NumericalFunctor_i
150 {
151 public:
152                                   AspectRatio3D_i();
153   FunctorType                     GetFunctorType();
154 };
155
156
157 /*
158   Class       : Warping_i
159   Description : Functor for calculating warping
160 */
161 class Warping_i: public virtual POA_SMESH::Warping,
162                  public virtual NumericalFunctor_i
163 {
164 public:
165                                   Warping_i();
166   FunctorType                     GetFunctorType();
167 };
168
169
170 /*
171   Class       : Taper_i
172   Description : Functor for calculating taper
173 */
174 class Taper_i: public virtual POA_SMESH::Taper,
175                public virtual NumericalFunctor_i
176 {
177 public:
178                                   Taper_i();
179   FunctorType                     GetFunctorType();
180 };
181
182
183 /*
184   Class       : Skew_i
185   Description : Functor for calculating skew in degrees
186 */
187 class Skew_i: public virtual POA_SMESH::Skew,
188               public virtual NumericalFunctor_i
189 {
190 public:
191                                   Skew_i();
192   FunctorType                     GetFunctorType();
193 };
194
195
196 /*
197   Class       : Area_i
198   Description : Functor for calculating area
199 */
200 class Area_i: public virtual POA_SMESH::Area,
201               public virtual NumericalFunctor_i
202 {
203 public:
204                                   Area_i();
205   FunctorType                     GetFunctorType();
206 };
207
208
209 /*
210   Class       : Length_i
211   Description : Functor for calculating length of edge
212 */
213 class Length_i: public virtual POA_SMESH::Length,
214                 public virtual NumericalFunctor_i
215 {
216 public:
217                                   Length_i();
218   FunctorType                     GetFunctorType();
219 };
220
221 /*
222   Class       : Length2D_i
223   Description : Functor for calculating length of edge
224 */
225 class Length2D_i: public virtual POA_SMESH::Length2D,
226                   public virtual NumericalFunctor_i
227 {
228 public:
229                                   Length2D_i();
230   SMESH::Length2D::Values*        GetValues();
231   FunctorType                     GetFunctorType();
232
233 protected:
234   Controls::Length2DPtr          myLength2DPtr;
235 };
236
237
238 /*
239   Class       : MultiConnection_i
240   Description : Functor for calculating number of faces conneted to the edge
241 */
242 class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
243                          public virtual NumericalFunctor_i
244 {
245 public:
246                                   MultiConnection_i();
247   FunctorType                     GetFunctorType();
248 };
249
250
251 /*
252                             PREDICATES
253 */
254 /*
255   Class       : Predicate_i
256   Description : Base class for all predicates
257 */
258 class Predicate_i: public virtual POA_SMESH::Predicate,
259                    public virtual Functor_i
260 {
261 public:
262   CORBA::Boolean                  IsSatisfy( CORBA::Long theElementId );
263   Controls::PredicatePtr          GetPredicate();
264   
265 protected:
266   Controls::PredicatePtr          myPredicatePtr;
267 };
268
269
270 /*
271   Class       : BelongToGeom_i
272   Description : Predicate for selection on geometrical support
273 */
274 class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
275                       public virtual Predicate_i
276 {
277 public:
278                                   BelongToGeom_i();
279   virtual                         ~BelongToGeom_i();
280                                   
281   void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
282   void                            SetElementType( ElementType theType );
283   FunctorType                     GetFunctorType();
284
285   void                            SetGeom( const TopoDS_Shape& theShape );
286
287   void                            SetShapeName( const char* theName );
288   char*                           GetShapeName();
289
290 protected:
291   Controls::BelongToGeomPtr       myBelongToGeomPtr;
292   char*                           myShapeName;
293 };
294
295 /*
296   Class       : BelongToSurface_i
297   Description : Verify whether mesh element lie in pointed Geom planar object
298 */
299 class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
300                          public virtual Predicate_i
301 {
302 public:
303                                   BelongToSurface_i( const Handle(Standard_Type)& );
304   virtual                         ~BelongToSurface_i();
305
306   void                            SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
307
308   void                            SetShapeName( const char* theName, ElementType theType );
309   char*                           GetShapeName();
310
311   void                            SetTolerance( CORBA::Double );
312   CORBA::Double                   GetTolerance();
313
314 protected:
315   Controls::ElementsOnSurfacePtr  myElementsOnSurfacePtr;
316   char*                           myShapeName;
317   Handle(Standard_Type)           mySurfaceType;
318 };
319
320 /*
321   Class       : BelongToPlane_i
322   Description : Verify whether mesh element lie in pointed Geom planar object
323 */
324 class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
325                        public virtual BelongToSurface_i
326 {
327 public:
328                                   BelongToPlane_i();
329   void                            SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
330   FunctorType                     GetFunctorType();
331 };
332
333 /*
334   Class       : BelongToCylinder_i
335   Description : Verify whether mesh element lie in pointed Geom cylindrical object
336 */
337 class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
338                           public virtual BelongToSurface_i
339 {
340 public:
341                                   BelongToCylinder_i();
342   void                            SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
343   FunctorType                     GetFunctorType();
344 };
345
346
347 /*
348   Class       : FreeBorders_i
349   Description : Predicate for free borders
350 */
351 class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
352                      public virtual Predicate_i
353 {
354 public:
355                                   FreeBorders_i();
356   FunctorType                     GetFunctorType();
357 };
358
359
360 /*
361   Class       : FreeEdges_i
362   Description : Predicate for free edges
363 */
364 class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
365                    public virtual Predicate_i
366 {
367 public:
368                                   FreeEdges_i();
369   SMESH::FreeEdges::Borders*      GetBorders();
370   FunctorType                     GetFunctorType();
371   
372 protected:
373   Controls::FreeEdgesPtr          myFreeEdgesPtr;
374 };
375
376
377 /*
378   Class       : RangeOfIds_i
379   Description : Predicate for Range of Ids
380 */
381 class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
382                     public virtual Predicate_i
383 {
384 public:
385                                   RangeOfIds_i();
386   void                            SetRange( const SMESH::long_array& theIds );
387   CORBA::Boolean                  SetRangeStr( const char* theRange );
388   char*                           GetRangeStr();
389
390   void                            SetElementType( ElementType theType );
391   FunctorType                     GetFunctorType();
392
393 protected:
394   Controls::RangeOfIdsPtr         myRangeOfIdsPtr;
395 };
396
397 /*
398   Class       : Comparator_i
399   Description : Base class for comparators
400 */
401 class Comparator_i: public virtual POA_SMESH::Comparator,
402                     public virtual Predicate_i
403 {
404 public:
405   virtual                         ~Comparator_i();
406   
407   virtual void                    SetMargin( CORBA::Double );
408   virtual void                    SetNumFunctor( NumericalFunctor_ptr );
409   
410   Controls::ComparatorPtr         GetComparator();
411   NumericalFunctor_i*             GetNumFunctor_i();
412   CORBA::Double                   GetMargin();
413   
414 protected:
415                                   Comparator_i();
416 protected:                                  
417   Controls::ComparatorPtr         myComparatorPtr;
418   NumericalFunctor_i*             myNumericalFunctor;
419 };
420
421
422 /*
423   Class       : LessThan_i
424   Description : Comparator "<"
425 */
426 class LessThan_i: public virtual POA_SMESH::LessThan,
427                   public virtual Comparator_i
428 {
429 public:
430                                   LessThan_i();
431   FunctorType                     GetFunctorType();
432 };
433
434
435 /*
436   Class       : MoreThan_i
437   Description : Comparator ">"
438 */
439 class MoreThan_i: public virtual POA_SMESH::MoreThan,
440                   public virtual Comparator_i
441 {
442 public:
443                                   MoreThan_i();
444   FunctorType                     GetFunctorType();
445 };
446
447
448 /*
449   Class       : EqualTo_i
450   Description : Comparator "="
451 */
452 class EqualTo_i: public virtual POA_SMESH::EqualTo,
453                  public virtual Comparator_i
454 {
455 public:
456                                   EqualTo_i();
457   virtual void                    SetTolerance( CORBA::Double );
458   CORBA::Double                   GetTolerance();
459   FunctorType                     GetFunctorType();
460   
461 protected:
462   Controls::EqualToPtr            myEqualToPtr;
463 };
464
465
466 /*
467   Class       : LogicalNOT_i
468   Description : Logical NOT predicate
469 */
470 class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
471                     public virtual Predicate_i
472 {
473 public:
474                                   LogicalNOT_i();
475   virtual                         ~LogicalNOT_i();
476   
477   virtual void                    SetPredicate( Predicate_ptr );
478   Predicate_i*                    GetPredicate_i();
479   FunctorType                     GetFunctorType();
480   
481 protected:
482   Controls::LogicalNOTPtr         myLogicalNOTPtr;
483   Predicate_i*                    myPredicate;
484 };
485
486
487 /*
488   Class       : LogicalBinary_i
489   Description : Base class for binary logical predicate
490 */
491 class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
492                        public virtual Predicate_i
493 {
494 public:
495   virtual                         ~LogicalBinary_i();
496   virtual void                    SetMesh( SMESH_Mesh_ptr theMesh );
497   virtual void                    SetPredicate1( Predicate_ptr );
498   virtual void                    SetPredicate2( Predicate_ptr );
499   
500   Controls::LogicalBinaryPtr      GetLogicalBinary();
501   Predicate_i*                    GetPredicate1_i();
502   Predicate_i*                    GetPredicate2_i();
503   
504 protected:
505                                   LogicalBinary_i();
506 protected:  
507   Controls::LogicalBinaryPtr      myLogicalBinaryPtr;
508   Predicate_i*                    myPredicate1;
509   Predicate_i*                    myPredicate2;
510 };
511
512
513 /*
514   Class       : LogicalAND_i
515   Description : Logical AND
516 */
517 class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
518                     public virtual LogicalBinary_i
519 {
520 public:
521                                   LogicalAND_i();
522   FunctorType                     GetFunctorType();
523 };
524
525
526 /*
527   Class       : LogicalOR_i
528   Description : Logical OR
529 */
530 class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
531                    public virtual LogicalBinary_i
532 {
533 public:
534                                   LogicalOR_i();
535   FunctorType                     GetFunctorType();
536 };
537
538
539 /*
540                                FILTER
541 */
542 class Filter_i: public virtual POA_SMESH::Filter,
543                 public virtual SALOME::GenericObj_i
544 {
545 public:
546                                   Filter_i();
547   virtual                         ~Filter_i();
548   
549   void                            SetPredicate( Predicate_ptr );
550   void                            SetMesh( SMESH_Mesh_ptr );
551
552   long_array*                     GetElementsId( SMESH_Mesh_ptr );
553   ElementType                     GetElementType();
554
555   CORBA::Boolean                  GetCriteria( SMESH::Filter::Criteria_out theCriteria );
556   CORBA::Boolean                  SetCriteria( const SMESH::Filter::Criteria& theCriteria );
557   
558   Predicate_ptr                   GetPredicate();
559   Predicate_i*                    GetPredicate_i();
560
561 private:
562   Controls::Filter                myFilter;
563   Predicate_i*                    myPredicate;
564 };
565
566
567 /*
568                             FILTER LIBRARY
569 */
570 class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
571                        public virtual SALOME::GenericObj_i
572 {
573 public:
574                           FilterLibrary_i( const char* theFileName );
575                           FilterLibrary_i();
576                           ~FilterLibrary_i();
577
578   Filter_ptr              Copy( const char* theFilterName );
579
580   CORBA::Boolean          Add     ( const char* theFilterName, Filter_ptr theFilter );
581   CORBA::Boolean          AddEmpty( const char* theFilterName, ElementType theType );
582   CORBA::Boolean          Delete  ( const char* theFilterName );
583   CORBA::Boolean          Replace ( const char* theFilterName, 
584                                     const char* theNewName, 
585                                     Filter_ptr  theFilter );
586
587   CORBA::Boolean          Save();
588   CORBA::Boolean          SaveAs( const char* aFileName );
589   
590   CORBA::Boolean          IsPresent( const char* aFilterName );
591   CORBA::Long             NbFilters( ElementType );
592   string_array*           GetNames( ElementType );
593   string_array*           GetAllNames();
594   void                    SetFileName( const char* theFileName );
595   char*                   GetFileName();
596
597 private:
598   char*                   myFileName;
599   LDOM_Document           myDoc;
600   FilterManager_var       myFilterMgr;
601 };
602
603
604 /*
605                             FILTER MANAGER
606 */
607
608 class FilterManager_i: public virtual POA_SMESH::FilterManager,
609                        public virtual SALOME::GenericObj_i
610 {
611 public:
612                             FilterManager_i();
613   MinimumAngle_ptr          CreateMinimumAngle();
614   AspectRatio_ptr           CreateAspectRatio();
615   AspectRatio3D_ptr         CreateAspectRatio3D();
616   Warping_ptr               CreateWarping();
617   Taper_ptr                 CreateTaper();
618   Skew_ptr                  CreateSkew();
619   Area_ptr                  CreateArea();
620   Length_ptr                CreateLength();
621   Length2D_ptr              CreateLength2D();
622   MultiConnection_ptr       CreateMultiConnection();
623   
624   BelongToGeom_ptr          CreateBelongToGeom();
625   BelongToPlane_ptr         CreateBelongToPlane();
626   BelongToCylinder_ptr      CreateBelongToCylinder();
627
628   FreeBorders_ptr           CreateFreeBorders();
629   FreeEdges_ptr             CreateFreeEdges();
630
631   RangeOfIds_ptr            CreateRangeOfIds();
632
633   LessThan_ptr              CreateLessThan();
634   MoreThan_ptr              CreateMoreThan();
635   EqualTo_ptr               CreateEqualTo();
636   
637   LogicalNOT_ptr            CreateLogicalNOT();
638   LogicalAND_ptr            CreateLogicalAND();
639   LogicalOR_ptr             CreateLogicalOR();
640
641   Filter_ptr                CreateFilter();
642
643   FilterLibrary_ptr         LoadLibrary( const char* aFileName );
644   FilterLibrary_ptr         CreateLibrary();
645   CORBA::Boolean            DeleteLibrary( const char* aFileName );
646 };
647
648
649
650 };
651
652
653 #endif