ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkConstNeighborhoodIteratorWithOnlyIndex.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 itkConstNeighborhoodIteratorWithOnlyIndex_h
19#define itkConstNeighborhoodIteratorWithOnlyIndex_h
20
21#include <vector>
22#include <cstring>
23#include <iostream>
24#include <type_traits> // For remove_const_t.
25
26#include "itkImage.h"
27#include "itkNeighborhood.h"
28#include "itkMacro.h"
29
30namespace itk
31{
61template <typename TImage>
62class ITK_TEMPLATE_EXPORT ConstNeighborhoodIteratorWithOnlyIndex : public Neighborhood<int8_t, TImage::ImageDimension>
63{
64public:
66
68 using DimensionValueType = unsigned int;
69
71 static constexpr DimensionValueType Dimension = TImage::ImageDimension;
72
74
78
80 using typename Superclass::OffsetType;
81 using typename Superclass::RadiusType;
82 using typename Superclass::SizeType;
83 using typename Superclass::Iterator;
84 using typename Superclass::ConstIterator;
85
87 using ImageType = TImage;
88 using RegionType = typename TImage::RegionType;
91
94
97
100
103 ConstNeighborhoodIteratorWithOnlyIndex(const SizeType & radius, const TImage * ptr, const RegionType & region);
104
106 void
107 PrintSelf(std::ostream &, Indent) const override;
108
113
116 GetBound() const
117 {
118 return m_Bound;
119 }
120
125 {
126 return m_Bound[n];
127 }
128
130 const ImageType *
132 {
133 return m_ConstImage;
134 }
135
138 IndexType
139 GetIndex() const
140 {
141 return m_Loop;
142 }
143
146 IndexType
147 GetIndex(const OffsetType & o) const
148 {
149 return this->GetIndex() + o;
150 }
151
154 IndexType
156 {
157 return this->GetIndex() + this->GetOffset(i);
158 }
159
161 RegionType
162 GetRegion() const
163 {
164 return m_Region;
165 }
166
169 IndexType
171 {
172 return m_BeginIndex;
173 }
174
177 RegionType
179
181 void
183
186 void
188
191 void
192 Initialize(const SizeType & radius, const ImageType * ptr, const RegionType & region);
193
196 bool
197 IsAtBegin() const
198 {
199 return this->GetIndex() == m_BeginIndex;
200 }
201
204 bool
205 IsAtEnd() const;
206
211 Self &
213
218 Self &
220
224 bool
225 operator==(const Self & it) const
226 {
227 return it.GetIndex() == this->GetIndex();
228 }
229
231
237 bool
238 operator<(const Self & it) const;
239
245 bool
246 operator<=(const Self & it) const;
247
253 bool
254 operator>(const Self & it) const;
255
261 bool
262 operator>=(const Self & it) const;
263
268 void
269 SetLocation(const IndexType & position)
270 {
271 this->SetLoop(position);
272 }
273
277 Self &
279
283 Self &
285
288 operator-(const Self & b) const
289 {
290 return m_Loop - b.m_Loop;
291 }
292
296 bool
297 InBounds() const;
298
310 bool
311 IndexInBounds(const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset) const;
312
314 void
319
320 void
325
326 void
331
332 bool
337
338protected:
341 void
343 {
344 m_Loop = p;
345 m_IsInBoundsValid = false;
346 }
347
351 void
353
356 void
358 {
359 m_BeginIndex = start;
360 }
361
364 void
366
370
373
375 typename ImageType::ConstPointer m_ConstImage{};
376
380
383
386
389 mutable bool m_InBounds[Dimension]{ false };
390
392 mutable bool m_IsInBounds{ false };
393
397 mutable bool m_IsInBoundsValid{ false };
398
401
404
407};
408
409// Deduction guide for class template argument deduction (CTAD).
410template <typename TImage>
411ConstNeighborhoodIteratorWithOnlyIndex(const typename TImage::SizeType &,
413 const typename TImage::RegionType &)
415
416
417template <typename TImage>
426
427template <typename TImage>
434
435template <typename TImage>
444} // namespace itk
445
446#ifndef ITK_MANUAL_INSTANTIATION
447# include "itkConstNeighborhoodIteratorWithOnlyIndex.hxx"
448#endif
449
450#endif
Index-only version of ConstNeighborhoodIterator, defining iteration of a local N-dimensional neighbor...
Neighborhood< DummyNeighborhoodPixelType, Self::Dimension > NeighborhoodType
Self & operator-=(const OffsetType &)
ConstNeighborhoodIteratorWithOnlyIndex(const SizeType &radius, const TImage *ptr, const RegionType &region)
bool operator>=(const Self &it) const
bool operator<(const Self &it) const
bool IndexInBounds(const NeighborIndexType n, OffsetType &internalIndex, OffsetType &offset) const
void Initialize(const SizeType &radius, const ImageType *ptr, const RegionType &region)
OffsetType ComputeInternalIndex(NeighborIndexType n) const
typename NeighborhoodType::NeighborIndexType NeighborIndexType
void PrintSelf(std::ostream &, Indent) const override
ITK_DEFAULT_COPY_AND_MOVE(ConstNeighborhoodIteratorWithOnlyIndex)
bool operator>(const Self &it) const
Neighborhood< DummyNeighborhoodPixelType, Self::Dimension > Superclass
Self & operator+=(const OffsetType &)
~ConstNeighborhoodIteratorWithOnlyIndex() override=default
bool operator<=(const Self &it) const
Control indentation during Print() invocation.
Definition itkIndent.h:51
OffsetType GetOffset(NeighborIndexType i) const
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ConstNeighborhoodIteratorWithOnlyIndex(const typename TImage::SizeType &, SmartPointer< TImage >, const typename TImage::RegionType &) -> ConstNeighborhoodIteratorWithOnlyIndex< std::remove_const_t< TImage > >
ConstNeighborhoodIterator< TImage > operator-(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
ConstNeighborhoodIterator< TImage > operator+(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
long IndexValueType
Definition itkIntTypes.h:93
Represent a n-dimensional index in a n-dimensional image.
Definition itkIndex.h:69