1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
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. +
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. +
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/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "vtkEgBoundaryCodesFilter.h"
24 #include <vtkObjectFactory.h>
25 #include <vtkInformation.h>
26 #include <vtkDataObject.h>
27 #include <vtkPolyData.h>
28 #include <vtkUnstructuredGrid.h>
29 #include <vtkSmartPointer.h>
30 #include <vtkCellData.h>
31 #include <vtkIntArray.h>
33 vtkStandardNewMacro(vtkEgBoundaryCodesFilter
)
35 void vtkEgBoundaryCodesFilter::ExecuteEg()
37 EG_VTKDCC(vtkIntArray
,cell_code
,m_Input
,"cell_code");
39 // copy the node coordinates
40 allocateGrid(m_Output
, m_Input
->GetNumberOfCells(), m_Input
->GetNumberOfPoints());
41 for (vtkIdType vertId
= 0; vertId
< m_Input
->GetNumberOfPoints(); ++vertId
) {
43 m_Input
->GetPoints()->GetPoint(vertId
,x
);
44 m_Output
->GetPoints()->SetPoint(vertId
,x
);
47 // copy the cells and the cell/node data
48 for (vtkIdType cellId
= 0; cellId
< m_Input
->GetNumberOfCells(); ++cellId
) {
54 if (m_BoundaryCodes
.contains(cell_code
->GetValue(cellId
))) {
55 if (m_Input
->GetCellType(cellId
) == VTK_TRIANGLE
) add
= true;
56 if (m_Input
->GetCellType(cellId
) == VTK_QUAD
) add
= true;
57 if (m_Input
->GetCellType(cellId
) == VTK_POLYGON
) add
= true;
62 EG_GET_CELL(cellId
, m_Input
);
63 vtkIdType newCell
= m_Output
->InsertNextCell(m_Input
->GetCellType(cellId
), ptIds
);
64 copyCellData(m_Input
, cellId
, m_Output
, newCell
);
65 for (int i
= 0; i
< num_pts
; i
++) {
66 if (pts
[i
] >= m_Input
->GetNumberOfPoints()) {
68 } else if (pts
[i
] >= m_Output
->GetNumberOfPoints()) {
71 copyNodeData(m_Input
, pts
[i
], m_Output
, pts
[i
]);