updated to modern VTK
[engrid-github.git] / src / libengrid / vtkEgGridFilter.h
blob87733a7fdcfea0d9d26866dee7249362d91066b0
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
11 // + +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
16 // + +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #ifndef __vtkEgGridFilter_h
22 #define __vtkEgGridFilter_h
24 class vtkEgGridFilter;
26 #include <vtkUnstructuredGridAlgorithm.h>
27 #include <vtkUnstructuredGrid.h>
28 #include <vtkIntArray.h>
29 #include <vtkLongArray.h>
30 #include <vtkDoubleArray.h>
31 #include <vtkCellData.h>
32 #include <vtkCellType.h>
33 #include <vtkCellLinks.h>
34 #include <vtkObjectFactory.h>
36 #include <QVector>
38 #include "engrid.h"
39 #include "egvtkobject.h"
41 class vtkEgGridFilter : public vtkUnstructuredGridAlgorithm, public EgVtkObject
44 protected: // attributes
46 QSet<int> m_BoundaryCodes;
47 vtkUnstructuredGrid *m_Input;
48 vtkUnstructuredGrid *m_Output;
49 vtkUnstructuredGrid *m_LastOutput;
50 unsigned long m_LastRun;
52 protected: // methods
54 vtkEgGridFilter();
55 ~vtkEgGridFilter();
57 virtual int FillInputPortInformation(int, vtkInformation* info);
58 virtual int FillOutputPortInformation(int, vtkInformation* info);
59 virtual int RequestData(vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector);
61 virtual void ExecuteEg() = 0;
63 /**
64 * Extract boundary elements and nodes with a given set of boundary conditions
65 * @param cells On return, this will contain the indexes of the extracted boundary elements.
66 * @param modes On return, this will contain the indexes of the extracted boundary nodes.
67 * @param grid The grid to operate on.
68 * @param bc_c A Qt container with the boundary conditions to extract.
70 void ExtractBoundary(QVector<vtkIdType> &cells, QVector<vtkIdType> &nodes, QSet<int> &bc_c, vtkUnstructuredGrid *grid);
72 public: // methods
74 template <typename C>
75 void SetBoundaryCodes(const C& bc);
76 virtual void Update() { vtkAlgorithm::Update(); ExecuteEg(); }
80 template <typename C>
81 void vtkEgGridFilter::SetBoundaryCodes(const C &bc_c)
83 bool update = false;
85 QSet<int> bc_set;
86 foreach (int bc , bc_c) {
87 bc_set.insert(bc);
90 if (m_BoundaryCodes.size() != bc_set.size()) {
91 update = true;
92 } else {
93 QSet<int> bc_inters = m_BoundaryCodes.intersect(bc_set);
94 if (bc_inters.size() != bc_set.size()) {
95 update = true;
98 if (update) {
99 m_BoundaryCodes = bc_set;
100 Modified();
105 #endif