| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkConditionalConstIterator.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:34 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkConditionalConstIterator_h |
| 18 |
|
#define __itkConditionalConstIterator_h |
| 19 |
|
|
| 20 |
|
#include "itkIndex.h" |
| 21 |
|
|
| 22 |
|
namespace itk |
| 23 |
|
{ |
| 24 |
|
|
| 25 |
|
/** \class ConditionalConstIterator |
| 26 |
|
* \brief ConditionalConstIterator is a base class for other iterators where |
| 27 |
|
* membership in the set of output pixels is "conditional" upon some |
| 28 |
|
* property, calculation, etc. For example, a threshold iterator might |
| 29 |
|
* walk a region and return only those pixels which meet a minimum |
| 30 |
|
* intensity condition. |
| 31 |
|
* |
| 32 |
|
* This class is the const version of the ConditionalIterator |
| 33 |
|
* for this reason it doesn't support the Set() method. |
| 34 |
|
* |
| 35 |
|
* \ingroup ImageIterators |
| 36 |
|
*/ |
| 37 |
|
template<class TImage> |
| 38 |
|
class ConditionalConstIterator { |
| 39 |
|
public: |
| 40 |
|
/** Standard class typedefs. */ |
| 41 |
|
typedef ConditionalConstIterator Self; |
| 42 |
|
|
| 43 |
|
/** Dimension of the image the iterator walks. This constant is needed so |
| 44 |
|
* that functions that are templated over image iterator type (as opposed to |
| 45 |
|
* being templated over pixel type and dimension) can have compile time |
| 46 |
|
* access to the dimension of the image that the iterator walks. */ |
| 47 |
|
itkStaticConstMacro(NDimension, unsigned int, TImage::ImageDimension); |
| 48 |
|
|
| 49 |
|
/** Index typedef support. */ |
| 50 |
|
typedef typename TImage::IndexType IndexType; |
| 51 |
|
|
| 52 |
|
/** Size typedef support. */ |
| 53 |
|
typedef typename TImage::SizeType SizeType; |
| 54 |
|
|
| 55 |
|
/** Region typedef support. */ |
| 56 |
|
typedef typename TImage::RegionType RegionType; |
| 57 |
|
|
| 58 |
|
/** Image typedef support. */ |
| 59 |
|
typedef TImage ImageType; |
| 60 |
|
|
| 61 |
|
/** Internal Pixel Type */ |
| 62 |
|
typedef typename TImage::InternalPixelType InternalPixelType; |
| 63 |
|
|
| 64 |
|
/** External Pixel Type */ |
| 65 |
|
typedef typename TImage::PixelType PixelType; |
| 66 |
|
|
| 67 |
|
/** Compute whether the index of interest should be included in the flood */ |
| 68 |
|
virtual bool IsPixelIncluded(const IndexType & index) const = 0; |
| 69 |
|
|
| 70 |
|
/** operator= is provided to make sure the handle to the image is properly |
| 71 |
|
* reference counted. */ |
| 72 |
|
Self &operator=(const Self& it) |
| 73 |
IND |
**{ |
| 74 |
|
m_Image = it.m_Image; // copy the smart pointer |
| 75 |
|
m_Region = it.m_Region; // copy the region |
| 76 |
|
return *this; |
| 77 |
IND |
**} |
| 78 |
|
|
| 79 |
|
/** Get the dimension (size) of the index. */ |
| 80 |
|
static unsigned int GetIteratorDimension() |
| 81 |
|
{return TImage::ImageDimension;} |
| 82 |
|
|
| 83 |
|
/** Get the index at the current iterator location. */ |
| 84 |
|
virtual const IndexType GetIndex() = 0; |
| 85 |
|
|
| 86 |
|
/** Get the pixel value at the current iterator location. */ |
| 87 |
|
virtual const PixelType & Get(void) const = 0; |
| 88 |
|
|
| 89 |
|
/** Is the iterator at the end of the region? */ |
| 90 |
|
virtual bool IsAtEnd() = 0; |
| 91 |
|
|
| 92 |
|
/** Walk forward one index. */ |
| 93 |
|
virtual void operator++() = 0; |
| 94 |
|
|
| 95 |
|
/** Constructor */ |
| 96 |
|
ConditionalConstIterator(); |
| 97 |
|
|
| 98 |
|
/** Destructor */ |
| 99 |
|
virtual ~ConditionalConstIterator(); |
| 100 |
|
|
| 101 |
|
protected: //made protected so other iterators can access |
| 102 |
|
/** Smart pointer to the source image. */ |
| 103 |
|
//SmartPointer<const ImageType> m_Image; |
| 104 |
|
typename ImageType::ConstWeakPointer m_Image; |
| 105 |
|
|
| 106 |
|
/** Region type to iterate over. */ |
| 107 |
|
RegionType m_Region; |
| 108 |
|
|
| 109 |
|
/** Is the iterator at the end of its walk? */ |
| 110 |
|
bool m_IsAtEnd; |
| 111 |
|
}; |
| 112 |
|
|
| 113 |
|
} // end namespace itk |
| 114 |
|
|
| 115 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 116 |
|
#include "itkConditionalConstIterator.txx" |
| 117 |
|
#endif |
| 118 |
|
|
| 119 |
|
#endif |
| 120 |
|
|