Added getNeighbours functions to class Operation + moved UpdateMeshDensity to class...
[engrid.git] / vtkEgBoundaryCodesFilter.cxx
blobb8534da579e428a4654320f6175078a19b2484b9
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008 Oliver Gloth +
7 // + +
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. +
12 // + +
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. +
17 // + +
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/>. +
20 // + +
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 // the coordinates of the nodes
39 allocateGrid(output, input->GetNumberOfCells(), input->GetNumberOfPoints());
40 for (vtkIdType vertId = 0; vertId < input->GetNumberOfPoints(); ++vertId) {
41 double x[3];
42 input->GetPoints()->GetPoint(vertId,x);
43 output->GetPoints()->SetPoint(vertId,x);
46 EG_VTKDCC(vtkIntArray,cell_code,input,"cell_code");
48 // the cells
49 for (vtkIdType cellId = 0; cellId < input->GetNumberOfCells(); ++cellId) {
50 vtkIdType *pts;
51 vtkIdType npts;
52 bool add = false;
53 if (!cell_code || !BoundaryCodes) {
54 add = false;
55 } else if (BoundaryCodes->contains(cell_code->GetValue(cellId))) {
56 if (input->GetCellType(cellId) == VTK_TRIANGLE) add = true;
57 if (input->GetCellType(cellId) == VTK_QUAD) add = true;
59 if (add) {
60 input->GetCellPoints(cellId,npts,pts);
61 vtkIdType newCell = output->InsertNextCell(input->GetCellType(cellId),npts,pts);
62 copyCellData(input, cellId, output, newCell);
66 output->Squeeze();