diff --git a/Modules/SurfaceInterpolation/files.cmake b/Modules/SurfaceInterpolation/files.cmake index 0dd9c14810..03b27ed22b 100644 --- a/Modules/SurfaceInterpolation/files.cmake +++ b/Modules/SurfaceInterpolation/files.cmake @@ -1,6 +1,7 @@ set(CPP_FILES + mitkClusteredPlaneSuggestionFilter.cpp mitkComputeContourSetNormalsFilter.cpp mitkCreateDistanceImageFromSurfaceFilter.cpp mitkReduceContourSetFilter.cpp mitkSurfaceInterpolationController.cpp -) \ No newline at end of file +) diff --git a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp new file mode 100644 index 0000000000..257718a435 --- /dev/null +++ b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp @@ -0,0 +1,82 @@ +/*=================================================================== + +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 + +#include +#include +#include +#include + +#include +#include +#include + + +mitk::ClusteredPlaneSuggestionFilter::ClusteredPlaneSuggestionFilter(): m_Meshing(false), m_MinPts(4), m_Eps(1.2) +{ + this->m_UnstructGrid = mitk::UnstructuredGrid::New(); + this->m_GeoData = mitk::GeometryData::New(); +} + +mitk::ClusteredPlaneSuggestionFilter::~ClusteredPlaneSuggestionFilter(){} + +void mitk::ClusteredPlaneSuggestionFilter::GenerateData() +{ + mitk::UnstructuredGrid::Pointer inpGrid = const_cast(this->GetInput()); + + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(inpGrid); + clusterFilter->SetMeshing(false); + clusterFilter->SetMinPts(4); + clusterFilter->Seteps(1.2); + clusterFilter->Update(); + + vtkSmartPointer< vtkUnstructuredGrid > vtkGrid = clusterFilter->GetOutput()->GetVtkUnstructuredGrid(); + m_UnstructGrid->SetVtkUnstructuredGrid(vtkGrid); + + //Generate a pointset from UnstructuredGrid for the PlaneFitFilter: + mitk::PointSet::Pointer pointset = mitk::PointSet::New(); + + for(int i=0; iGetNumberOfPoints();i++) + { + mitk::Point3D point; + point[0] = vtkGrid->GetPoint(i)[0]; + point[1] = vtkGrid->GetPoint(i)[1]; + point[2] = vtkGrid->GetPoint(i)[2]; + + pointset->InsertPoint(i,point); + } + + mitk::PlaneFit::Pointer planeFilter = mitk::PlaneFit::New(); + planeFilter->SetInput(pointset); + planeFilter->Update(); + + m_GeoData = planeFilter->GetOutput(); + +// mitk::PlaneGeometry* planeGeometry = dynamic_cast( planeFilter->GetOutput()->GetGeometry()); +} + +void mitk::ClusteredPlaneSuggestionFilter::GenerateOutputInformation() +{ + mitk::UnstructuredGrid::ConstPointer inputImage = this->GetInput(); + + m_UnstructGrid = this->GetOutput(); + + itkDebugMacro(<<"GenerateOutputInformation()"); + + if(inputImage.IsNull()) return; +} diff --git a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h new file mode 100644 index 0000000000..e50defce6f --- /dev/null +++ b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h @@ -0,0 +1,85 @@ +/*=================================================================== + +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 _MITKCLUSTEREDPLANESUGGESTIONFILTER_h__ +#define _MITKCLUSTEREDPLANESUGGESTIONFILTER_h__ + +#include + +#include + +#include +#include +#include + +#include +#include + + +namespace mitk { + + class MitkSurfaceInterpolation_EXPORT ClusteredPlaneSuggestionFilter + : public UnstructuredGridToUnstructuredGridFilter + { + public: + + mitkClassMacro(ClusteredPlaneSuggestionFilter, + UnstructuredGridToUnstructuredGridFilter) + + itkFactorylessNewMacro(Self) + + itkCloneMacro(Self) + + itkGetMacro(GeoData, mitk::GeometryData::Pointer) + itkGetMacro(Meshing, bool) + itkGetMacro(MinPts, int) + itkGetMacro(Eps, double) + + itkSetMacro(Meshing, bool) + itkSetMacro(MinPts, int) + itkSetMacro(Eps, double) + + + protected: + + ClusteredPlaneSuggestionFilter(); + + virtual ~ClusteredPlaneSuggestionFilter(); + + virtual void GenerateData(); + + virtual void GenerateOutputInformation(); + + + private: + + mitk::GeometryData::Pointer m_GeoData; + + mitk::UnstructuredGrid::Pointer m_UnstructGrid; + + bool m_Meshing; + + int m_MinPts; + + double m_Eps; + + }; + +} // namespace mitk + +#endif //_MITKCLUSTEREDPLANESUGGESTIONFILTER_h__ + +