Salome HOME
Update comments
[modules/gui.git] / src / VTKViewer / VTKViewer_ExtractUnstructuredGrid.h
1 #ifndef VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
2 #define VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
3
4 #include "VTKViewer.h"
5
6 #include <vtkUnstructuredGridToUnstructuredGridFilter.h>
7
8 #include <set>
9 #include <map>
10 #include <vector>
11 /*! \class vtkUnstructuredGridToUnstructuredGridFilter
12  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation
13  */
14 /*! \class vtkUnstructuredGridToUnstructuredGridFilter
15  * \brief For more information see VTK documentation.
16  */
17 class VTKVIEWER_EXPORT VTKViewer_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter
18 {
19 public:
20   //! VTK type macros.
21   vtkTypeMacro( VTKViewer_ExtractUnstructuredGrid, vtkUnstructuredGridToUnstructuredGridFilter );
22
23   //! \brief Construct with all types of clipping turned off.
24   static VTKViewer_ExtractUnstructuredGrid *New();
25
26   enum EExtraction{ eCells, ePoints};
27   //! Sets mode of extraction to \a theExtractionMode
28   void SetModeOfExtraction(EExtraction theExtractionMode){
29     myExtractionMode = theExtractionMode; Modified();
30   }
31   //! Get Extraction mode (Return: \a myExtractionMode field)
32   EExtraction GetModeOfExtraction(){ return myExtractionMode;}
33
34   enum EChanging{ ePassAll, eAdding, eRemoving};
35   //! Sets mode of changing to \a theChangeMode
36   void SetModeOfChanging(EChanging theChangeMode){
37     myChangeMode = theChangeMode; 
38     Modified();
39   }
40   //! Return \a myChangeMode field
41   EChanging GetModeOfChanging(){ return myChangeMode;}
42
43   //! Add cell id to \a myCellIds std::set
44   void RegisterCell(vtkIdType theCellId);
45   //! Check if myCellIds is empty.
46   int IsCellsRegistered() { return !myCellIds.empty();}
47   //! Remove the cell from the output
48   void ClearRegisteredCells() { 
49     myCellIds.clear();
50     Modified();
51   }
52   
53   //! Add cell type to \a myCellTypes std::set
54   void RegisterCellsWithType(vtkIdType theCellType);
55   //! Check if myCellTypes is empty.
56   int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
57   //! Remove every cells with the type from the output
58   void ClearRegisteredCellsWithType() { 
59     myCellTypes.clear();
60     Modified();
61   }
62
63   //! \brief Do the filter do some real work
64   int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered();}
65
66   //! \brief Do it keep the mapping between input's and output's UnstructuredGrid
67   void SetStoreMapping(int theStoreMapping);
68   //! Get \a myStoreMapping
69   int GetStoreMapping(){ return myStoreMapping;}
70
71   //! Gets the input id by output id.
72   vtkIdType GetInputId(int theOutId) const;
73   //! Gets the output id by input id.
74   vtkIdType GetOutputId(int theInId) const;
75
76   typedef std::vector<vtkIdType> TVectorId;
77   typedef std::map<vtkIdType,vtkIdType> TMapId;
78
79 protected:
80   VTKViewer_ExtractUnstructuredGrid();
81   ~VTKViewer_ExtractUnstructuredGrid();
82
83   //! Main method, which calculate output
84   void Execute();
85
86   EExtraction myExtractionMode;
87   
88   EChanging myChangeMode;
89   typedef std::set<vtkIdType> TSetId;
90   TSetId myCellIds;
91   TSetId myCellTypes;
92
93   bool myStoreMapping;
94   TVectorId myOut2InId;
95   TMapId myIn2OutId;
96
97 private:
98   //! Not implemented.
99   VTKViewer_ExtractUnstructuredGrid(const VTKViewer_ExtractUnstructuredGrid&);
100   //! Not implemented.
101   void operator=(const VTKViewer_ExtractUnstructuredGrid&);
102 };
103
104 #endif