ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkNeighborhoodIterator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkNeighborhoodIterator_h
00019 #define __itkNeighborhoodIterator_h
00020 
00021 #include <vector>
00022 #include <string.h>
00023 #include <iostream>
00024 #include "itkConstNeighborhoodIterator.h"
00025 
00026 namespace itk
00027 {
00215 template< class TImage, class TBoundaryCondition =
00216             ZeroFluxNeumannBoundaryCondition< TImage > >
00217 class ITK_EXPORT NeighborhoodIterator:
00218   public ConstNeighborhoodIterator< TImage, TBoundaryCondition >
00219 {
00220 public:
00221 
00223   typedef NeighborhoodIterator                                    Self;
00224   typedef ConstNeighborhoodIterator< TImage, TBoundaryCondition > Superclass;
00225 
00227   typedef typename Superclass::InternalPixelType InternalPixelType;
00228   typedef typename Superclass::PixelType         PixelType;
00229   typedef typename Superclass::SizeType          SizeType;
00230   typedef typename Superclass::ImageType         ImageType;
00231   typedef typename Superclass::RegionType        RegionType;
00232   typedef typename Superclass::IndexType         IndexType;
00233   typedef typename Superclass::OffsetType        OffsetType;
00234   typedef typename Superclass::RadiusType        RadiusType;
00235   typedef typename Superclass::NeighborhoodType  NeighborhoodType;
00236   typedef typename Superclass::Iterator          Iterator;
00237   typedef typename Superclass::ConstIterator     ConstIterator;
00238   typedef typename Superclass::ImageBoundaryConditionPointerType
00239   ImageBoundaryConditionPointerType;
00240 
00242   NeighborhoodIterator():Superclass() {}
00243 
00245   NeighborhoodIterator(const NeighborhoodIterator & n):Superclass(n) {}
00246 
00248   Self & operator=(const Self & orig)
00249   {
00250     Superclass::operator=(orig);
00251     return *this;
00252   }
00254 
00257   NeighborhoodIterator(const SizeType & radius, ImageType *ptr,
00258                        const RegionType & region):
00259     Superclass(radius, ptr, region) {}
00260 
00262   virtual void PrintSelf(std::ostream &, Indent) const;
00263 
00265   InternalPixelType * GetCenterPointer()
00266   { return ( this->operator[]( ( this->Size() ) >> 1 ) ); }
00267 
00269   virtual void SetCenterPixel(const PixelType & p)
00270   { this->m_NeighborhoodAccessorFunctor.Set(this->operator[]( ( this->Size() ) >> 1 ), p); }
00271 
00275   virtual void SetNeighborhood(const NeighborhoodType &);
00276 
00279   virtual void SetPixel(const unsigned i, const PixelType & v,
00280                         bool  & status);
00281 
00283   virtual void SetPixel(const unsigned i, const PixelType & v);
00284 
00285   //  { *(this->operator[](i)) = v; }
00286 
00288   virtual void SetPixel(const OffsetType o, const PixelType & v)
00289   { this->SetPixel(this->GetNeighborhoodIndex(o), v); }
00290   //  { *(this->operator[](o)) = v; }
00292 
00296   virtual void SetNext(const unsigned axis, const unsigned i,
00297                        const PixelType & v)
00298   {
00299     this->SetPixel(this->GetCenterNeighborhoodIndex()
00300                    + ( i * this->GetStride(axis) ), v);
00301   }
00302 
00306   virtual void SetNext(const unsigned axis, const PixelType & v)
00307   {
00308     this->SetPixel(this->GetCenterNeighborhoodIndex()
00309                    + this->GetStride(axis), v);
00310   }
00311 
00315   virtual void SetPrevious(const unsigned axis, const unsigned i,
00316                            const PixelType & v)
00317   {
00318     this->SetPixel(this->GetCenterNeighborhoodIndex()
00319                    - ( i * this->GetStride(axis) ), v);
00320   }
00321 
00325   virtual void SetPrevious(const unsigned axis,
00326                            const PixelType & v)
00327   {
00328     this->SetPixel(this->GetCenterNeighborhoodIndex()
00329                    - this->GetStride(axis), v);
00330   }
00331 };
00332 } // namespace itk
00334 
00335 #ifndef ITK_MANUAL_INSTANTIATION
00336 #include "itkNeighborhoodIterator.hxx"
00337 #endif
00338 
00339 #endif
00340