diff --git a/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.cpp b/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.cpp index 0a71bbdd08..b45d410b51 100644 --- a/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.cpp +++ b/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.cpp @@ -1,142 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPointCloudScoringFilter.h" #include #include #include #include #include #include +#include +#include mitk::PointCloudScoringFilter::PointCloudScoringFilter(): m_NumberOfOutpPoints(0) { - m_OutpSurface = mitk::Surface::New(); + m_OutpGrid = mitk::UnstructuredGrid::New(); // this->SetNumberOfRequiredInputs(2); // this->SetNumberOfRequiredOutputs(1); - this->SetNthOutput(0, m_OutpSurface); + this->SetNthOutput(0, m_OutpGrid); } mitk::PointCloudScoringFilter::~PointCloudScoringFilter(){} void mitk::PointCloudScoringFilter::GenerateData() { - if(SurfaceToSurfaceFilter::GetNumberOfInputs()!=2) + if(UnstructuredGridToUnstructuredGridFilter::GetNumberOfInputs()!=2) { MITK_ERROR << "Not enough input arguments for PointCloudScoringFilter" << std::endl; return; } - DataObjectPointerArray inputs = SurfaceToSurfaceFilter::GetInputs(); - mitk::Surface::Pointer edgeSurface = dynamic_cast(inputs.at(0).GetPointer()); - mitk::Surface::Pointer segmSurface = dynamic_cast(inputs.at(1).GetPointer()); + DataObjectPointerArray inputs = UnstructuredGridToUnstructuredGridFilter::GetInputs(); + mitk::UnstructuredGrid::Pointer edgeGrid = dynamic_cast(inputs.at(0).GetPointer()); + mitk::UnstructuredGrid::Pointer segmGrid = dynamic_cast(inputs.at(1).GetPointer()); - if(edgeSurface->IsEmpty() || segmSurface->IsEmpty()) + if(edgeGrid->IsEmpty() || segmGrid->IsEmpty()) { - if(edgeSurface->IsEmpty()) - MITK_ERROR << "Cannot convert EdgeSurface into Surfaces" << std::endl; - if(segmSurface->IsEmpty()) - MITK_ERROR << "Cannot convert SegmSurface into Surfaces" << std::endl; + if(edgeGrid->IsEmpty()) + MITK_ERROR << "Cannot convert edgeGrid into Surfaces" << std::endl; + if(segmGrid->IsEmpty()) + MITK_ERROR << "Cannot convert segmGrid into Surfaces" << std::endl; } - vtkSmartPointer edgePolyData = edgeSurface->GetVtkPolyData(); - vtkSmartPointer segmPolyData = segmSurface->GetVtkPolyData(); + vtkSmartPointer edgevtkGrid = edgeGrid->GetVtkUnstructuredGrid(); + vtkSmartPointer segmvtkGrid = segmGrid->GetVtkUnstructuredGrid(); // KdTree from here vtkSmartPointer kdPoints = vtkSmartPointer::New(); vtkSmartPointer kdTree = vtkSmartPointer::New(); - for(int i=0; iGetNumberOfPoints(); i++) + for(int i=0; iGetNumberOfPoints(); i++) { - kdPoints->InsertNextPoint(edgePolyData->GetPoint(i)); + kdPoints->InsertNextPoint(edgevtkGrid->GetPoint(i)); } kdTree->BuildLocatorFromPoints(kdPoints); // KdTree until here vtkSmartPointer points = vtkSmartPointer::New(); - for(int i=0; iGetNumberOfPoints(); i++) + for(int i=0; iGetNumberOfPoints(); i++) { - points->InsertNextPoint(segmPolyData->GetPoint(i)); + points->InsertNextPoint(segmvtkGrid->GetPoint(i)); } std::vector< ScorePair > score; double dist_glob; double dist; for(int i=0; iGetNumberOfPoints(); i++) { double point[3]; points->GetPoint(i,point); kdTree->FindClosestPoint(point[0],point[1],point[2],dist); dist_glob+=dist; score.push_back(std::make_pair(i,dist)); } double avg = dist_glob / points->GetNumberOfPoints(); for(unsigned int i=0; i avg) { m_FilteredScores.push_back(std::make_pair(score.at(i).first,score.at(i).second)); } } m_NumberOfOutpPoints = m_FilteredScores.size(); - vtkSmartPointer outpSurface = vtkSmartPointer::New(); vtkSmartPointer filteredPoints = vtkSmartPointer::New(); for(unsigned int i=0; iGetPoint(m_FilteredScores.at(i).first); + point = segmvtkGrid->GetPoint(m_FilteredScores.at(i).first); filteredPoints->InsertNextPoint(point[0],point[1],point[2]); } unsigned int numPoints = filteredPoints->GetNumberOfPoints(); - vtkSmartPointer polyLine = vtkSmartPointer::New(); - polyLine->GetPointIds()->SetNumberOfIds(numPoints); + vtkSmartPointer verts = vtkSmartPointer::New(); - for(unsigned int i = 0; i < numPoints; i++) + verts->GetPointIds()->SetNumberOfIds(numPoints); + for(unsigned int i=0; iGetPointIds()->SetId(i,i); + verts->GetPointIds()->SetId(i,i); } - vtkSmartPointer cells = vtkSmartPointer::New(); - cells->InsertNextCell(polyLine); + vtkSmartPointer uGrid = vtkSmartPointer::New(); + uGrid->Allocate(1); - vtkSmartPointer polyData = vtkSmartPointer::New(); + uGrid->InsertNextCell(verts->GetCellType(), verts->GetPointIds()); + uGrid->SetPoints(filteredPoints); - polyData->SetPoints(filteredPoints); - polyData->SetLines(cells); - - outpSurface->BuildCells(); - outpSurface->BuildLinks(); - m_OutpSurface->SetVtkPolyData(polyData); + m_OutpGrid->SetVtkUnstructuredGrid(uGrid); } void mitk::PointCloudScoringFilter::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); } diff --git a/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.h b/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.h index 6c17362795..9aa8fe76c1 100644 --- a/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.h +++ b/Modules/SurfaceInterpolation/mitkPointCloudScoringFilter.h @@ -1,65 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkPointCloudScoringFilter_h_Included #define mitkPointCloudScoringFilter_h_Included #include -#include - -#include "mitkSurface.h" +#include +#include namespace mitk { class MitkSurfaceInterpolation_EXPORT PointCloudScoringFilter: - public SurfaceToSurfaceFilter + public UnstructuredGridToUnstructuredGridFilter { public: typedef std::pair ScorePair; - mitkClassMacro( PointCloudScoringFilter, SurfaceToSurfaceFilter) + mitkClassMacro( PointCloudScoringFilter, UnstructuredGridToUnstructuredGridFilter) itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkGetMacro(NumberOfOutpPoints, int) itkGetMacro(FilteredScores, std::vector< ScorePair >) protected: virtual void GenerateData(); virtual void GenerateOutputInformation(); PointCloudScoringFilter(); virtual ~PointCloudScoringFilter(); private: - mitk::Surface::Pointer m_OutpSurface; + mitk::UnstructuredGrid::Pointer m_OutpGrid; std::vector< ScorePair > m_FilteredScores; int m_NumberOfOutpPoints; }; } #endif