You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement iterator over 2D pixel coordinates (#28)
Closes MET-56
## Summary of Changes
This PR implements a `PixelCoordRange` class, which defines `.begin()`
and `.end()` methods compliant with C++'s range-expression. Instead of
using two `Iterator` to denote the range, the `end()` returns a special
`Sentinel` object, which requires less bookkeeping information (e.g. it
doesn't need to keep another copy of the pixel start & end location).
[You can read more about C++20's Iterator Sentinel feature here if
interested :)](https://www.foonathan.net/2020/03/iterator-sentinel/).
With this new class, we can now iterating over 2D pixels using
range-based for loop ([as we wished for in
Slack](https://probcomp.slack.com/archives/C09RM9VCCLQ/p1764124142124389)),
i.e.,
```cpp
auto pixel_ranges = PixelCoordRange{ i_start, i_end, j_start, j_end };
for (auto pixel_coords : pixel_ranges)
// do something
```
## Test Plan
This new pixel coordinate generator replaces the need to have a
dedicated `Intrinsics.get_ray_directions_kernels` method (which is
removed in this PR). As such, `camera_test.cu` has been updated
accordingly to show & test that [range-based for
loop](https://github.com/probcomp/GenMetaBalls/pull/28/files#diff-b9bfc85cd301b1b50504120cdc05a855e0cd3013c0d5d8d506821520b988a393R22-R26)
works as expected.
As always, to run the tests:
```bash
pixi run ctest
```
0 commit comments