ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkNeighborhoodIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 __itkNeighborhoodIterator_h
19 #define __itkNeighborhoodIterator_h
20 
21 #include <vector>
22 #include <cstring>
23 #include <iostream>
25 
26 namespace itk
27 {
215 template< class TImage, class TBoundaryCondition =
216  ZeroFluxNeumannBoundaryCondition< TImage > >
217 class ITK_EXPORT NeighborhoodIterator:
218  public ConstNeighborhoodIterator< TImage, TBoundaryCondition >
219 {
220 public:
221 
225 
227  typedef typename Superclass::InternalPixelType InternalPixelType;
229  typedef typename Superclass::SizeType SizeType;
230  typedef typename Superclass::ImageType ImageType;
231  typedef typename Superclass::RegionType RegionType;
232  typedef typename Superclass::IndexType IndexType;
234  typedef typename Superclass::RadiusType RadiusType;
235  typedef typename Superclass::NeighborhoodType NeighborhoodType;
236  typedef typename Superclass::Iterator Iterator;
238  typedef typename Superclass::ImageBoundaryConditionPointerType
240 
243 
246 
248  Self & operator=(const Self & orig)
249  {
250  Superclass::operator=(orig);
251  return *this;
252  }
254 
258  const RegionType & region):
259  Superclass(radius, ptr, region) {}
260 
262  virtual void PrintSelf(std::ostream &, Indent) const;
263 
265  InternalPixelType * GetCenterPointer()
266  { return ( this->operator[]( ( this->Size() ) >> 1 ) ); }
267 
269  virtual void SetCenterPixel(const PixelType & p)
270  { this->m_NeighborhoodAccessorFunctor.Set(this->operator[]( ( this->Size() ) >> 1 ), p); }
271 
275  virtual void SetNeighborhood(const NeighborhoodType &);
276 
279  virtual void SetPixel(const unsigned i, const PixelType & v,
280  bool & status);
281 
283  virtual void SetPixel(const unsigned i, const PixelType & v);
284 
285  // { *(this->operator[](i)) = v; }
286 
288  virtual void SetPixel(const OffsetType o, const PixelType & v)
289  { this->SetPixel(this->GetNeighborhoodIndex(o), v); }
290  // { *(this->operator[](o)) = v; }
292 
296  virtual void SetNext(const unsigned axis, const unsigned i,
297  const PixelType & v)
298  {
299  this->SetPixel(this->GetCenterNeighborhoodIndex()
300  + ( i * this->GetStride(axis) ), v);
301  }
302 
306  virtual void SetNext(const unsigned axis, const PixelType & v)
307  {
308  this->SetPixel(this->GetCenterNeighborhoodIndex()
309  + this->GetStride(axis), v);
310  }
311 
315  virtual void SetPrevious(const unsigned axis, const unsigned i,
316  const PixelType & v)
317  {
318  this->SetPixel(this->GetCenterNeighborhoodIndex()
319  - ( i * this->GetStride(axis) ), v);
320  }
321 
325  virtual void SetPrevious(const unsigned axis,
326  const PixelType & v)
327  {
328  this->SetPixel(this->GetCenterNeighborhoodIndex()
329  - this->GetStride(axis), v);
330  }
331 };
332 } // namespace itk
334 
335 #ifndef ITK_MANUAL_INSTANTIATION
336 #include "itkNeighborhoodIterator.hxx"
337 #endif
338 
339 #endif
340