Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::util::BrickIterator< Iter > Class Template Reference

An iterator providing access to a subregion, or brick, within linearized 3D data. More...

#include <brickiterator.h>

Public Types

using base_category = typename std::iterator_traits<Iter>::iterator_category
 
using difference_type = typename std::iterator_traits<Iter>::difference_type
 
using iterator_category = std::bidirectional_iterator_tag
 
using value_type = typename std::iterator_traits<Iter>::value_type
 
using pointer = typename std::iterator_traits<Iter>::pointer
 
using reference = typename std::iterator_traits<Iter>::reference
 

Public Member Functions

 BrickIterator (Iter iterator, size3_t dims, size3_t offset, size3_t extent)
 
BrickIteratoroperator++ ()
 
BrickIterator operator++ (int)
 
BrickIteratoroperator-- ()
 
BrickIterator operator-- (int)
 
reference operator* () const
 
pointer operator-> () const
 
bool operator== (const BrickIterator &rhs) const
 
bool operator!= (const BrickIterator &rhs) const
 
const Iter & base () const
 
Iter & base ()
 
size3_t globalPos () const
 
size3_t blockPos () const
 
BrickIterator begin () const
 
BrickIterator end () const
 

Detailed Description

template<typename Iter>
class inviwo::util::BrickIterator< Iter >

An iterator providing access to a subregion, or brick, within linearized 3D data.

This iterator provides access to and iterates over a subregion within 3D data. The 3D data is assumed to be contiguous, i.e. linearized, in x, then y, then z similar to IndexMapper3D. Initially, the iterator points to the first voxel of the brick. Iteration takes place in x direction, followed by y and z, respectively.

BrickIterator::end() provides the matching end iterator

See also
util::IndexMapper3D

Example:

std::vector<int> data(27); // linearized data of a 3x3x3 volume
// create a brick iterator starting at (1,1,1) with an extent of (2,2,2)
auto it = util::BrickIterator{data.begin(), size3_t{3, 3, 3},
size3_t{1, 1, 1}, size3_t{2, 2, 2}};
// copy the data elements of the brick iterator into a std::vector,
// the vector will contain the corresponding 8 voxels
std::vector<int> block(it, it.end());
An iterator providing access to a subregion, or brick, within linearized 3D data.
Definition brickiterator.h:89

Here, a single voxel at position (2,0,0) of a VolumeRAM is extracted.

auto volume = VolumeRAMPrecision<float>(size3_t{3, 3, 3});
int value = *util::BrickIterator{volume.getDataTyped(), volume.getDimensions(),
size3_t{2, 0, 0}, size3_t{1, 1, 1}};
Definition volumeramdistancetransform.h:63

Modify a subregion within a volume.

std::vector<int> data(5 * 4 * 6);
auto it = util::BrickIterator{data.begin(), size3_t{5, 4, 6},
size3_t{3, 1, 2}, size3_t{2, 3, 3}};
for (auto& elem : it) {
elem *= 2;
}

Constructor & Destructor Documentation

◆ BrickIterator()

template<typename Iter >
inviwo::util::BrickIterator< Iter >::BrickIterator ( Iter iterator,
size3_t dims,
size3_t offset,
size3_t extent )
inline

Creates an brick iterator given an iterator to an array containing linearized volume data and its corresponding volume dimensions.

Parameters
iteratoriterator pointing to the begin of the linearized source data
dimsdimensions of the source volume
offsetstarting position of the brick
extentextent of the brick, i.e. the region the iterator should iterate over

The documentation for this class was generated from the following file: