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 itkShapedFloodFilledImageFunctionConditionalConstIterator_h
19 #define itkShapedFloodFilledImageFunctionConditionalConstIterator_h
20 
21 #include "itkShapedFloodFilledFunctionConditionalConstIterator.h"
22 
23 namespace itk
24 {
25 /**
26  * \class ShapedFloodFilledImageFunctionConditionalConstIterator
27  * \brief Iterates over a flood-filled image function with read-only
28  *        access to pixels.
29  *
30  * Contributed as a paper to the Insight Journal:
31  *  https://hdl.handle.net/1926/1320
32  *
33  * \ingroup ImageIterators
34  *
35  * \ingroup ITKCommon
36  */
37 template< typename TImage, typename TFunction >
38 class ITK_TEMPLATE_EXPORT ShapedFloodFilledImageFunctionConditionalConstIterator:
39   public ShapedFloodFilledFunctionConditionalConstIterator< TImage, TFunction >
40 {
41 public:
42   /** Standard class type aliases. */
43   using Self = ShapedFloodFilledImageFunctionConditionalConstIterator<TImage, TFunction>;
44   using Superclass = ShapedFloodFilledFunctionConditionalConstIterator< TImage, TFunction >;
45 
46   /** Type of function */
47   using FunctionType = typename Superclass::FunctionType;
48 
49   /** Type of vector used to store location info in the spatial function */
50   using FunctionInputType = typename Superclass::FunctionInputType;
51 
52   /** Index type alias support */
53   using IndexType = typename Superclass::IndexType;
54 
55   /** Size type alias support */
56   using SizeType = typename Superclass::SizeType;
57 
58   /** Region type alias support */
59   using RegionType = typename Superclass::RegionType;
60 
61   /** Image type alias support */
62   using ImageType = typename Superclass::ImageType;
63 
64   /** Internal Pixel Type */
65   using InternalPixelType = typename Superclass::InternalPixelType;
66 
67   /** External Pixel Type */
68   using PixelType = typename Superclass::PixelType;
69 
70   /** Dimension of the image the iterator walks.  This constant is needed so
71    * functions that are templated over image iterator type (as opposed to
72    * being templated over pixel type and dimension) can have compile time
73    * access to the dimension of the image that the iterator walks. */
74   static constexpr unsigned int NDimensions = Superclass::NDimensions;
75 
76   /** Constructor establishes an iterator to walk a particular image and a
77    * particular region of that image. This version of the constructor uses
78    * an explicit seed pixel for the flood fill, the "startIndex" */
ShapedFloodFilledImageFunctionConditionalConstIterator(const ImageType * imagePtr,FunctionType * fnPtr,IndexType startIndex)79   ShapedFloodFilledImageFunctionConditionalConstIterator(
80     const ImageType *imagePtr,
81     FunctionType *fnPtr,
82     IndexType startIndex):Superclass(imagePtr,
83                                      fnPtr,
84                                      startIndex) {}
85 
86   /** Constructor establishes an iterator to walk a particular image and a
87    * particular region of that image. This version of the constructor uses
88    * an explicit list of seed pixels for the flood fill, the "startIndex" */
ShapedFloodFilledImageFunctionConditionalConstIterator(const ImageType * imagePtr,FunctionType * fnPtr,std::vector<IndexType> & startIndex)89   ShapedFloodFilledImageFunctionConditionalConstIterator(
90     const ImageType *imagePtr,
91     FunctionType *fnPtr,
92     std::vector< IndexType > & startIndex):Superclass(imagePtr,
93                                                       fnPtr,
94                                                       startIndex) {}
95 
96   /** Constructor establishes an iterator to walk a particular image and a
97    * particular region of that image. This version of the constructor
98    * should be used when the seed pixel is unknown. */
ShapedFloodFilledImageFunctionConditionalConstIterator(const ImageType * imagePtr,FunctionType * fnPtr)99   ShapedFloodFilledImageFunctionConditionalConstIterator(
100     const ImageType *imagePtr,
101     FunctionType *fnPtr):Superclass(imagePtr,
102                                     fnPtr) {}
103   /** Default Destructor. */
104   ~ShapedFloodFilledImageFunctionConditionalConstIterator() override = default;
105 
106   /** Compute whether the index of interest should be included in the flood */
107   bool IsPixelIncluded(const IndexType & index) const override;
108 };
109 } // end namespace itk
110 
111 #ifndef ITK_MANUAL_INSTANTIATION
112 #include "itkShapedFloodFilledImageFunctionConditionalConstIterator.hxx"
113 #endif
114 
115 #endif
116