ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMultipleImageIterator.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
19#ifndef itkMultipleImageIterator_h
20#define itkMultipleImageIterator_h
21#include <vector>
23
24
25namespace itk
26{
34template <typename TIterator>
36{
37public:
39 using IteratorType = TIterator;
40 using ImageType = typename IteratorType::ImageType;
43 operator[](const unsigned int i)
44 {
45 return m_Iterators[i];
46 }
47
48 void
50 {
51 m_Iterators.push_back(it);
52 }
53
54 Self &
56 {
57 for (auto it = m_Iterators.begin(); it != m_Iterators.end(); ++it)
58 {
59 ++(*it);
60 }
61 return *this;
62 }
63
64 void
66 {
67 for (auto it = m_Iterators.begin(); it != m_Iterators.end(); ++it)
68 {
69 it->GoToBegin();
70 }
71 }
72
75 bool
77 {
78#ifdef NDEBUG
79 return m_Iterators[0].IsAtEnd();
80#else
81 assert(m_Iterators.size());
82 bool retval = m_Iterators[0].IsAtEnd();
83 for (unsigned int i = 0; i < m_Iterators.size(); ++i)
84 assert(m_Iterators[i].IsAtEnd() == retval);
85 return retval;
86#endif
87 }
88
89 unsigned int
90 Size() const
91 {
92 return m_Iterators.size();
93 }
94
95protected:
96 std::vector<IteratorType> m_Iterators;
97};
98} // namespace itk
99#endif // itkMultipleImageIterator_h
An wrapper around image iterators to iterate over several images simultaneously All iterators must.
void GoToBegin()
Rewind all iterators.
Self & operator++()
Advance all iterators.
IteratorType & operator[](const unsigned int i)
Access one of the iterators.
void AddIterator(const IteratorType &it)
Add a new iterator.
std::vector< IteratorType > m_Iterators
typename IteratorType::ImageType ImageType
unsigned int Size() const
Returns the number of iterators.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....