]> SALOME platform Git repositories - modules/gui.git/blob - src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.h
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / VTKViewer / VTKViewer_ExtractUnstructuredGrid.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
20 #define VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
21
22 #include "VTKViewer.h"
23
24 #include <vtkUnstructuredGridToUnstructuredGridFilter.h>
25
26 #include <set>
27 #include <map>
28 #include <vector>
29
30 #ifdef WIN32
31 #pragma warning ( disable:4251 )
32 #endif
33
34 /*! \class vtkUnstructuredGridToUnstructuredGridFilter
35  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
36  */
37 /*! \class vtkUnstructuredGridToUnstructuredGridFilter
38  * \brief For more information see VTK documentation.
39  */
40 class VTKVIEWER_EXPORT VTKViewer_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter
41 {
42 public:
43   //! VTK type macros.
44   vtkTypeMacro( VTKViewer_ExtractUnstructuredGrid, vtkUnstructuredGridToUnstructuredGridFilter );
45
46   //! \brief Construct with all types of clipping turned off.
47   static VTKViewer_ExtractUnstructuredGrid *New();
48
49   enum EExtraction{ eCells, ePoints};
50   //! Sets mode of extraction to \a theExtractionMode
51   void SetModeOfExtraction(EExtraction theExtractionMode){
52     myExtractionMode = theExtractionMode; Modified();
53   }
54   //! Get Extraction mode (Return: \a myExtractionMode field)
55   EExtraction GetModeOfExtraction(){ return myExtractionMode;}
56
57   enum EChanging{ ePassAll, eAdding, eRemoving};
58   //! Sets mode of changing to \a theChangeMode
59   void SetModeOfChanging(EChanging theChangeMode){
60     myChangeMode = theChangeMode; 
61     Modified();
62   }
63   //! Return \a myChangeMode field
64   EChanging GetModeOfChanging(){ return myChangeMode;}
65
66   //! Add cell id to \a myCellIds std::set
67   void RegisterCell(vtkIdType theCellId);
68   //! Check if myCellIds is empty.
69   int IsCellsRegistered() { return !myCellIds.empty();}
70   //! Remove the cell from the output
71   void ClearRegisteredCells() { 
72     myCellIds.clear();
73     Modified();
74   }
75   
76   //! Add cell type to \a myCellTypes std::set
77   void RegisterCellsWithType(vtkIdType theCellType);
78   //! Check if myCellTypes is empty.
79   int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
80   //! Remove every cells with the type from the output
81   void ClearRegisteredCellsWithType() { 
82     myCellTypes.clear();
83     Modified();
84   }
85
86   //! \brief Do the filter do some real work
87   int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered();}
88
89   //! \brief Do it keep the mapping between input's and output's UnstructuredGrid
90   void SetStoreMapping(int theStoreMapping);
91   //! Get \a myStoreMapping
92   int GetStoreMapping(){ return myStoreMapping;}
93
94   //! Gets the input id by output id.
95   vtkIdType GetInputId(int theOutId) const;
96   //! Gets the output id by input id.
97   vtkIdType GetOutputId(int theInId) const;
98
99   typedef std::vector<vtkIdType> TVectorId;
100   typedef std::map<vtkIdType,vtkIdType> TMapId;
101
102 protected:
103   VTKViewer_ExtractUnstructuredGrid();
104   ~VTKViewer_ExtractUnstructuredGrid();
105
106   //! Main method, which calculate output
107   // not ported yet to the new executive-based pipeline architecture.
108   // see http://www.vtk.org/cgi-bin/viewcvs.cgi/Filtering/vtkUnstructuredGridToUnstructuredGridFilter.h?rev=1.19&view=log
109   // virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
110   virtual void Execute();
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