diff --git a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp index 3ee86c6d59..a810997461 100644 --- a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp +++ b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.cpp @@ -1,102 +1,96 @@ /*=================================================================== 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 #include mitk::ClusteredPlaneSuggestionFilter::ClusteredPlaneSuggestionFilter(): m_Meshing(false), m_MinPts(4), m_Eps(1.2) { this->m_MainCluster = mitk::UnstructuredGrid::New(); this->m_GeoData = mitk::GeometryData::New(); } mitk::ClusteredPlaneSuggestionFilter::~ClusteredPlaneSuggestionFilter(){} void mitk::ClusteredPlaneSuggestionFilter::GenerateData() { mitk::UnstructuredGrid::Pointer inpGrid = const_cast(this->GetInput()); if(inpGrid.IsNull()) { MITK_ERROR << "Input or cast to UnstructuredGrid is null"; return; } mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); clusterFilter->SetInput(inpGrid); - clusterFilter->SetMeshing(false); - clusterFilter->SetMinPts(4); - clusterFilter->Seteps(1.2); + clusterFilter->SetMeshing(m_Meshing); + clusterFilter->SetMinPts(m_MinPts); + clusterFilter->Seteps(m_Eps); clusterFilter->Update(); + //need the get and set the vtkUnstructuredGrid instead of the mitkUnstructuredGrid, otherwise rendering error vtkSmartPointer< vtkUnstructuredGrid > vtkGrid = clusterFilter->GetOutput()->GetVtkUnstructuredGrid(); if(!vtkGrid) { MITK_ERROR << "vtkUnstructuredGrid output from clustering is null"; return; } m_MainCluster->SetVtkUnstructuredGrid(vtkGrid); m_Clusters = clusterFilter->GetAllClusters(); //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(); if(m_GeoData.IsNull()) { MITK_ERROR << "GeometryData output from PlaneFit filter is null"; return; } - -// mitk::PlaneGeometry* planeGeometry = dynamic_cast( planeFilter->GetOutput()->GetGeometry()); } void mitk::ClusteredPlaneSuggestionFilter::GenerateOutputInformation() { mitk::UnstructuredGrid::ConstPointer inputImage = this->GetInput(); m_MainCluster = this->GetOutput(); itkDebugMacro(<<"GenerateOutputInformation()"); if(inputImage.IsNull()) return; } diff --git a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h index b3f6b86cd6..6697e41698 100644 --- a/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h +++ b/Modules/SurfaceInterpolation/mitkClusteredPlaneSuggestionFilter.h @@ -1,88 +1,112 @@ /*=================================================================== 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 +#include namespace mitk { + /** + * @brief Clustering an UnstructuredGrid and calculating a Plane through it. + * + * The output is the biggest found cluster but you can get all clusters in a + * std::vector represented by vtkPoints. Use GetClusters() the get the vector. + * With GetGeoData() you get the calculated geometry as a mitk::GeometryData. + * Internally the mitk::UnstructuredGridClusteringFilter is used for + * clustering and after the mitk::PlaneFit for calculating the plane. + * The parameters m_Meshing (Set/GetMeshing()), m_MinPts (Set/GetMinPts()) and + * m_Eps (Set/GetEps()) are used for the UnstructuredGridClusteringFilter. + */ class MitkSurfaceInterpolation_EXPORT ClusteredPlaneSuggestionFilter : public UnstructuredGridToUnstructuredGridFilter { public: mitkClassMacro(ClusteredPlaneSuggestionFilter, UnstructuredGridToUnstructuredGridFilter) itkFactorylessNewMacro(Self) itkCloneMacro(Self) + /** Returns the geometry of the calculated plane from mitk::PlaneFit */ itkGetMacro(GeoData, mitk::GeometryData::Pointer) + + /** Returns all clusters which were found by the clustering filter */ itkGetMacro(Clusters, std::vector< mitk::UnstructuredGrid::Pointer >) - itkGetMacro(Meshing, bool) - itkGetMacro(MinPts, int) - itkGetMacro(Eps, double) + /** Activate the meshing function for the returned clusters. The meshing + * is needed to see the result in the 2D-renderwindows */ + itkGetMacro(Meshing, bool) itkSetMacro(Meshing, bool) + + /** Minimal points which have to be located in the neighbourhood to define + * the point as a core point. For more information see DBSCAN algorithm */ + itkGetMacro(MinPts, int) itkSetMacro(MinPts, int) + + /** The range/neighbourhood for clustering the points. For more + * information see DBSCAN algorithm */ + itkGetMacro(Eps, double) itkSetMacro(Eps, double) protected: + /** Constructor */ ClusteredPlaneSuggestionFilter(); + /** Destructor */ virtual ~ClusteredPlaneSuggestionFilter(); + /** Is called by the Update() method of the filter */ virtual void GenerateData(); + /** Defines the output of the filter */ virtual void GenerateOutputInformation(); private: + /** The geometry of the calculated plane */ mitk::GeometryData::Pointer m_GeoData; + /** The vector which holds all found clusters */ std::vector< mitk::UnstructuredGrid::Pointer > m_Clusters; + /** The biggest found cluster - the output */ mitk::UnstructuredGrid::Pointer m_MainCluster; + /** Connect the points to meshes. Required for 2D rendering */ bool m_Meshing; + /** Number of points required to define a core point */ int m_MinPts; + /** The distance/neighbourhood for clustering */ double m_Eps; }; } // namespace mitk #endif //_MITKCLUSTEREDPLANESUGGESTIONFILTER_h__ - -