ITK  5.2.0
Insight Toolkit
itkShapedNeighborhoodIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkShapedNeighborhoodIterator_h
19 #define itkShapedNeighborhoodIterator_h
20 
21 #include <vector>
22 #include <list>
24 
25 namespace itk
26 {
152 template <typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
153 class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
154  : public ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>
155 {
156 public:
158  using InternalPixelType = typename TImage::InternalPixelType;
159  using PixelType = typename TImage::PixelType;
160 
162  static constexpr unsigned int Dimension = TImage::ImageDimension;
163 
167 
172  using SizeType = typename Superclass::SizeType;
175  using IndexListType = typename Superclass::IndexListType;
176  using BoundaryConditionType = typename Superclass::BoundaryConditionType;
177  using ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType;
178  using NeighborhoodType = typename Superclass::NeighborhoodType;
180  using ImageType = typename Superclass::ImageType;
183 
185  struct Iterator : public ConstIterator
186  {
187  Iterator() = default;
189  : ConstIterator(s)
190  {}
191 
192  ~Iterator() ITK_ITERATOR_OVERRIDE = default;
193  Iterator &
194  operator=(const Iterator & o)
195  {
196  ConstIterator::operator=(o);
197  return *this;
198  }
199 
200  // Promote to public
201  void
202  Set(const PixelType & v) const
203  {
204  ConstIterator::ProtectedSet(v);
205  }
206 
207  protected:
208  friend Self;
209 
210  Iterator(const Self * s, const typename IndexListType::const_iterator & li)
211  : ConstIterator(s, li)
212  {}
213  };
214 
216  ShapedNeighborhoodIterator() = default;
217 
219  ~ShapedNeighborhoodIterator() override = default;
220 
223 
226  ShapedNeighborhoodIterator(const SizeType & radius, const ImageType * ptr, const RegionType & region)
227  : Superclass(radius, const_cast<ImageType *>(ptr), region)
228  {}
229 
230  // Expose the following methods from the superclass. This is a restricted
231  // subset of the methods available for NeighborhoodIterator.
232  using Superclass::SetPixel;
233  using Superclass::SetCenterPixel;
234 
235 
237  Self &
238  operator=(const Self & orig)
239  {
240  Superclass::operator=(orig);
241  return *this;
242  }
244 
246  void
247  PrintSelf(std::ostream &, Indent) const override;
248 
251  Iterator
253  {
254  return Iterator(this, this->m_ActiveIndexList.begin());
255  }
256  Iterator
257  End()
258  {
259  return Iterator(this, this->m_ActiveIndexList.end());
260  }
262 
263  using Superclass::Begin;
264  using Superclass::End;
265 
266 protected:
267  friend Superclass;
268 
270 };
271 } // namespace itk
272 
273 #ifndef ITK_MANUAL_INSTANTIATION
274 # include "itkShapedNeighborhoodIterator.hxx"
275 #endif
276 
277 #endif
itk::ShapedNeighborhoodIterator::operator=
Self & operator=(const Self &orig)
Definition: itkShapedNeighborhoodIterator.h:238
itkConstShapedNeighborhoodIterator.h
itk::ShapedNeighborhoodIterator::ShapedNeighborhoodIterator
ShapedNeighborhoodIterator(const SizeType &radius, const ImageType *ptr, const RegionType &region)
Definition: itkShapedNeighborhoodIterator.h:226
itk::Index< Self::Dimension >
itk::ShapedNeighborhoodIterator::Iterator::Set
void Set(const PixelType &v) const
Definition: itkShapedNeighborhoodIterator.h:202
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkConstNeighborhoodIterator.h:70
itk::ShapedNeighborhoodIterator::Iterator::Iterator
Iterator(Self *s)
Definition: itkShapedNeighborhoodIterator.h:188
itk::ShapedNeighborhoodIterator::ConstIterator
typename Superclass::ConstIterator ConstIterator
Definition: itkShapedNeighborhoodIterator.h:174
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::NeighborIndexType
typename NeighborhoodType::NeighborIndexType NeighborIndexType
Definition: itkConstNeighborhoodIterator.h:88
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::PixelType
typename ImageType ::PixelType PixelType
Definition: itkConstNeighborhoodIterator.h:56
itk::ConstShapedNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::IndexValueType
typename IndexType::IndexValueType IndexValueType
Definition: itkConstShapedNeighborhoodIterator.h:96
itk::ShapedNeighborhoodIterator::Iterator::Self
friend Self
Definition: itkShapedNeighborhoodIterator.h:208
itk::Neighborhood
A light-weight container object for storing an N-dimensional neighborhood of values.
Definition: itkNeighborhood.h:54
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ConstShapedNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::SizeValueType
typename SizeType::SizeValueType SizeValueType
Definition: itkConstShapedNeighborhoodIterator.h:90
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ShapedNeighborhoodIterator
A neighborhood iterator which can take on an arbitrary shape.
Definition: itkShapedNeighborhoodIterator.h:153
itk::ShapedNeighborhoodIterator::Iterator::Iterator
Iterator(const Self *s, const typename IndexListType::const_iterator &li)
Definition: itkShapedNeighborhoodIterator.h:210
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ImageType
ImageType ImageType
Definition: itkConstNeighborhoodIterator.h:76
itk::ImageBoundaryCondition< ImageType, OutputImageType >
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::InternalPixelType
typename ImageType ::InternalPixelType InternalPixelType
Definition: itkConstNeighborhoodIterator.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ConstShapedNeighborhoodIterator
Const version of ShapedNeighborhoodIterator, defining iteration of a local N-dimensional neighborhood...
Definition: itkConstShapedNeighborhoodIterator.h:71
itk::ConstShapedNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::IndexListType
std::list< NeighborIndexType > IndexListType
Definition: itkConstShapedNeighborhoodIterator.h:103
itk::ShapedNeighborhoodIterator::End
Iterator End()
Definition: itkShapedNeighborhoodIterator.h:257
itk::Neighborhood::ConstIterator
typename AllocatorType::const_iterator ConstIterator
Definition: itkNeighborhood.h:76
itk::Offset
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
Definition: itkOffset.h:67
itk::ShapedNeighborhoodIterator::Iterator
Definition: itkShapedNeighborhoodIterator.h:185
itk::ConstShapedNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::OffsetValueType
typename OffsetType::OffsetValueType OffsetValueType
Definition: itkConstShapedNeighborhoodIterator.h:87
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:50
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RegionType
typename ImageType ::RegionType RegionType
Definition: itkConstNeighborhoodIterator.h:77
itk::OffsetValueType
signed long OffsetValueType
Definition: itkIntTypes.h:94
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ConstIterator
typename Superclass::ConstIterator ConstIterator
Definition: itkConstNeighborhoodIterator.h:73
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::OffsetType
typename Superclass::OffsetType OffsetType
Definition: itkConstNeighborhoodIterator.h:69
itk::ShapedNeighborhoodIterator::Superclass
friend Superclass
Definition: itkShapedNeighborhoodIterator.h:267
itk::ZeroFluxNeumannBoundaryCondition< ImageType >
itk::Neighborhood::NeighborIndexType
SizeValueType NeighborIndexType
Definition: itkNeighborhood.h:96
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::Iterator
typename Superclass::Iterator Iterator
Definition: itkConstNeighborhoodIterator.h:72
itk::ShapedNeighborhoodIterator::Begin
Iterator Begin()
Definition: itkShapedNeighborhoodIterator.h:252
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::SizeType
typename Superclass::SizeType SizeType
Definition: itkConstNeighborhoodIterator.h:71
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83