Salome HOME
Initial version
[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
12 class VTKVIEWER_EXPORT VTKViewer_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter
13 {
14 public:
15   vtkTypeMacro( VTKViewer_ExtractUnstructuredGrid, vtkUnstructuredGridToUnstructuredGridFilter );
16
17   // Description:
18   // Construct with all types of clipping turned off.
19   static VTKViewer_ExtractUnstructuredGrid *New();
20
21   enum EExtraction{ eCells, ePoints};
22   void SetModeOfExtraction(EExtraction theExtractionMode){
23     myExtractionMode = theExtractionMode; Modified();
24   }
25   EExtraction GetModeOfExtraction(){ return myExtractionMode;}
26
27   enum EChanging{ ePassAll, eAdding, eRemoving};
28   void SetModeOfChanging(EChanging theChangeMode){
29     myChangeMode = theChangeMode; 
30     Modified();
31   }
32   EChanging GetModeOfChanging(){ return myChangeMode;}
33
34   // Remove the cell from the output
35   void RegisterCell(vtkIdType theCellId);
36   int IsCellsRegistered() { return !myCellIds.empty();}
37   void ClearRegisteredCells() { 
38     myCellIds.clear();
39     Modified();
40   }
41   
42   // Remove every cells with the type from the output
43   void RegisterCellsWithType(vtkIdType theCellType);
44   int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
45   void ClearRegisteredCellsWithType() { 
46     myCellTypes.clear();
47     Modified();
48   }
49
50   // Do the filter do some real work
51   int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered();}
52
53   // Do it keep the mapping between input's and output's UnstructuredGrid
54   void SetStoreMapping(int theStoreMapping);
55   int GetStoreMapping(){ return myStoreMapping;}
56
57   vtkIdType GetInputId(int theOutId) const;
58   vtkIdType GetOutputId(int theInId) const;
59
60   typedef std::vector<vtkIdType> TVectorId;
61   typedef std::map<vtkIdType,vtkIdType> TMapId;
62
63 protected:
64   VTKViewer_ExtractUnstructuredGrid();
65   ~VTKViewer_ExtractUnstructuredGrid();
66
67   void Execute();
68
69   EExtraction myExtractionMode;
70   
71   EChanging myChangeMode;
72   typedef std::set<vtkIdType> TSetId;
73   TSetId myCellIds;
74   TSetId myCellTypes;
75
76   bool myStoreMapping;
77   TVectorId myOut2InId;
78   TMapId myIn2OutId;
79
80 private:
81   VTKViewer_ExtractUnstructuredGrid(const VTKViewer_ExtractUnstructuredGrid&);  // Not implemented.
82   void operator=(const VTKViewer_ExtractUnstructuredGrid&);  // Not implemented.
83 };
84
85 #endif