slider for smoothing
[engrid-github.git] / src / libengrid / vtkEgBoundaryCodesFilter.cxx
blob6e820e69033c68ea2adf7b4cd08d8c667f3f0e7a
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 #include "vtkEgBoundaryCodesFilter.h"
23 #include <vtkObjectFactory.h>
24 #include <vtkInformation.h>
25 #include <vtkDataObject.h>
26 #include <vtkPolyData.h>
27 #include <vtkUnstructuredGrid.h>
28 #include <vtkSmartPointer.h>
29 #include <vtkCellData.h>
30 #include <vtkIntArray.h>
32 vtkStandardNewMacro(vtkEgBoundaryCodesFilter)
34 void vtkEgBoundaryCodesFilter::ExecuteEg()
36 EG_VTKDCC(vtkIntArray,cell_code,m_Input,"cell_code");
38 // copy the node coordinates
39 allocateGrid(m_Output, m_Input->GetNumberOfCells(), m_Input->GetNumberOfPoints());
40 for (vtkIdType vertId = 0; vertId < m_Input->GetNumberOfPoints(); ++vertId) {
41 double x[3];
42 m_Input->GetPoints()->GetPoint(vertId,x);
43 m_Output->GetPoints()->SetPoint(vertId,x);
46 // copy the cells and the cell/node data
47 for (vtkIdType cellId = 0; cellId < m_Input->GetNumberOfCells(); ++cellId) {
48 vtkIdType *pts;
49 vtkIdType npts;
50 bool add = false;
51 if (!cell_code) {
52 add = false;
54 else {
55 if (m_BoundaryCodes.contains(cell_code->GetValue(cellId))) {
56 if (m_Input->GetCellType(cellId) == VTK_TRIANGLE) add = true;
57 if (m_Input->GetCellType(cellId) == VTK_QUAD) add = true;
58 if (m_Input->GetCellType(cellId) == VTK_POLYGON) add = true;
62 if (add) {
63 m_Input->GetCellPoints(cellId,npts,pts);
64 vtkIdType newCell = m_Output->InsertNextCell(m_Input->GetCellType(cellId),npts,pts);
65 copyCellData(m_Input, cellId, m_Output, newCell);
66 for(int i = 0; i < npts; i++) {
67 if (pts[i] >= m_Input->GetNumberOfPoints()) {
68 EG_BUG;
70 if (pts[i] >= m_Output->GetNumberOfPoints()) {
71 EG_BUG;
73 copyNodeData(m_Input, pts[i], m_Output, pts[i]);
78 m_Output->Squeeze();