1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
24 #define VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
26 #include "VTKViewer.h"
28 #include <vtkUnstructuredGridAlgorithm.h>
35 #pragma warning ( disable:4251 )
38 /*! \class vtkUnstructuredGridAlgorithm
39 * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
41 /*! \class vtkUnstructuredGridAlgorithm
42 * \brief For more information see VTK documentation.
44 class VTKVIEWER_EXPORT VTKViewer_ExtractUnstructuredGrid : public vtkUnstructuredGridAlgorithm
48 vtkTypeMacro( VTKViewer_ExtractUnstructuredGrid, vtkUnstructuredGridAlgorithm );
50 //! \brief Construct with all types of clipping turned off.
51 static VTKViewer_ExtractUnstructuredGrid *New();
53 enum EExtraction{ eCells, ePoints};
54 //! Sets mode of extraction to \a theExtractionMode
55 void SetModeOfExtraction(EExtraction theExtractionMode){
56 if ( myExtractionMode != theExtractionMode ) { myExtractionMode = theExtractionMode; Modified(); }
58 //! Get Extraction mode (Return: \a myExtractionMode field)
59 EExtraction GetModeOfExtraction(){ return myExtractionMode;}
61 enum EChanging{ ePassAll, eAdding, eRemoving};
62 //! Sets mode of changing to \a theChangeMode
63 void SetModeOfChanging(EChanging theChangeMode){
64 if ( myChangeMode != theChangeMode ) { myChangeMode = theChangeMode; Modified(); }
66 //! Return \a myChangeMode field
67 EChanging GetModeOfChanging(){ return myChangeMode; }
69 //! Add cell id to \a myCellIds std::set
70 void RegisterCell(vtkIdType theCellId);
71 //! Check if myCellIds is empty.
72 int IsCellsRegistered() { return !myCellIds.empty(); }
73 //! Remove the cell from the output
74 void ClearRegisteredCells() {
75 if ( !myCellIds.empty() ) { myCellIds.clear(); Modified(); }
78 //! Add cell type to \a myCellTypes std::set
79 void RegisterCellsWithType(vtkIdType theCellType);
80 //! Check if myCellTypes is empty.
81 int IsCellsWithTypeRegistered() { return !myCellTypes.empty(); }
82 //! Remove every cells with the type from the output
83 void ClearRegisteredCellsWithType() {
84 if ( !myCellTypes.empty() ) { myCellTypes.clear(); Modified(); }
87 //! \brief Do the filter do some real work
88 int IsChanging() { return IsCellsRegistered() || IsCellsWithTypeRegistered(); }
90 //! \brief Do it keep the mapping between input's and output's UnstructuredGrid
91 void SetStoreMapping(int theStoreMapping);
92 //! Get \a myStoreMapping
93 int GetStoreMapping(){ return myStoreMapping; }
95 //! Computes a map out IDs to in IDs. Call it before GetInputId()!!!
96 void BuildOut2InMap();
97 //! Gets the input id by output id. Call BuildOut2InMap() before
98 vtkIdType GetInputId(int theOutId) const;
99 //! Gets the output id by input id.
100 //vtkIdType GetOutputId(int theInId) const;
102 typedef std::vector<vtkIdType> TVectorId;
103 typedef std::map<vtkIdType,vtkIdType> TMapId;
104 typedef std::set<vtkIdType> TSetId;
107 VTKViewer_ExtractUnstructuredGrid();
108 ~VTKViewer_ExtractUnstructuredGrid();
110 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
112 EExtraction myExtractionMode;
114 EChanging myChangeMode;
118 bool myStoreMapping, myPassAll;
119 TVectorId myOut2InId;
124 VTKViewer_ExtractUnstructuredGrid(const VTKViewer_ExtractUnstructuredGrid&);
126 void operator=(const VTKViewer_ExtractUnstructuredGrid&);
130 #pragma warning ( default:4251 )