#ifndef __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__ #define __CPEXTENSIONS__ALGORITHMS__MACHETEIMAGEFILTER__HXX__ #include //filter stuff #include "itkObjectFactory.h" #include "itkImageRegionIterator.h" #include "itkImageRegionConstIterator.h" //typedef itk::Image ImageType; template< class I, class O> void cpExtensions::Algorithms::MacheteImageFilter< I, O> ::GenerateData() { //const typename Superclass::OutputImageRegionType& region; typename I::ConstPointer input = this->GetInput(); typename O::Pointer output = this->GetOutput(); output->SetRegions(input->GetLargestPossibleRegion()); output->Allocate(); itk::ImageRegionIterator outputIterator(output, output->GetLargestPossibleRegion()); itk::ImageRegionConstIterator inputIterator(input, input->GetLargestPossibleRegion()); while (!outputIterator.IsAtEnd()) { auto p0 = inputIterator.GetIndex(); itk::Point otherPoint; otherPoint[0] = p0[0]; otherPoint[1] = p0[1]; otherPoint[2] = p0[2]; //otherPoint[2] = this->point[2]; // TODO : Solve this hammer double dist = this->point.EuclideanDistanceTo(otherPoint); if (dist <= this->m_Radius) { outputIterator.Set(0); } else { outputIterator.Set(inputIterator.Get()); } ++inputIterator; ++outputIterator; } } template< class I, class O> void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetRadius(const RadiusType & rad) { if (this->m_Radius != rad) { this->m_Radius = rad; this->Modified(); } } //template< class I, class O> //void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetRadius(const RadiusValueType & rad) //{ // RadiusType r; // r.Fill(rad); // this->SetRadius(r); //} template< class I, class O> void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetPoint(itk::Point & p){ if (point != p) { this->point = p; this->Modified(); } } template< class I, class O> void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetPoint(const double & x, const double & y, const double & z) { this->point[0] = x; this->point[1] = y; this->point[2] = z; this->Modified(); } #endif