Salome HOME
4b9f29ceaaa16e4d112949a993f450e4719671d4
[modules/smesh.git] / src / SMESHFiltersSelection / SMESH_NumberFilter.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 //  File   : SMESH_NumberFilter.hxx
21 //  Module : SMESH
22
23 #ifndef _SMESH_NumberFilter_HeaderFile
24 #define _SMESH_NumberFilter_HeaderFile
25
26 #include "SUIT_SelectionFilter.h"
27
28 #include <TopAbs_ShapeEnum.hxx>
29 #include <TColStd_MapOfInteger.hxx>
30
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(GEOM_Gen)
33
34 class SUIT_DataOwner;
35
36 /*!
37  *  Class       : SMESH_NumberFilter
38  *  Description : Filter for geom or smesh objects.
39  *                Filter geom objects by number of subshapes of the given type
40  *                Parameters of constructor:
41  *                * theSubShapeType - Type of subshape
42  *                * theNumber       - Number of subshapes. Object is selected if it contains theNumber of
43  *                                    theSubShapeType sub-shapes
44  *                * theShapeType    - This map specifies types of object to be selected
45  *                * theMainObject   - Sub-shapes of this object is selected only
46  *                * theIsClosedOnly - Closed shapes is selected if this parameter is true
47  */
48 class SMESH_NumberFilter : public SUIT_SelectionFilter
49 {
50  public:
51   SMESH_NumberFilter (const char*            theKind,
52                       const TopAbs_ShapeEnum theSubShapeType,
53                       const int              theNumber,
54                       const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE,
55                       GEOM::GEOM_Object_ptr  theMainObj = GEOM::GEOM_Object::_nil(),
56                       const bool             theIsClosedOnly = false );
57
58   SMESH_NumberFilter (const char*                 theKind,
59                       const TopAbs_ShapeEnum      theSubShapeType,
60                       const int                   theNumber,
61                       const TColStd_MapOfInteger& theShapeTypes,
62                       GEOM::GEOM_Object_ptr       theMainObj = GEOM::GEOM_Object::_nil(),
63                       const bool                  theIsClosedOnly = false );
64
65   virtual ~SMESH_NumberFilter();
66
67   virtual bool isOk (const SUIT_DataOwner*) const;
68
69   void SetSubShapeType (const TopAbs_ShapeEnum);
70   void SetNumber       (const int);
71   void SetClosedOnly   (const bool);
72   void SetShapeType    (const TopAbs_ShapeEnum);
73   void SetShapeTypes   (const TColStd_MapOfInteger&);
74   void SetMainShape    (GEOM::GEOM_Object_ptr);
75
76  private:
77   GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*, const bool extractReference = true ) const;
78
79  private:
80   char*                 myKind;
81   TopAbs_ShapeEnum      mySubShapeType;
82   int                   myNumber;
83   bool                  myIsClosedOnly;
84   TColStd_MapOfInteger  myShapeTypes;
85   GEOM::GEOM_Object_var myMainObj;
86 };
87
88 #endif