added methods to convert between Cartesian and spherical coordinates
[engrid-github.git] / src / libengrid / vtkEgBoundaryCodesFilter.cxx
blobeaa77c9a6df6dc0b17e594383dd8fb8f6b799552
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 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) {
43 double x[3];
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) {
50 vtkIdType *pts;
51 vtkIdType npts;
52 bool add = false;
53 if (!cell_code) {
54 add = false;
56 else {
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;
63 if (add) {
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]);
73 m_Output->Squeeze();