ITK/Examples/Developer/SetGetMacro: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==SetGetMacro.cxx== <source lang="cpp"> #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "ImageFilter.h" int main(int, char*[]) { ...")
 
(Deprecated content that is moved to sphinx)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
==SetGetMacro.cxx==
{{warning|1=The media wiki content on this page is no longer maintainedThe examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
<source lang="cpp">
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
 
#include "ImageFilter.h"
 
int main(int, char*[])
{
  // Setup types
  typedef itk::Image<unsigned char, 2>  ImageType;
  typedef itk::ImageFilter<ImageType> FilterType;
 
  // Create and the filter
  FilterType::Pointer filter = FilterType::New();
  filter->Update();
 
  return EXIT_SUCCESS;
}
</source>
 
==ImageFilter.h==
<source lang="cpp">
#ifndef __itkImageFilter_h
#define __itkImageFilter_h
 
#include "itkImageToImageFilter.h"
 
namespace itk
{
template< class TImage>
class ImageFilter:public ImageToImageFilter< TImage, TImage >
{
public:
 
  /** Standard class typedefs. */
  typedef ImageFilter            Self;
  typedef ImageToImageFilter< TImage, TImage > Superclass;
  typedef SmartPointer< Self >        Pointer;
 
  /** Method for creation through the object factory. */
  itkNewMacro(Self);
 
  /** Run-time type information (and related methods). */
   itkTypeMacro(ImageFilter, ImageToImageFilter);
 
  itkSetMacro( Variable, double );
  itkGetMacro( Variable, double);
 
protected:
  ImageFilter(){}
  ~ImageFilter(){}
 
  /** Does the real work. */
  virtual void GenerateData();
 
  double m_Variable;
 
private:
  ImageFilter(const Self &); //purposely not implemented
  void operator=(const Self &);  //purposely not implemented
 
};
} //namespace ITK
 
 
#ifndef ITK_MANUAL_INSTANTIATION
#include "ImageFilter.txx"
#endif
 
 
#endif // __itkImageFilter_h
</source>
 
==ImageFilter.txx==
<source lang="cpp">
#ifndef __itkImageFilter_txx
#define __itkImageFilter_txx
 
#include "ImageFilter.h"
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
 
namespace itk
{
 
template< class TImage>
void ImageFilter< TImage>
::GenerateData()
{
 
}
 
}// end namespace
 
 
#endif
</source>
 
{{ITKCMakeLists|SetGetMacro}}

Latest revision as of 19:50, 7 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.