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 itkImageRegionReverseIterator_h 19 #define itkImageRegionReverseIterator_h 20 21 #include "itkImageRegionReverseConstIterator.h" 22 #include "itkImageConstIterator.h" 23 24 namespace itk 25 { 26 /** \class ImageRegionReverseIterator 27 * \brief A multi-dimensional image iterator which only walks a region. 28 * 29 * ImageRegionReverseIterator is a templated class to represent a multi-dimensional 30 * iterator. ImageRegionReverseIterator is templated over the image type 31 * ImageRegionReverseIterator is constrained to walk only within the 32 * specified region and along a line parallel to one of the coordinate axis. 33 * 34 * Most of the functionality is inherited from the ImageRegionReverseConstIterator. 35 * The current class only adds write access to image pixels. 36 * 37 * \par MORE INFORMATION 38 * For a complete description of the ITK Image Iterators and their API, please 39 * see the Iterators chapter in the ITK Software Guide. The ITK Software Guide 40 * is available in print and as a free .pdf download from https://www.itk.org. 41 * 42 * \ingroup ImageIterators 43 * 44 * \sa ImageConstIterator \sa ConditionalConstIterator 45 * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator 46 * \sa ConstSliceIterator \sa CorrespondenceDataStructureIterator 47 * \sa FloodFilledFunctionConditionalConstIterator 48 * \sa FloodFilledImageFunctionConditionalConstIterator 49 * \sa FloodFilledImageFunctionConditionalIterator 50 * \sa FloodFilledSpatialFunctionConditionalConstIterator 51 * \sa FloodFilledSpatialFunctionConditionalIterator 52 * \sa ImageConstIterator \sa ImageConstIteratorWithIndex 53 * \sa ImageIterator \sa ImageIteratorWithIndex 54 * \sa ImageLinearConstIteratorWithIndex \sa ImageLinearIteratorWithIndex 55 * \sa ImageRandomConstIteratorWithIndex \sa ImageRandomIteratorWithIndex 56 * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex 57 * \sa ImageRegionExclusionConstIteratorWithIndex 58 * \sa ImageRegionExclusionIteratorWithIndex 59 * \sa ImageRegionIterator \sa ImageRegionIteratorWithIndex 60 * \sa ImageRegionReverseConstIterator \sa ImageRegionReverseIterator 61 * \sa ImageReverseConstIterator \sa ImageReverseIterator 62 * \sa ImageSliceConstIteratorWithIndex \sa ImageSliceIteratorWithIndex 63 * \sa NeighborhoodIterator \sa PathConstIterator \sa PathIterator 64 * \sa ShapedNeighborhoodIterator \sa SliceIterator 65 * \sa ImageConstIteratorWithIndex 66 * \ingroup ITKCommon 67 */ 68 template< typename TImage > 69 class ITK_TEMPLATE_EXPORT ImageRegionReverseIterator:public ImageRegionReverseConstIterator< TImage > 70 { 71 public: 72 /** Standard class type aliases. */ 73 using Self = ImageRegionReverseIterator; 74 using Superclass = ImageRegionReverseConstIterator< TImage >; 75 76 /** Types inherited from the Superclass */ 77 using IndexType = typename Superclass::IndexType; 78 using SizeType = typename Superclass::SizeType; 79 using OffsetType = typename Superclass::OffsetType; 80 using RegionType = typename Superclass::RegionType; 81 using ImageType = typename Superclass::ImageType; 82 using PixelContainer = typename Superclass::PixelContainer; 83 using PixelContainerPointer = typename Superclass::PixelContainerPointer; 84 using InternalPixelType = typename Superclass::InternalPixelType; 85 using PixelType = typename Superclass::PixelType; 86 using AccessorType = typename Superclass::AccessorType; 87 88 /** Default constructor. Needed since we provide a cast constructor. */ 89 ImageRegionReverseIterator() = default; 90 91 /** Constructor establishes an iterator to walk a particular image and a 92 * particular region of that image. */ 93 ImageRegionReverseIterator(ImageType *ptr, const RegionType & region); 94 95 /** Constructor that can be used to cast from an ImageConstIterator to an 96 * ImageRegionReverseIterator. Many routines return an ImageConstIterator but for a 97 * particular task, you may want an ImageRegionReverseIterator. Rather than 98 * provide overloaded APIs that return different types of Iterators, itk 99 * returns ImageConstIterators and uses constructors to cast from an 100 * ImageConstIterator to a ImageRegionReverseIterator. */ 101 ImageRegionReverseIterator(const ImageConstIterator< TImage > & it); 102 103 /** Set the pixel value */ Set(const PixelType & value)104 void Set(const PixelType & value) const 105 { this->m_PixelAccessor.Set(*const_cast< InternalPixelType * >( ( this->m_Buffer + this->m_Offset ) ), value); } 106 107 /** Return a reference to the pixel 108 * This method will provide the fastest access to pixel 109 * data, but it will NOT support ImageAdaptors. */ Value()110 PixelType & Value() 111 { return *const_cast< InternalPixelType * >( ( this->m_Buffer + this->m_Offset ) ); } 112 113 protected: 114 /** the construction from a const iterator is declared protected 115 in order to enforce const correctness. */ 116 ImageRegionReverseIterator(const ImageRegionReverseConstIterator< TImage > & it); 117 Self & operator=(const ImageRegionReverseConstIterator< TImage > & it); 118 }; 119 } // end namespace itk 120 121 #ifndef ITK_MANUAL_INSTANTIATION 122 #include "itkImageRegionReverseIterator.hxx" 123 #endif 124 125 #endif 126