next up previous contents
Next: Using Volume Processing Plugins Up: Accessing Volumetric Data using Previous: Accessing Voxel Data   Contents

Moving Iterator Around

The iterator can be moved around from the position it is at a certain instance. Functionality is provided to move the iterator to any of its neighboring voxels. The simplest function is next() which moves the iterator to the next voxel in the volume. The important point to note about next() is that the voxel pointed to by the iterator after a call to next() might not be a neighborhood of the earlier voxel. That is, next() does not specify which voxel it will move the iterator to. It is simply the fastest way to access all the voxels in a volume.

If you want to move the iterator to a voxel position in the neighborhood of the current voxel, you can use the following:

// Move to the next voxel along X. If there are no more voxels
// along X, then move along Y, then Z ...
iter.nextXYZ();
// Move to the next voxel along Z
iter.nextZXY();
// Move to previous voxel along Y
iter.prevYZX();

The iterator can also be moved to any voxel that is a relative position away from the current. For example, to move the iterator to another voxel at say $ (3, -1, 2)$ from the current position:

iter.moveRelative(vlPoint3i(3, -1, 2));

The iterator can also be moved to any position in a volume using:

bool ret = iter.moveTo(vlPoint3ui(10,5,8));
if (ret == false)
    std::cout « "moveTo failed. Moving outside volume?" « std::endl;

The moveTo function takes a position in the volume coordinates and moves the iterator to the new position if the position is valid. That is, the given position must be inside the bounds of the volume. If it fails to move, it returns false, else it returns true. It should be noted that moving iterators may not be very effecient and should be avoided as much as possible. The OpenVL iterators are always optimized for accessing and moving within the immediate neighborhood of a voxel.


next up previous contents
Next: Using Volume Processing Plugins Up: Accessing Volumetric Data using Previous: Accessing Voxel Data   Contents
Sarang Lakare 2003-04-26