Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright Contributors to the OpenVDB Project | ||
2 | // SPDX-License-Identifier: MPL-2.0 | ||
3 | |||
4 | /// @file points/IndexIterator.h | ||
5 | /// | ||
6 | /// @author Dan Bailey | ||
7 | /// | ||
8 | /// @brief Index Iterators. | ||
9 | |||
10 | #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED | ||
11 | #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED | ||
12 | |||
13 | #include <openvdb/version.h> | ||
14 | #include <openvdb/Types.h> | ||
15 | |||
16 | namespace openvdb { | ||
17 | OPENVDB_USE_VERSION_NAMESPACE | ||
18 | namespace OPENVDB_VERSION_NAME { | ||
19 | namespace points { | ||
20 | |||
21 | |||
22 | /// @brief Count up the number of times the iterator can iterate | ||
23 | /// | ||
24 | /// @param iter the iterator. | ||
25 | /// | ||
26 | /// @note counting by iteration only performed where a dynamic filter is in use, | ||
27 | template <typename IterT> | ||
28 | inline Index64 iterCount(const IterT& iter); | ||
29 | |||
30 | |||
31 | //////////////////////////////////////// | ||
32 | |||
33 | |||
34 | namespace index { | ||
35 | // Enum for informing early-exit optimizations | ||
36 | // PARTIAL - No optimizations are possible | ||
37 | // NONE - No indices to evaluate, can skip computation | ||
38 | // ALL - All indices to evaluate, can skip filtering | ||
39 | enum State | ||
40 | { | ||
41 | PARTIAL=0, | ||
42 | NONE, | ||
43 | ALL | ||
44 | }; | ||
45 | } | ||
46 | |||
47 | |||
48 | /// @brief A no-op filter that can be used when iterating over all indices | ||
49 | /// @see points/IndexFilter.h for the documented interface for an index filter | ||
50 | class NullFilter | ||
51 | { | ||
52 | public: | ||
53 | static bool initialized() { return true; } | ||
54 | static index::State state() { return index::ALL; } | ||
55 | template <typename LeafT> | ||
56 | static index::State state(const LeafT&) { return index::ALL; } | ||
57 | |||
58 | template <typename LeafT> void reset(const LeafT&) { } | ||
59 | template <typename IterT> static bool valid(const IterT&) { return true; } | ||
60 | }; // class NullFilter | ||
61 | |||
62 | |||
63 | /// @brief A forward iterator over array indices in a single voxel | ||
64 | class ValueVoxelCIter | ||
65 | { | ||
66 | public: | ||
67 | struct Parent | ||
68 | { | ||
69 | Parent() = default; | ||
70 | 47007 | explicit Parent(Index32 offset): mOffset(offset) { } | |
71 | 44532 | Index32 getValue(unsigned /*offset*/) const { return mOffset; } | |
72 | private: | ||
73 | Index32 mOffset = 0; | ||
74 | }; // struct Parent | ||
75 | |||
76 | using NodeType = Parent; | ||
77 | |||
78 | ValueVoxelCIter() = default; | ||
79 | ValueVoxelCIter(Index32 prevOffset, Index32 offset) | ||
80 |
9/18✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
|
47007 | : mOffset(offset), mParent(prevOffset) {} |
81 | ValueVoxelCIter(const ValueVoxelCIter& other) | ||
82 | 88359 | : mOffset(other.mOffset), mParent(other.mParent), mValid(other.mValid) {} | |
83 | |||
84 | /// @brief Return the item to which this iterator is currently pointing. | ||
85 | Index32 operator*() { return mOffset; } | ||
86 | Index32 operator*() const { return mOffset; } | ||
87 | |||
88 | /// @brief Advance to the next (valid) item (prefix). | ||
89 | 46969 | ValueVoxelCIter& operator++() { mValid = false; return *this; } | |
90 | |||
91 |
34/62✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4102 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1025 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 1 times.
✗ Branch 40 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 1 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 1 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 1 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 1 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 1 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 1 times.
|
127120 | operator bool() const { return mValid; } |
92 | bool test() const { return mValid; } | ||
93 | Index32 end() const { return mOffset+1; } | ||
94 | |||
95 | void reset(Index32 /*item*/, Index32 /*end*/) {} | ||
96 | |||
97 | 47020 | Parent& parent() { return mParent; } | |
98 | Index32 offset() { return mOffset; } | ||
99 | inline bool next() { this->operator++(); return this->test(); } | ||
100 | |||
101 | /// @brief For efficiency, Coord and active state assumed to be readily available | ||
102 | /// when iterating over indices of a single voxel | ||
103 | Coord getCoord [[noreturn]] () const { | ||
104 | OPENVDB_THROW(RuntimeError, "ValueVoxelCIter does not provide a valid Coord."); | ||
105 | } | ||
106 | void getCoord [[noreturn]] (Coord& /*coord*/) const { | ||
107 | OPENVDB_THROW(RuntimeError, "ValueVoxelCIter does not provide a valid Coord."); | ||
108 | } | ||
109 | bool isValueOn [[noreturn]] () const { | ||
110 | OPENVDB_THROW(RuntimeError, "ValueVoxelCIter does not test if voxel is active."); | ||
111 | } | ||
112 | |||
113 | /// @{ | ||
114 | /// @brief Equality operators | ||
115 | bool operator==(const ValueVoxelCIter& other) const { return mOffset == other.mOffset; } | ||
116 | bool operator!=(const ValueVoxelCIter& other) const { return !this->operator==(other); } | ||
117 | /// @} | ||
118 | |||
119 | private: | ||
120 | Index32 mOffset = 0; | ||
121 | Parent mParent; | ||
122 | mutable bool mValid = true; | ||
123 | }; // class ValueVoxelCIter | ||
124 | |||
125 | |||
126 | /// @brief A forward iterator over array indices with filtering | ||
127 | /// IteratorT can be either IndexIter or ValueIndexIter (or some custom index iterator) | ||
128 | /// FilterT should be a struct or class with a valid() method than can be evaluated per index | ||
129 | /// Here's a simple filter example that only accepts even indices: | ||
130 | /// | ||
131 | /// struct EvenIndexFilter | ||
132 | /// { | ||
133 | /// bool valid(const Index32 offset) const { | ||
134 | /// return (offset % 2) == 0; | ||
135 | /// } | ||
136 | /// }; | ||
137 | /// | ||
138 | template <typename IteratorT, typename FilterT> | ||
139 |
13/22✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
|
34954 | class IndexIter |
140 | { | ||
141 | public: | ||
142 | /// @brief A forward iterator over array indices from a value iterator (such as ValueOnCIter) | ||
143 |
12/24✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
|
12 | class ValueIndexIter |
144 | { | ||
145 | public: | ||
146 | 262110 | ValueIndexIter(const IteratorT& iter) | |
147 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 85092 times.
|
262110 | : mIter(iter), mParent(&mIter.parent()) |
148 | { | ||
149 |
2/2✓ Branch 0 taken 132111 times.
✓ Branch 1 taken 1 times.
|
262110 | if (mIter) { |
150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 132111 times.
|
262108 | assert(mParent); |
151 |
2/2✓ Branch 0 taken 107508 times.
✓ Branch 1 taken 24603 times.
|
262108 | Index32 start = (mIter.offset() > 0 ? |
152 | 125952 | Index32(mParent->getValue(mIter.offset() - 1)) : Index32(0)); | |
153 | 170116 | this->reset(start, *mIter); | |
154 | 102900 | if (mItem >= mEnd) this->operator++(); | |
155 | } | ||
156 | 262110 | } | |
157 | 29882742 | ValueIndexIter(const ValueIndexIter& other) | |
158 | 29882742 | : mEnd(other.mEnd), mItem(other.mItem), mIter(other.mIter), mParent(other.mParent) | |
159 | { | ||
160 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14944286 times.
|
29882742 | assert(mParent); |
161 | 29882742 | } | |
162 | ValueIndexIter& operator=(const ValueIndexIter&) = default; | ||
163 | |||
164 |
7/12✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
20671 | inline Index32 end() const { return mEnd; } |
165 | |||
166 | inline void reset(Index32 item, Index32 end) { | ||
167 | 67048 | mItem = item; | |
168 |
18/22✓ Branch 0 taken 2083 times.
✓ Branch 1 taken 37330 times.
✓ Branch 2 taken 5315 times.
✓ Branch 3 taken 549 times.
✓ Branch 4 taken 3576 times.
✓ Branch 5 taken 38872 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 74 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 121 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2822 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 41334 times.
|
132111 | mEnd = end; |
169 | 12271356 | } | |
170 | |||
171 | /// @brief Returns the item to which this iterator is currently pointing. | ||
172 |
18/34✓ Branch 0 taken 24 times.
✓ Branch 1 taken 154125515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154125499 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
|
298250923 | inline Index32 operator*() { assert(mIter); return mItem; } |
173 |
4/9✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13697015 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13696921 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
27394009 | inline Index32 operator*() const { assert(mIter); return mItem; } |
174 | |||
175 | /// @brief Return @c true if this iterator is not yet exhausted. | ||
176 | inline operator bool() const { return mIter; } | ||
177 | inline bool test() const { return mIter; } | ||
178 | |||
179 | /// @brief Advance to the next (valid) item (prefix). | ||
180 | 167464731 | inline ValueIndexIter& operator++() { | |
181 | 167550538 | ++mItem; | |
182 |
15/18✓ Branch 0 taken 12424122 times.
✓ Branch 1 taken 83647404 times.
✓ Branch 2 taken 12340546 times.
✓ Branch 3 taken 85071 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 41327 times.
✓ Branch 11 taken 38706 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
|
217012256 | while (mItem >= mEnd && mIter.next()) { |
183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12336981 times.
|
24645872 | assert(mParent); |
184 | 24645872 | this->reset(mParent->getValue(mIter.offset() - 1), *mIter); | |
185 | } | ||
186 | 167464731 | return *this; | |
187 | } | ||
188 | |||
189 | /// @brief Advance to the next (valid) item. | ||
190 | inline bool next() { this->operator++(); return this->test(); } | ||
191 | inline bool increment() { this->next(); return this->test(); } | ||
192 | |||
193 | /// Return the coordinates of the item to which the value iterator is pointing. | ||
194 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 55729619 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55729619 times.
|
111379212 | inline Coord getCoord() const { assert(mIter); return mIter.getCoord(); } |
195 | /// Return in @a xyz the coordinates of the item to which the value iterator is pointing. | ||
196 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | inline void getCoord(Coord& xyz) const { assert(mIter); xyz = mIter.getCoord(); } |
197 | |||
198 | /// @brief Return @c true if this iterator is pointing to an active value. | ||
199 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2094 times.
|
4188 | inline bool isValueOn() const { assert(mIter); return mIter.isValueOn(); } |
200 | |||
201 | /// Return the const value iterator | ||
202 | inline const IteratorT& valueIter() const { return mIter; } | ||
203 | |||
204 | /// @brief Equality operators | ||
205 | bool operator==(const ValueIndexIter& other) const { return mItem == other.mItem; } | ||
206 | bool operator!=(const ValueIndexIter& other) const { return !this->operator==(other); } | ||
207 | |||
208 | private: | ||
209 | Index32 mEnd = 0; | ||
210 | Index32 mItem = 0; | ||
211 | IteratorT mIter; | ||
212 | const typename IteratorT::NodeType* mParent; | ||
213 | }; // ValueIndexIter | ||
214 | |||
215 | 177383 | IndexIter(const IteratorT& iterator, const FilterT& filter) | |
216 | : mIterator(iterator) | ||
217 | 220764 | , mFilter(filter) | |
218 | { | ||
219 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24277 times.
|
48554 | if (!mFilter.initialized()) { |
220 | ✗ | OPENVDB_THROW(RuntimeError, | |
221 | "Filter needs to be initialized before constructing the iterator."); | ||
222 | } | ||
223 |
2/2✓ Branch 0 taken 85160 times.
✓ Branch 1 taken 3564 times.
|
177382 | if (mIterator) { |
224 |
2/3✓ Branch 1 taken 72 times.
✓ Branch 2 taken 20662 times.
✗ Branch 3 not taken.
|
170246 | this->reset(*mIterator, mIterator.end()); |
225 | } | ||
226 | 177382 | } | |
227 | 59757 | IndexIter(const IndexIter& other) | |
228 | 59757 | : mIterator(other.mIterator) | |
229 | 14905736 | , mFilter(other.mFilter) | |
230 | { | ||
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10950 times.
|
16064 | if (!mFilter.initialized()) { |
232 | ✗ | OPENVDB_THROW(RuntimeError, | |
233 | "Filter needs to be initialized before constructing the iterator."); | ||
234 | } | ||
235 | 59757 | } | |
236 | IndexIter& operator=(const IndexIter& other) | ||
237 | { | ||
238 | if (&other != this) { | ||
239 | mIterator = other.mIterator; | ||
240 | mFilter = other.mFilter; | ||
241 | if (!mFilter.initialized()) { | ||
242 | OPENVDB_THROW(RuntimeError, | ||
243 | "Filter needs to be initialized before constructing the iterator."); | ||
244 | } | ||
245 | } | ||
246 | return *this; | ||
247 | } | ||
248 | |||
249 | Index32 end() const { return mIterator.end(); } | ||
250 | |||
251 | /// @brief Reset the begining and end of the iterator. | ||
252 | 41457 | void reset(Index32 begin, Index32 end) { | |
253 | 41457 | mIterator.reset(begin, end); | |
254 |
6/8✓ Branch 0 taken 34721 times.
✓ Branch 1 taken 287 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 13639 times.
✓ Branch 4 taken 20445 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
|
99573 | while (mIterator.test() && !mFilter.template valid<ValueIndexIter>(mIterator)) { |
255 | 28338 | ++mIterator; | |
256 | } | ||
257 | 41457 | } | |
258 | |||
259 | /// @brief Returns the item to which this iterator is currently pointing. | ||
260 |
17/33✗ Branch 0 not taken.
✓ Branch 1 taken 144040417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144040415 times.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 1 times.
|
288000759 | Index32 operator*() { assert(mIterator); return *mIterator; } |
261 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 7674304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7674304 times.
|
15348580 | Index32 operator*() const { assert(mIterator); return *mIterator; } |
262 | |||
263 | /// @brief Return @c true if this iterator is not yet exhausted. | ||
264 | operator bool() const { return mIterator.test(); } | ||
265 | bool test() const { return mIterator.test(); } | ||
266 | |||
267 | /// @brief Advance to the next (valid) item (prefix). | ||
268 | 141425129 | IndexIter& operator++() { | |
269 | while (true) { | ||
270 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 42 times.
|
147425610 | ++mIterator; |
271 |
14/20✓ Branch 0 taken 6990136 times.
✓ Branch 1 taken 20454 times.
✓ Branch 2 taken 426 times.
✓ Branch 3 taken 3000859 times.
✓ Branch 4 taken 3988853 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
|
14024013 | if (!mIterator.test() || mFilter.template valid<ValueIndexIter>(mIterator)) { |
272 | break; | ||
273 | } | ||
274 | } | ||
275 | 141425129 | return *this; | |
276 | } | ||
277 | |||
278 | /// @brief Advance to the next (valid) item (postfix). | ||
279 | 7 | IndexIter operator++(int /*dummy*/) { | |
280 |
10/68✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 5000 times.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 49 taken 4 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 3 times.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✓ Branch 100 taken 4 times.
✗ Branch 101 not taken.
|
5046 | IndexIter newIterator(*this); |
281 |
39/154✓ Branch 1 taken 80016 times.
✓ Branch 2 taken 10 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 1 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 1 times.
✓ Branch 19 taken 8 times.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 6 times.
✓ Branch 25 taken 15 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1654104 times.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 3 times.
✓ Branch 34 taken 8 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 4 times.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 43 taken 4 times.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✓ Branch 47 taken 1 times.
✓ Branch 49 taken 8 times.
✗ Branch 50 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 6 times.
✓ Branch 55 taken 15 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1654104 times.
✗ Branch 59 not taken.
✗ Branch 61 not taken.
✓ Branch 62 taken 5000 times.
✓ Branch 64 taken 4 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 4 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 4 times.
✓ Branch 74 taken 4 times.
✓ Branch 76 taken 4 times.
✗ Branch 77 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✓ Branch 100 taken 3837100 times.
✗ Branch 101 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 3 times.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 175 not taken.
✓ Branch 176 taken 4 times.
✓ Branch 178 taken 4 times.
✗ Branch 179 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 190 not taken.
✗ Branch 191 not taken.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✓ Branch 202 taken 3837100 times.
✗ Branch 203 not taken.
✓ Branch 205 taken 3 times.
✗ Branch 206 not taken.
✓ Branch 208 taken 3827080 times.
✗ Branch 209 not taken.
✓ Branch 211 taken 4 times.
✗ Branch 212 not taken.
✓ Branch 214 taken 4 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 4 times.
✗ Branch 218 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
|
14894693 | this->operator++(); |
282 | 14889654 | return newIterator; | |
283 | } | ||
284 | |||
285 | /// @brief Advance to the next (valid) item. | ||
286 |
8/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
|
8 | bool next() { this->operator++(); return this->test(); } |
287 | bool increment() { this->next(); return this->test(); } | ||
288 | |||
289 | /// Return the const filter | ||
290 | inline const FilterT& filter() const { return mFilter; } | ||
291 | |||
292 | /// Return the coordinates of the item to which the value iterator is pointing. | ||
293 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 55729609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55729609 times.
|
111379193 | inline Coord getCoord() const { assert(mIterator); return mIterator.getCoord(); } |
294 | /// Return in @a xyz the coordinates of the item to which the value iterator is pointing. | ||
295 | inline void getCoord(Coord& xyz) const { assert(mIterator); xyz = mIterator.getCoord(); } | ||
296 | |||
297 | /// @brief Return @c true if the value iterator is pointing to an active value. | ||
298 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
|
18 | inline bool isValueOn() const { assert(mIterator); return mIterator.valueIter().isValueOn(); } |
299 | |||
300 | /// @brief Equality operators | ||
301 | bool operator==(const IndexIter& other) const { return mIterator == other.mIterator; } | ||
302 | bool operator!=(const IndexIter& other) const { return !this->operator==(other); } | ||
303 | |||
304 | private: | ||
305 | ValueIndexIter mIterator; | ||
306 | FilterT mFilter; | ||
307 | }; // class IndexIter | ||
308 | |||
309 | |||
310 | //////////////////////////////////////// | ||
311 | |||
312 | |||
313 | template <typename IterT> | ||
314 | 49592 | inline Index64 iterCount(const IterT& iter) | |
315 | { | ||
316 | Index64 size = 0; | ||
317 |
4/5✓ Branch 0 taken 3827873 times.
✓ Branch 1 taken 1502381 times.
✓ Branch 2 taken 5837 times.
✓ Branch 4 taken 1500030 times.
✗ Branch 5 not taken.
|
5467623 | for (IterT newIter(iter); newIter; ++newIter, ++size) { } |
318 | 49592 | return size; | |
319 | } | ||
320 | |||
321 | |||
322 | //////////////////////////////////////// | ||
323 | |||
324 | |||
325 | } // namespace points | ||
326 | } // namespace OPENVDB_VERSION_NAME | ||
327 | } // namespace openvdb | ||
328 | |||
329 | #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED | ||
330 |