ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkShapedNeighborhoodIterator.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 __itkShapedNeighborhoodIterator_h
19 #define __itkShapedNeighborhoodIterator_h
20 
21 #include <vector>
22 #include <list>
24 
25 namespace itk
26 {
150 template< class TImage, class TBoundaryCondition =
151  ZeroFluxNeumannBoundaryCondition< TImage > >
152 class ITK_EXPORT ShapedNeighborhoodIterator:
153  public ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
154 {
155 public:
157  typedef typename TImage::InternalPixelType InternalPixelType;
158  typedef typename TImage::PixelType PixelType;
159 
161  itkStaticConstMacro(Dimension, unsigned int, TImage::ImageDimension);
162 
167 
171  typedef typename Superclass::RadiusType RadiusType;
172  typedef typename Superclass::SizeType SizeType;
175  typedef typename Superclass::IndexListType IndexListType;
176  typedef typename Superclass::BoundaryConditionType BoundaryConditionType;
177  typedef typename Superclass::ImageBoundaryConditionPointerType ImageBoundaryConditionPointerType;
178  typedef typename Superclass::NeighborhoodType NeighborhoodType;
179  typedef typename Superclass::IndexType IndexType;
180  typedef typename Superclass::ImageType ImageType;
181  typedef typename Superclass::RegionType RegionType;
183 
185  struct Iterator:public ConstIterator {
186  Iterator() {}
189 
191  const Iterator & operator=(const Iterator & o)
192  {
193  ConstIterator::operator=(o);
194  return *this;
195  }
196 
197  // Promote to public
198  void Set(const PixelType & v) const
199  { ConstIterator::ProtectedSet(v); }
200  };
201 
204  {
205  m_BeginIterator = Iterator(this);
206  m_EndIterator = Iterator(this);
207  m_EndIterator.GoToEnd();
208  }
210 
213 
217  const ImageType *ptr,
218  const RegionType & region
219  ):Superclass(radius, const_cast< ImageType * >( ptr ),
220  region)
221  {
222  m_BeginIterator = Iterator(this);
223  m_EndIterator = Iterator(this);
224  m_EndIterator.GoToEnd();
225  }
227 
228  // Expose the following methods from the superclass. This is a restricted
229  // subset of the methods available for NeighborhoodIterator.
230  using Superclass::SetPixel;
231  using Superclass::SetCenterPixel;
232 
233 
235  Self & operator=(const Self & orig)
236  {
237  Superclass::operator=(orig);
238 
239  // Reset begin and end pointer locations
240  m_BeginIterator.GoToBegin();
241  m_EndIterator.GoToEnd();
242  return *this;
243  }
244 
246  virtual void PrintSelf(std::ostream &, Indent) const;
247 
250  Iterator & Begin() { return m_BeginIterator; }
251  Iterator & End() { return m_EndIterator; }
253 
256  const ConstIterator & End() const
257  { return this->m_ConstEndIterator; }
258 
259  void ClearActiveList()
260  {
261  Superclass::ClearActiveList();
262  m_EndIterator.GoToEnd();
263  m_BeginIterator.GoToBegin();
264  }
265 
266 protected:
267 
270  // purposely not implemented
271 
273 
274  void ActivateIndex(NeighborIndexType n)
275  {
276  Superclass::ActivateIndex(n);
277  m_EndIterator.GoToEnd();
278  m_BeginIterator.GoToBegin();
279  }
280 
281  void DeactivateIndex(NeighborIndexType n)
282  {
283  Superclass::DeactivateIndex(n);
284  m_EndIterator.GoToEnd();
285  m_BeginIterator.GoToBegin();
286  }
287 
290 };
291 } // namespace itk
292 
293 #ifndef ITK_MANUAL_INSTANTIATION
294 #include "itkShapedNeighborhoodIterator.hxx"
295 #endif
296 
297 #endif
298