| 44 | } |
| 45 | |
| 46 | void mitk::ReduceContourSetFilter::GenerateData() |
| 47 | { |
| 48 | unsigned int numberOfInputs = this->GetNumberOfIndexedInputs(); |
| 49 | unsigned int numberOfOutputs(0); |
| 50 | |
| 51 | vtkSmartPointer<vtkPolyData> newPolyData; |
| 52 | vtkSmartPointer<vtkCellArray> newPolygons; |
| 53 | vtkSmartPointer<vtkPoints> newPoints; |
| 54 | |
| 55 | // For the purpose of evaluation |
| 56 | // unsigned int numberOfPointsBefore (0); |
| 57 | m_NumberOfPointsAfterReduction = 0; |
| 58 | |
| 59 | for (unsigned int i = 0; i < numberOfInputs; i++) |
| 60 | { |
| 61 | auto *currentSurface = this->GetInput(i); |
| 62 | vtkSmartPointer<vtkPolyData> polyData = currentSurface->GetVtkPolyData(); |
| 63 | |
| 64 | newPolyData = vtkSmartPointer<vtkPolyData>::New(); |
| 65 | newPolygons = vtkSmartPointer<vtkCellArray>::New(); |
| 66 | newPoints = vtkSmartPointer<vtkPoints>::New(); |
| 67 | |
| 68 | vtkSmartPointer<vtkCellArray> existingPolys = polyData->GetPolys(); |
| 69 | |
| 70 | vtkSmartPointer<vtkPoints> existingPoints = polyData->GetPoints(); |
| 71 | |
| 72 | existingPolys->InitTraversal(); |
| 73 | |
| 74 | const vtkIdType *cell(nullptr); |
| 75 | vtkIdType cellSize(0); |
| 76 | |
| 77 | for (existingPolys->InitTraversal(); existingPolys->GetNextCell(cellSize, cell);) |
| 78 | { |
| 79 | bool incorporatePolygon = |
| 80 | this->CheckForIntersection(cell, cellSize, existingPoints, /*numberOfIntersections, intersectionPoints, */ i); |
| 81 | if (!incorporatePolygon) |
| 82 | continue; |
| 83 | |
| 84 | vtkSmartPointer<vtkPolygon> newPolygon = vtkSmartPointer<vtkPolygon>::New(); |
| 85 | |
| 86 | if (m_ReductionType == NTH_POINT) |
| 87 | { |
| 88 | this->ReduceNumberOfPointsByNthPoint(cellSize, cell, existingPoints, newPolygon, newPoints); |
| 89 | if (newPolygon->GetPointIds()->GetNumberOfIds() != 0) |
| 90 | { |
| 91 | newPolygons->InsertNextCell(newPolygon); |
| 92 | } |
| 93 | } |
| 94 | else if (m_ReductionType == DOUGLAS_PEUCKER) |
| 95 | { |
| 96 | this->ReduceNumberOfPointsByDouglasPeucker(cellSize, cell, existingPoints, newPolygon, newPoints); |
| 97 | if (newPolygon->GetPointIds()->GetNumberOfIds() > 3) |
| 98 | { |
| 99 | newPolygons->InsertNextCell(newPolygon); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // Again for evaluation |
nothing calls this directly
no test coverage detected