2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "vtkEgBoundaryCodesFilter.h"
25 #include <vtkObjectFactory.h>
26 #include <vtkInformation.h>
27 #include <vtkDataObject.h>
28 #include <vtkPolyData.h>
29 #include <vtkUnstructuredGrid.h>
30 #include <vtkSmartPointer.h>
31 #include <vtkCellData.h>
32 #include <vtkIntArray.h>
34 vtkStandardNewMacro(vtkEgBoundaryCodesFilter
)
36 void vtkEgBoundaryCodesFilter::ExecuteEg()
38 EG_VTKDCC(vtkIntArray
,cell_code
,m_Input
,"cell_code");
40 // copy the node coordinates
41 allocateGrid(m_Output
, m_Input
->GetNumberOfCells(), m_Input
->GetNumberOfPoints());
42 for (vtkIdType vertId
= 0; vertId
< m_Input
->GetNumberOfPoints(); ++vertId
) {
44 m_Input
->GetPoints()->GetPoint(vertId
,x
);
45 m_Output
->GetPoints()->SetPoint(vertId
,x
);
48 // copy the cells and the cell/node data
49 for (vtkIdType cellId
= 0; cellId
< m_Input
->GetNumberOfCells(); ++cellId
) {
57 if (m_BoundaryCodes
.contains(cell_code
->GetValue(cellId
))) {
58 if (m_Input
->GetCellType(cellId
) == VTK_TRIANGLE
) add
= true;
59 if (m_Input
->GetCellType(cellId
) == VTK_QUAD
) add
= true;
64 m_Input
->GetCellPoints(cellId
,npts
,pts
);
65 vtkIdType newCell
= m_Output
->InsertNextCell(m_Input
->GetCellType(cellId
),npts
,pts
);
66 copyCellData(m_Input
, cellId
, m_Output
, newCell
);
67 for(int i
= 0; i
< npts
; i
++) {
68 copyNodeData(m_Input
, pts
[i
], m_Output
, pts
[i
]);