Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / VTKFilter / SALOME_ExtractUnstructuredGrid.h
1 //  VISU CONVERTOR :
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 //  File   : SALOME_ExtractUnstructuredGrid.hxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef SALOME_ExtractUnstructuredGrid_HeaderFile
28 #define SALOME_ExtractUnstructuredGrid_HeaderFile
29
30 #include <vtkUnstructuredGridToUnstructuredGridFilter.h>
31
32 #include <set>
33 #include <map>
34 #include <vector>
35
36 class SALOME_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter{
37 public:
38   vtkTypeMacro(SALOME_ExtractUnstructuredGrid,vtkUnstructuredGridToUnstructuredGridFilter);
39
40   // Description:
41   // Construct with all types of clipping turned off.
42   static SALOME_ExtractUnstructuredGrid *New();
43
44   enum EExtraction{ eCells, ePoints};
45   void SetModeOfExtraction(EExtraction theExtractionMode){
46     myExtractionMode = theExtractionMode; Modified();
47   }
48   EExtraction GetModeOfExtraction(){ return myExtractionMode;}
49
50   enum EChanging{ ePassAll, eAdding, eRemoving};
51   void SetModeOfChanging(EChanging theChangeMode){
52     myChangeMode = theChangeMode; 
53     Modified();
54   }
55   EChanging GetModeOfChanging(){ return myChangeMode;}
56
57   // Remove the cell from the output
58   void RegisterCell(vtkIdType theCellId);
59   int IsCellsRegistered() { return !myCellIds.empty();}
60   void ClearRegisteredCells() { 
61     myCellIds.clear();
62     Modified();
63   }
64   
65   // Remove every cells with the type from the output
66   void RegisterCellsWithType(vtkIdType theCellType);
67   int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
68   void ClearRegisteredCellsWithType() { 
69     myCellTypes.clear();
70     Modified();
71   }
72
73   // Do the filter do some real work
74   int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered();}
75
76   // Do it keep the mapping between input's and output's UnstructuredGrid
77   void SetStoreMapping(int theStoreMapping);
78   int GetStoreMapping(){ return myStoreMapping;}
79
80   vtkIdType GetInputId(int theOutId) const;
81   vtkIdType GetOutputId(int theInId) const;
82
83   typedef std::vector<vtkIdType> TVectorId;
84   typedef std::map<vtkIdType,vtkIdType> TMapId;
85
86 protected:
87   SALOME_ExtractUnstructuredGrid();
88   ~SALOME_ExtractUnstructuredGrid();
89
90   void Execute();
91
92   EExtraction myExtractionMode;
93   
94   EChanging myChangeMode;
95   typedef std::set<vtkIdType> TSetId;
96   TSetId myCellIds;
97   TSetId myCellTypes;
98
99   bool myStoreMapping;
100   TVectorId myOut2InId;
101   TMapId myIn2OutId;
102
103 private:
104   SALOME_ExtractUnstructuredGrid(const SALOME_ExtractUnstructuredGrid&);  // Not implemented.
105   void operator=(const SALOME_ExtractUnstructuredGrid&);  // Not implemented.
106 };
107
108
109 #endif
110
111