Salome HOME
Copyrights update 2015.
[modules/gui.git] / src / VTKViewer / VTKViewer_ExtractUnstructuredGrid.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
24 #define VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
25
26 #include "VTKViewer.h"
27
28 #include <vtkUnstructuredGridAlgorithm.h>
29
30 #include <set>
31 #include <map>
32 #include <vector>
33
34 #ifdef WIN32
35 #pragma warning ( disable:4251 )
36 #endif
37
38 /*! \class vtkUnstructuredGridAlgorithm
39  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
40  */
41 /*! \class vtkUnstructuredGridAlgorithm
42  * \brief For more information see VTK documentation.
43  */
44 class VTKVIEWER_EXPORT VTKViewer_ExtractUnstructuredGrid : public vtkUnstructuredGridAlgorithm
45 {
46 public:
47   //! VTK type macros.
48   vtkTypeMacro( VTKViewer_ExtractUnstructuredGrid, vtkUnstructuredGridAlgorithm );
49
50   //! \brief Construct with all types of clipping turned off.
51   static VTKViewer_ExtractUnstructuredGrid *New();
52
53   enum EExtraction{ eCells, ePoints};
54   //! Sets mode of extraction to \a theExtractionMode
55   void SetModeOfExtraction(EExtraction theExtractionMode){
56     myExtractionMode = theExtractionMode; Modified();
57   }
58   //! Get Extraction mode (Return: \a myExtractionMode field)
59   EExtraction GetModeOfExtraction(){ return myExtractionMode;}
60
61   enum EChanging{ ePassAll, eAdding, eRemoving};
62   //! Sets mode of changing to \a theChangeMode
63   void SetModeOfChanging(EChanging theChangeMode){
64     myChangeMode = theChangeMode; 
65     Modified();
66   }
67   //! Return \a myChangeMode field
68   EChanging GetModeOfChanging(){ return myChangeMode;}
69
70   //! Add cell id to \a myCellIds std::set
71   void RegisterCell(vtkIdType theCellId);
72   //! Check if myCellIds is empty.
73   int IsCellsRegistered() { return !myCellIds.empty();}
74   //! Remove the cell from the output
75   void ClearRegisteredCells() { 
76     myCellIds.clear();
77     Modified();
78   }
79   
80   //! Add cell type to \a myCellTypes std::set
81   void RegisterCellsWithType(vtkIdType theCellType);
82   //! Check if myCellTypes is empty.
83   int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
84   //! Remove every cells with the type from the output
85   void ClearRegisteredCellsWithType() { 
86     myCellTypes.clear();
87     Modified();
88   }
89
90   //! \brief Do the filter do some real work
91   int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered();}
92
93   //! \brief Do it keep the mapping between input's and output's UnstructuredGrid
94   void SetStoreMapping(int theStoreMapping);
95   //! Get \a myStoreMapping
96   int GetStoreMapping(){ return myStoreMapping;}
97
98   //! Gets the input id by output id.
99   vtkIdType GetInputId(int theOutId) const;
100   //! Gets the output id by input id.
101   vtkIdType GetOutputId(int theInId) const;
102
103   typedef std::vector<vtkIdType> TVectorId;
104   typedef std::map<vtkIdType,vtkIdType> TMapId;
105
106 protected:
107   VTKViewer_ExtractUnstructuredGrid();
108   ~VTKViewer_ExtractUnstructuredGrid();
109
110   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
111
112   EExtraction myExtractionMode;
113   
114   EChanging myChangeMode;
115   typedef std::set<vtkIdType> TSetId;
116   TSetId myCellIds;
117   TSetId myCellTypes;
118
119   bool myStoreMapping;
120   TVectorId myOut2InId;
121   TMapId myIn2OutId;
122
123 private:
124   //! Not implemented.
125   VTKViewer_ExtractUnstructuredGrid(const VTKViewer_ExtractUnstructuredGrid&);
126   //! Not implemented.
127   void operator=(const VTKViewer_ExtractUnstructuredGrid&);
128 };
129
130 #ifdef WIN32
131 #pragma warning ( default:4251 )
132 #endif
133
134 #endif