Salome HOME
GetElementType method added
[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( const 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       const SMESHDS_Mesh*             GetMeshDS() const;
68       
69     private:
70       TopoDS_Shape                    myShape;
71       const SMESHDS_Mesh*             myMeshDS;
72       SMDSAbs_ElementType             myType;
73     };
74     typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
75     
76     /*
77       Class       : LyingOnGeom
78       Description : Predicate for verifying whether entiy lying or partially lying on
79       specified geometrical support
80     */
81     class LyingOnGeom: public virtual Predicate
82     {
83     public:
84       LyingOnGeom();
85       
86       virtual void                    SetMesh( const SMDS_Mesh* theMesh );
87       virtual void                    SetGeom( const TopoDS_Shape& theShape );
88       
89       virtual bool                    IsSatisfy( long theElementId );
90       
91       virtual void                    SetType( SMDSAbs_ElementType theType );
92       virtual                         SMDSAbs_ElementType GetType() const;
93       
94       TopoDS_Shape                    GetShape();
95       const SMESHDS_Mesh*             GetMeshDS() const;
96       
97       virtual bool                    Contains( const SMESHDS_Mesh*     theMeshDS,
98                                                 const TopoDS_Shape&     theShape,
99                                                 const SMDS_MeshElement* theElem,
100                                                 TopAbs_ShapeEnum        theFindShapeEnum,
101                                                 TopAbs_ShapeEnum        theAvoidShapeEnum = TopAbs_SHAPE );
102     private:
103       TopoDS_Shape                    myShape;
104       const SMESHDS_Mesh*             myMeshDS;
105       SMDSAbs_ElementType             myType;
106     };
107     typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
108   }
109   
110   /*
111     FUNCTORS
112   */
113   
114   /*
115     Class       : Functor_i
116     Description : An abstact class for all functors 
117   */
118   class Functor_i: public virtual POA_SMESH::Functor,
119                    public virtual SALOME::GenericObj_i
120   {
121   public:
122     void                            SetMesh( SMESH_Mesh_ptr theMesh );
123     Controls::FunctorPtr            GetFunctor(){ return myFunctorPtr;}
124     ElementType                     GetElementType();
125     
126   protected:
127     Functor_i();
128     ~Functor_i();
129   protected:                                
130     Controls::FunctorPtr            myFunctorPtr;
131   };
132   
133   /*
134     Class       : NumericalFunctor_i
135     Description : Base class for numerical functors 
136   */
137   class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
138                             public virtual Functor_i
139   {
140   public:
141     CORBA::Double                   GetValue( CORBA::Long theElementId );
142     void                            SetPrecision( CORBA::Long thePrecision );
143     CORBA::Long                     GetPrecision();
144     Controls::NumericalFunctorPtr   GetNumericalFunctor();
145     
146   protected:
147     Controls::NumericalFunctorPtr   myNumericalFunctorPtr;
148   };
149   
150   
151   /*
152     Class       : SMESH_MinimumAngleFunct
153     Description : Functor for calculation of minimum angle
154   */
155   class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
156                         public virtual NumericalFunctor_i
157   {
158   public:
159     MinimumAngle_i();
160     FunctorType                     GetFunctorType();
161   };
162   
163   
164   /*
165     Class       : AspectRatio_i
166     Description : Functor for calculating aspect ratio
167   */
168   class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
169                        public virtual NumericalFunctor_i
170   {
171   public:
172     AspectRatio_i();
173     FunctorType                     GetFunctorType();
174   };
175   
176   
177   /*
178     Class       : AspectRatio3D_i
179     Description : Functor for calculating aspect ratio for 3D
180   */
181   class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
182                          public virtual NumericalFunctor_i
183   {
184   public:
185     AspectRatio3D_i();
186     FunctorType                     GetFunctorType();
187   };
188   
189
190   /*
191     Class       : Warping_i
192     Description : Functor for calculating warping
193   */
194   class Warping_i: public virtual POA_SMESH::Warping,
195                    public virtual NumericalFunctor_i
196   {
197   public:
198     Warping_i();
199     FunctorType                     GetFunctorType();
200   };
201   
202   
203   /*
204     Class       : Taper_i
205     Description : Functor for calculating taper
206   */
207   class Taper_i: public virtual POA_SMESH::Taper,
208                  public virtual NumericalFunctor_i
209   {
210   public:
211     Taper_i();
212     FunctorType                     GetFunctorType();
213   };
214   
215   
216   /*
217     Class       : Skew_i
218     Description : Functor for calculating skew in degrees
219   */
220   class Skew_i: public virtual POA_SMESH::Skew,
221                 public virtual NumericalFunctor_i
222   {
223   public:
224     Skew_i();
225     FunctorType                     GetFunctorType();
226   };
227   
228   
229   /*
230     Class       : Area_i
231     Description : Functor for calculating area
232   */
233   class Area_i: public virtual POA_SMESH::Area,
234                 public virtual NumericalFunctor_i
235   {
236   public:
237     Area_i();
238     FunctorType                     GetFunctorType();
239   };
240   
241   
242   /*
243     Class       : Length_i
244     Description : Functor for calculating length of edge
245   */
246   class Length_i: public virtual POA_SMESH::Length,
247                   public virtual NumericalFunctor_i
248   {
249   public:
250     Length_i();
251     FunctorType                     GetFunctorType();
252   };
253   
254   /*
255     Class       : Length2D_i
256     Description : Functor for calculating length of edge
257   */
258   class Length2D_i: public virtual POA_SMESH::Length2D,
259                     public virtual NumericalFunctor_i
260   {
261   public:
262     Length2D_i();
263     SMESH::Length2D::Values*        GetValues();
264     FunctorType                     GetFunctorType();
265     
266   protected:
267     Controls::Length2DPtr          myLength2DPtr;
268   };
269   
270   
271   /*
272     Class       : MultiConnection_i
273     Description : Functor for calculating number of faces conneted to the edge
274   */
275   class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
276                            public virtual NumericalFunctor_i
277   {
278   public:
279     MultiConnection_i();
280     FunctorType                     GetFunctorType();
281   };
282   
283   /*
284     Class       : MultiConnection2D_i
285     Description : Functor for calculating number of faces conneted to the edge
286   */
287   class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
288                              public virtual NumericalFunctor_i
289   {
290   public:
291     MultiConnection2D_i();
292     SMESH::MultiConnection2D::Values*  GetValues();
293     FunctorType                        GetFunctorType();
294     
295   protected:
296     Controls::MultiConnection2DPtr     myMulticonnection2DPtr;
297   };
298   
299   
300   /*
301     PREDICATES
302   */
303   /*
304     Class       : Predicate_i
305     Description : Base class for all predicates
306   */
307   class Predicate_i: public virtual POA_SMESH::Predicate,
308                      public virtual Functor_i
309   {
310   public:
311     CORBA::Boolean                  IsSatisfy( CORBA::Long theElementId );
312     Controls::PredicatePtr          GetPredicate();
313     
314   protected:
315     Controls::PredicatePtr          myPredicatePtr;
316   };
317   
318   
319   /*
320     Class       : BadOrientedVolume_i
321     Description : Verify whether a mesh volume is incorrectly oriented from
322     the point of view of MED convention
323   */
324   class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
325                              public virtual Predicate_i
326   {
327   public:
328     BadOrientedVolume_i();
329     FunctorType                     GetFunctorType();
330   };
331   
332   /*
333     Class       : BelongToGeom_i
334     Description : Predicate for selection on geometrical support
335   */
336   class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
337                         public virtual Predicate_i
338   {
339   public:
340     BelongToGeom_i();
341     virtual                         ~BelongToGeom_i();
342     
343     void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
344     void                            SetElementType( ElementType theType );
345     FunctorType                     GetFunctorType();
346     
347     void                            SetGeom( const TopoDS_Shape& theShape );
348     
349     void                            SetShapeName( const char* theName );
350     char*                           GetShapeName();
351     
352   protected:
353     Controls::BelongToGeomPtr       myBelongToGeomPtr;
354     char*                           myShapeName;
355   };
356   
357   /*
358     Class       : BelongToSurface_i
359     Description : Verify whether mesh element lie in pointed Geom planar object
360   */
361   class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
362                            public virtual Predicate_i
363   {
364   public:
365     BelongToSurface_i( const Handle(Standard_Type)& );
366     virtual                         ~BelongToSurface_i();
367     
368     void                            SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
369     
370     void                            SetShapeName( const char* theName, ElementType theType );
371     char*                           GetShapeName();
372     
373     void                            SetTolerance( CORBA::Double );
374     CORBA::Double                   GetTolerance();
375     
376   protected:
377     Controls::ElementsOnSurfacePtr  myElementsOnSurfacePtr;
378     char*                           myShapeName;
379     Handle(Standard_Type)           mySurfaceType;
380   };
381   
382   /*
383     Class       : BelongToPlane_i
384     Description : Verify whether mesh element lie in pointed Geom planar object
385   */
386   class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
387                          public virtual BelongToSurface_i
388   {
389   public:
390     BelongToPlane_i();
391     void                            SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
392     FunctorType                     GetFunctorType();
393   };
394   
395   /*
396     Class       : BelongToCylinder_i
397     Description : Verify whether mesh element lie in pointed Geom cylindrical object
398   */
399   class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
400                             public virtual BelongToSurface_i
401   {
402   public:
403     BelongToCylinder_i();
404     void                            SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
405     FunctorType                     GetFunctorType();
406   };
407   
408   /*
409     Class       : LyingOnGeom_i
410     Description : Predicate for selection on geometrical support(lying or partially lying)
411   */
412   class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
413                        public virtual Predicate_i
414   {
415   public:
416     LyingOnGeom_i();
417     virtual                         ~LyingOnGeom_i();
418     
419     void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
420     void                            SetElementType( ElementType theType );
421     FunctorType                     GetFunctorType();
422     
423     void                            SetGeom( const TopoDS_Shape& theShape );
424     
425     void                            SetShapeName( const char* theName );
426     char*                           GetShapeName();
427     
428   protected:
429     Controls::LyingOnGeomPtr        myLyingOnGeomPtr;
430     char*                           myShapeName;
431   };
432   
433   /*
434     Class       : FreeBorders_i
435     Description : Predicate for free borders
436   */
437   class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
438                        public virtual Predicate_i
439   {
440   public:
441     FreeBorders_i();
442     FunctorType                     GetFunctorType();
443   };
444   
445   
446   /*
447     Class       : FreeEdges_i
448     Description : Predicate for free edges
449   */
450   class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
451                      public virtual Predicate_i
452   {
453   public:
454     FreeEdges_i();
455     SMESH::FreeEdges::Borders*      GetBorders();
456     FunctorType                     GetFunctorType();
457     
458   protected:
459     Controls::FreeEdgesPtr          myFreeEdgesPtr;
460   };
461   
462   
463   /*
464     Class       : RangeOfIds_i
465     Description : Predicate for Range of Ids
466   */
467   class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
468                       public virtual Predicate_i
469   {
470   public:
471     RangeOfIds_i();
472     void                            SetRange( const SMESH::long_array& theIds );
473     CORBA::Boolean                  SetRangeStr( const char* theRange );
474     char*                           GetRangeStr();
475     
476     void                            SetElementType( ElementType theType );
477     FunctorType                     GetFunctorType();
478     
479   protected:
480     Controls::RangeOfIdsPtr         myRangeOfIdsPtr;
481   };
482   
483   /*
484     Class       : Comparator_i
485     Description : Base class for comparators
486   */
487   class Comparator_i: public virtual POA_SMESH::Comparator,
488                       public virtual Predicate_i
489   {
490   public:
491     virtual                         ~Comparator_i();
492     
493     virtual void                    SetMargin( CORBA::Double );
494     virtual void                    SetNumFunctor( NumericalFunctor_ptr );
495     
496     Controls::ComparatorPtr         GetComparator();
497     NumericalFunctor_i*             GetNumFunctor_i();
498     CORBA::Double                   GetMargin();
499     
500   protected:
501     Comparator_i();
502   protected:                                  
503     Controls::ComparatorPtr         myComparatorPtr;
504     NumericalFunctor_i*             myNumericalFunctor;
505   };
506   
507   
508   /*
509     Class       : LessThan_i
510     Description : Comparator "<"
511   */
512   class LessThan_i: public virtual POA_SMESH::LessThan,
513                     public virtual Comparator_i
514   {
515   public:
516     LessThan_i();
517     FunctorType                     GetFunctorType();
518   };
519   
520   
521   /*
522     Class       : MoreThan_i
523     Description : Comparator ">"
524   */
525   class MoreThan_i: public virtual POA_SMESH::MoreThan,
526                     public virtual Comparator_i
527   {
528   public:
529     MoreThan_i();
530     FunctorType                     GetFunctorType();
531   };
532   
533   
534   /*
535     Class       : EqualTo_i
536     Description : Comparator "="
537   */
538   class EqualTo_i: public virtual POA_SMESH::EqualTo,
539                    public virtual Comparator_i
540   {
541   public:
542     EqualTo_i();
543     virtual void                    SetTolerance( CORBA::Double );
544     CORBA::Double                   GetTolerance();
545     FunctorType                     GetFunctorType();
546     
547   protected:
548     Controls::EqualToPtr            myEqualToPtr;
549   };
550   
551   
552   /*
553     Class       : LogicalNOT_i
554     Description : Logical NOT predicate
555   */
556   class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
557                       public virtual Predicate_i
558   {
559   public:
560     LogicalNOT_i();
561   virtual                         ~LogicalNOT_i();
562     
563     virtual void                    SetPredicate( Predicate_ptr );
564     Predicate_i*                    GetPredicate_i();
565     FunctorType                     GetFunctorType();
566     
567   protected:
568     Controls::LogicalNOTPtr         myLogicalNOTPtr;
569     Predicate_i*                    myPredicate;
570   };
571   
572   
573   /*
574     Class       : LogicalBinary_i
575     Description : Base class for binary logical predicate
576   */
577   class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
578                          public virtual Predicate_i
579   {
580   public:
581     virtual                         ~LogicalBinary_i();
582     virtual void                    SetMesh( SMESH_Mesh_ptr theMesh );
583     virtual void                    SetPredicate1( Predicate_ptr );
584     virtual void                    SetPredicate2( Predicate_ptr );
585     
586     Controls::LogicalBinaryPtr      GetLogicalBinary();
587     Predicate_i*                    GetPredicate1_i();
588     Predicate_i*                    GetPredicate2_i();
589     
590   protected:
591     LogicalBinary_i();
592   protected:  
593     Controls::LogicalBinaryPtr      myLogicalBinaryPtr;
594     Predicate_i*                    myPredicate1;
595     Predicate_i*                    myPredicate2;
596   };
597   
598   
599   /*
600     Class       : LogicalAND_i
601     Description : Logical AND
602   */
603   class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
604                       public virtual LogicalBinary_i
605   {
606   public:
607     LogicalAND_i();
608     FunctorType                     GetFunctorType();
609   };
610   
611   
612   /*
613     Class       : LogicalOR_i
614     Description : Logical OR
615   */
616   class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
617                      public virtual LogicalBinary_i
618   {
619   public:
620     LogicalOR_i();
621     FunctorType                     GetFunctorType();
622   };
623   
624   
625   /*
626     FILTER
627   */
628   class Filter_i: public virtual POA_SMESH::Filter,
629                   public virtual SALOME::GenericObj_i
630   {
631   public:
632     Filter_i();
633     ~Filter_i();
634     
635     virtual
636     void
637     SetPredicate( Predicate_ptr );
638
639     virtual
640     void
641     SetMesh( SMESH_Mesh_ptr );
642
643     virtual
644     SMESH::long_array* 
645     GetIDs();
646     
647     static
648     void
649     GetElementsId( Predicate_i*,
650                    const SMDS_Mesh*,
651                    Controls::Filter::TIdSequence& );
652     static
653     void           
654     GetElementsId( Predicate_i*,
655                    SMESH_Mesh_ptr,
656                    Controls::Filter::TIdSequence& );
657     
658     virtual
659     long_array*      
660     GetElementsId( SMESH_Mesh_ptr );
661
662     virtual
663     ElementType      
664     GetElementType();
665     
666     virtual
667     CORBA::Boolean   
668     GetCriteria( SMESH::Filter::Criteria_out theCriteria );
669
670     virtual
671     CORBA::Boolean
672     SetCriteria( const SMESH::Filter::Criteria& theCriteria );
673     
674     virtual
675     Predicate_ptr
676     GetPredicate();
677
678     Predicate_i*     GetPredicate_i();
679
680   private:
681     Controls::Filter myFilter;
682     Predicate_i*     myPredicate;
683     SMESH_Mesh_var   myMesh;
684   };
685   
686   
687   /*
688     FILTER LIBRARY
689   */
690   class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
691                          public virtual SALOME::GenericObj_i
692   {
693   public:
694     FilterLibrary_i( const char* theFileName );
695     FilterLibrary_i();
696     ~FilterLibrary_i();
697     
698     Filter_ptr              Copy( const char* theFilterName );
699     
700     CORBA::Boolean          Add     ( const char* theFilterName, Filter_ptr theFilter );
701     CORBA::Boolean          AddEmpty( const char* theFilterName, ElementType theType );
702     CORBA::Boolean          Delete  ( const char* theFilterName );
703     CORBA::Boolean          Replace ( const char* theFilterName, 
704                                       const char* theNewName, 
705                                       Filter_ptr  theFilter );
706     
707     CORBA::Boolean          Save();
708     CORBA::Boolean          SaveAs( const char* aFileName );
709     
710     CORBA::Boolean          IsPresent( const char* aFilterName );
711     CORBA::Long             NbFilters( ElementType );
712     string_array*           GetNames( ElementType );
713     string_array*           GetAllNames();
714     void                    SetFileName( const char* theFileName );
715     char*                   GetFileName();
716     
717   private:
718     char*                   myFileName;
719     LDOM_Document           myDoc;
720     FilterManager_var       myFilterMgr;
721   };
722   
723   
724   /*
725     FILTER MANAGER
726   */
727   
728   class FilterManager_i: public virtual POA_SMESH::FilterManager,
729                          public virtual SALOME::GenericObj_i
730   {
731   public:
732     FilterManager_i();
733     ~FilterManager_i();
734
735     MinimumAngle_ptr          CreateMinimumAngle();
736     AspectRatio_ptr           CreateAspectRatio();
737     AspectRatio3D_ptr         CreateAspectRatio3D();
738     Warping_ptr               CreateWarping();
739     Taper_ptr                 CreateTaper();
740     Skew_ptr                  CreateSkew();
741     Area_ptr                  CreateArea();
742     Length_ptr                CreateLength();
743     Length2D_ptr              CreateLength2D();
744     MultiConnection_ptr       CreateMultiConnection();
745     MultiConnection2D_ptr     CreateMultiConnection2D();
746     
747     BelongToGeom_ptr          CreateBelongToGeom();
748     BelongToPlane_ptr         CreateBelongToPlane();
749     BelongToCylinder_ptr      CreateBelongToCylinder();
750     
751     LyingOnGeom_ptr           CreateLyingOnGeom();
752     
753     FreeBorders_ptr           CreateFreeBorders();
754     FreeEdges_ptr             CreateFreeEdges();
755     
756     RangeOfIds_ptr            CreateRangeOfIds();
757     
758     BadOrientedVolume_ptr     CreateBadOrientedVolume();
759     
760     LessThan_ptr              CreateLessThan();
761     MoreThan_ptr              CreateMoreThan();
762     EqualTo_ptr               CreateEqualTo();
763     
764     LogicalNOT_ptr            CreateLogicalNOT();
765     LogicalAND_ptr            CreateLogicalAND();
766     LogicalOR_ptr             CreateLogicalOR();
767     
768     Filter_ptr                CreateFilter();
769     
770     FilterLibrary_ptr         LoadLibrary( const char* aFileName );
771     FilterLibrary_ptr         CreateLibrary();
772     CORBA::Boolean            DeleteLibrary( const char* aFileName );
773   };
774   
775   
776   Predicate_i* 
777   GetPredicate( SMESH::Predicate_ptr thePredicate );
778 }
779
780
781 #endif