ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkShapedNeighborhoodIterator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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>
23#include <type_traits> // For add_const_t.
25
26namespace itk
27{
149template <typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
150class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
151 : public ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>
152{
153public:
155 using InternalPixelType = typename TImage::InternalPixelType;
156 using PixelType = typename TImage::PixelType;
157
159 static constexpr unsigned int Dimension = TImage::ImageDimension;
160
164
166 using typename Superclass::OffsetType;
168 using typename Superclass::RadiusType;
169 using typename Superclass::SizeType;
170 using typename Superclass::SizeValueType;
171 using typename Superclass::ConstIterator;
172 using typename Superclass::IndexListType;
175 using typename Superclass::NeighborhoodType;
176 using typename Superclass::IndexType;
177 using typename Superclass::ImageType;
178 using typename Superclass::RegionType;
179 using typename Superclass::IndexValueType;
180
182 struct Iterator : public Superclass::ConstIterator
183 {
184 Iterator() = default;
186 : ConstIterator(s)
187 {}
188
189 ~Iterator() = default;
190 Iterator &
192 {
193 ConstIterator::operator=(o);
194 return *this;
195 }
196
197 // Promote to public
198 void
199 Set(const PixelType & v) const
200 {
201 ConstIterator::ProtectedSet(v);
202 }
203
204 protected:
205 friend Self;
206
207 Iterator(const Self * s, const typename IndexListType::const_iterator & li)
208 : ConstIterator(s, li)
209 {}
210 };
211
214
216 ~ShapedNeighborhoodIterator() override = default;
217
220
223 ShapedNeighborhoodIterator(const SizeType & radius, ImageType * ptr, const RegionType & region)
224 : Superclass(radius, ptr, region)
225 {}
226
227#ifndef ITK_FUTURE_LEGACY_REMOVE
231 ITK_FUTURE_DEPRECATED(
232 "This constructor is intended to be removed. For a `const` image, use ConstShapedNeighborhoodIterator instead!")
233 ShapedNeighborhoodIterator(const SizeType & radius, std::add_const_t<ImageType> * ptr, const RegionType & region)
234 : Superclass(radius, ptr, region)
235 {
236 // Note: parameter type `std::add_const_t<ImageType> *` prevents accidental class template argument deduction
237 // (CTAD).
238 }
239#endif
240
241 // Expose the following methods from the superclass. This is a restricted
242 // subset of the methods available for NeighborhoodIterator.
243 using Superclass::SetPixel;
244 using Superclass::SetCenterPixel;
245
246
248 Self &
249 operator=(const Self & orig)
250 {
252 return *this;
253 }
254
258 Iterator
260 {
261 return Iterator(this, this->m_ActiveIndexList.begin());
262 }
263 Iterator
265 {
266 return Iterator(this, this->m_ActiveIndexList.end());
267 }
268
269
270 using Superclass::Begin;
271 using Superclass::End;
272
273protected:
275
276 using typename Superclass::NeighborIndexType;
277};
278} // namespace itk
279
280#endif
typename NeighborhoodType::NeighborIndexType NeighborIndexType
itk::Size< VDimension > SizeType
A neighborhood iterator which can take on an arbitrary shape.
typename OffsetType::OffsetValueType OffsetValueType
ShapedNeighborhoodIterator(const ShapedNeighborhoodIterator &o)=delete
~ShapedNeighborhoodIterator() override=default
typename TImage::InternalPixelType InternalPixelType
ShapedNeighborhoodIterator(const SizeType &radius, ImageType *ptr, const RegionType &region)
ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition > Superclass
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
STL namespace.
itk::OffsetValueType OffsetValueType
Definition itkOffset.h:77
Iterator(const Self *s, const typename IndexListType::const_iterator &li)