ITK  4.13.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< typename TImage, typename TBoundaryCondition =
152 class ITK_TEMPLATE_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;
180  typedef typename Superclass::ImageType ImageType;
181  typedef typename Superclass::RegionType RegionType;
183 
185  struct Iterator:public ConstIterator {
186  Iterator() {}
189 
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 
260  {
261  Superclass::ClearActiveList();
262  m_EndIterator.GoToEnd();
263  m_BeginIterator.GoToBegin();
264  }
265 
266 protected:
267 
269  ShapedNeighborhoodIterator(const ShapedNeighborhoodIterator & o) ITK_DELETED_FUNCTION;
270 
272 
274  {
275  Superclass::ActivateIndex(n);
276  m_EndIterator.GoToEnd();
277  m_BeginIterator.GoToBegin();
278  }
279 
281  {
282  Superclass::DeactivateIndex(n);
283  m_EndIterator.GoToEnd();
284  m_BeginIterator.GoToBegin();
285  }
286 
289 };
290 } // namespace itk
291 
292 #ifndef ITK_MANUAL_INSTANTIATION
293 #include "itkShapedNeighborhoodIterator.hxx"
294 #endif
295 
296 #endif
Superclass::BoundaryConditionType BoundaryConditionType
Const version of ShapedNeighborhoodIterator, defining iteration of a local N-dimensional neighborhood...
Superclass::ImageBoundaryConditionPointerType ImageBoundaryConditionPointerType
Superclass::NeighborhoodType NeighborhoodType
A light-weight container object for storing an N-dimensional neighborhood of values.
signed long IndexValueType
Definition: itkIntTypes.h:150
ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition > Superclass
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
A neighborhood iterator which can take on an arbitrary shape.
ShapedNeighborhoodIterator(const SizeType &radius, const ImageType *ptr, const RegionType &region)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
AllocatorType::const_iterator ConstIterator
SizeType::SizeValueType SizeValueType
itk::OffsetValueType OffsetValueType
Definition: itkOffset.h:70
Superclass::NeighborIndexType NeighborIndexType
SizeValueType NeighborIndexType