/** Run-time type information (and related methods). */
itkTypeMacro(MacheteImageFilter, ImageToImageFilter);
+
+ typedef typename I::PixelType RadiusType;
+ //typedef typename I::SizeValueType RadiusValueType;
+
+ itkGetConstReferenceMacro(Radius, RadiusType);
- void SetRadius(double radius);
- void SetPoint(itk::Point<double, 3> point);
+
+ void SetRadius(const RadiusType & rad);
+ //void SetRadius(const RadiusValueType & rad);
+
+ void SetPoint(itk::Point<double, 3> & point);
+ void SetPoint(const double & x, const double & y, const double & z);
protected:
MacheteImageFilter(){}
/** Does the real work. */
virtual void GenerateData();
+ RadiusType m_Radius;
+ itk::Point<double, 3> point;
private:
MacheteImageFilter(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
- double radius;
- itk::Point<double, 3> point;
+
};
} // ecapseman
otherPoint[0] = p0[0];
otherPoint[1] = p0[1];
otherPoint[2] = p0[2];
- otherPoint[2] = this->point[2]; // TODO : Solve this hammer
+ //otherPoint[2] = this->point[2]; // TODO : Solve this hammer
double dist = this->point.EuclideanDistanceTo(otherPoint);
- if (dist <= this->radius)
+ if (dist <= this->m_Radius)
{
outputIterator.Set(0);
}
++outputIterator;
}
+
}
template< class I, class O>
-void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetRadius(double rad){
- this->radius = rad;
+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<double, 3> point){
- this->point = point;
+void cpExtensions::Algorithms::MacheteImageFilter< I, O>::SetPoint(itk::Point<double, 3> & 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();
+}
// -------------------------------------------------------------------------
cpPlugins::BasicFilters::MacheteImageFilter::
-MacheteImageFilter( )
- : Superclass( )
+MacheteImageFilter()
+: Superclass()
{
- this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddInput("Input");
+ this->_MakeOutput< cpPlugins::Interface::Image >("Output");
+
+ this->m_Parameters->ConfigureAsReal("Radius", 20);
+ //this->m_Parameters->ConfigureAsPoint("Point", 3, 3);
+ this->m_Parameters->ConfigureAsReal("X", 30);
+ this->m_Parameters->ConfigureAsReal("Y", 30);
+ this->m_Parameters->ConfigureAsReal("Z", 30);
+
- this->m_Parameters->ConfigureAsUint( "Radius", 2 );
-
}
// -------------------------------------------------------------------------
cpPlugins::BasicFilters::MacheteImageFilter::
-~MacheteImageFilter( )
+~MacheteImageFilter()
{
}
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::MacheteImageFilter::
-_GenerateData( )
+_GenerateData()
{
cpPlugins::Interface::Image* image =
- this->GetInput< cpPlugins::Interface::Image >( "Input" );
- if( image == NULL )
- return( "MacheteImageFilter: No input image." );
+ this->GetInput< cpPlugins::Interface::Image >("Input");
+ if (image == NULL)
+ return("MacheteImageFilter: No input image.");
itk::DataObject* itk_image = NULL;
std::string r = "";
- cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
- else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
- else cpPlugins_Image_Demangle_AllScalarTypes( 4, image, itk_image, r, _GD0 );
+ cpPlugins_Image_Demangle_AllScalarTypes(2, image, itk_image, r, _GD0);
+ else cpPlugins_Image_Demangle_AllScalarTypes(3, image, itk_image, r, _GD0);
+ else cpPlugins_Image_Demangle_AllScalarTypes(4, image, itk_image, r, _GD0);
else r = "MacheteImageFilter: Input image type not supported.";
- return( r );
+ return(r);
}
// -------------------------------------------------------------------------
template< class I >
std::string cpPlugins::BasicFilters::MacheteImageFilter::
-_GD0( itk::DataObject* image )
+_GD0(itk::DataObject* image)
{
return(
this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
- image
- )
+ image
+ )
);
}
// -------------------------------------------------------------------------
template< class I, class O >
inline std::string cpPlugins::BasicFilters::MacheteImageFilter::
-_RealGD( itk::DataObject* image )
+_RealGD(itk::DataObject* image)
{
typedef cpExtensions::Algorithms::MacheteImageFilter< I, O > _F;
- //typedef typename _F::radius _RT;
+ typedef typename I::PixelType _RT;
// Get parameters
- //_RT rad_val;
- //rad_val.Fill( this->m_Parameters->GetUint( "Radius" ) );
+
+ _RT rad_val = _RT(this->m_Parameters->GetReal("Radius"));
+
+ double pointx = this->m_Parameters->GetReal("X");
+ double pointy = this->m_Parameters->GetReal("Y");
+ double pointz = this->m_Parameters->GetReal("Z");
// Configure filter
+ _F* filter = this->_CreateITK< _F >();
+ filter->SetInput(dynamic_cast<I*>(image));
+ filter->SetRadius(rad_val);
+
+ filter->SetPoint(pointx, pointy, pointz);
- _F* filter = this->_CreateITK< _F >();
- filter->SetInput(dynamic_cast< I* >(image));
- filter->SetRadius(this->m_Parameters->GetUint("Radius"));
filter->Update();
- //_F* filter = this->_CreateITK< _F >( );
- //filter->SetInput( dynamic_cast< I* >( image ) );
- //filter->Update( );
-
// Connect output
cpPlugins::Interface::Image* out =
- this->GetOutput< cpPlugins::Interface::Image >( "Output" );
- if( out != NULL )
+ this->GetOutput< cpPlugins::Interface::Image >("Output");
+ if (out != NULL)
{
- //out->SetITK< O >( filter->GetOutput( ) );
- return( "" );
+ out->SetITK< O >( filter->GetOutput( ) );
+ return("");
}
else
- return( "MacheteImageFilter: output not correctly created." );
+ return("MacheteImageFilter: output not correctly created.");
}
// eof - $RCSfile$