Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.util.VolumeIterator

java.lang.Object
  |
  +--ncsa.horizon.util.Voxel
        |
        +--ncsa.horizon.util.VolumeIterator

public class VolumeIterator
extends Voxel
a pointer for iterating through the data voxels selected by a Volume object.

This class allows one to actually access data from an N-dimensional array as specified by a Volume object taking into a account the data sampling and order. (The Volume's interpretation flags are ignored.) This is done via 3 basic actions:

  1. initializing the iterator by passing the Volume object to the VolumeIterator's constructor,
  2. querying for the new position (e.g. via getPos()),
  3. incrementing the iterator to the next position via increment(), decrement(), or related method.

Because a VolumeIterator is a Voxel, it can be passed to any method that takes a Voxel as an argument.

See Also:
Voxel, Serialized Form

Field Summary
double[] first
          the first voxel in the volume
double[] last
          the last voxel in the volume
boolean noMore
          true if the iterator has stepped out of range of the volume.
int[] order
          the order of the axes
double[] samp
          the sampling to use when iterating through the volume
 
Fields inherited from class ncsa.horizon.util.Voxel
MAX_AXIS_POSITION
 
Constructor Summary
VolumeIterator(Volume volume, boolean begin)
          create an iterator for a given volume
VolumeIterator(Volume volume)
          create an iterator for a given volume and set it at the volume's first voxel.
 
Method Summary
java.lang.Object clone()
          return a clone of this iterator
void decrementRow()
          decrement the iterator by one row.
void decrementSlice()
          decrement the iterator by one slice.
void decrement(int axis)
          decrement the iterator by one sampling unit along the given axis.
void decrement()
          decrement the iterator by one voxel.
java.util.Observable getMonitor()
          return an Observable monitor for listening for changes to this Voxel.
int[] getPosRef()
          get a reference to the integer array pointing to the current position.
void incrementRow()
          increment the iterator by one row.
void incrementSlice()
          increment the iterator by one slice.
void increment(int axis)
          increment the iterator by one sampling unit along the given axis The input is the "reordered" axis index in that the axis ordering specified by the volume will be applied to it.
void increment()
          increment the iterator by one voxel.
boolean isMutable()
          return true if the position of this Voxel can change
boolean isValid()
          return true if the iterator currently points to a valid voxel from the volume, or false if there are no more voxels.
void setAtFirst()
          set iterator at the first voxel
void setAtLast()
          set iterator at the first voxel
 
Methods inherited from class ncsa.horizon.util.Voxel
add, axisPos, clone, doubleToInt, equals, equals, getExactPos, getExactPos, getMonitor, getNaxes, getPos, getPos, getValues, hashCode, intToDouble, isMutable, roundDoubleToInt, roundToInt, subtract, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

first

protected double[] first
the first voxel in the volume

last

protected double[] last
the last voxel in the volume

samp

protected double[] samp
the sampling to use when iterating through the volume

order

protected int[] order
the order of the axes

noMore

protected boolean noMore
true if the iterator has stepped out of range of the volume. That is, there is no more voxels within the volume.
Constructor Detail

VolumeIterator

public VolumeIterator(Volume volume,
                      boolean begin)
create an iterator for a given volume
Parameters:
volume - the volume to iterate through
begin - true if the iterator should be initially set to the first voxel in the volume; false if it should be set to the last voxel (for incrementing in reverse).

VolumeIterator

public VolumeIterator(Volume volume)
create an iterator for a given volume and set it at the volume's first voxel.
Parameters:
volume - the volume to iterate through
Method Detail

isMutable

public boolean isMutable()
return true if the position of this Voxel can change
Overrides:
isMutable in class Voxel

getMonitor

public java.util.Observable getMonitor()
return an Observable monitor for listening for changes to this Voxel. Clients interested in such changes can add themselves to the Observable returned by this method. They will be notified when the Voxel position changes, passing this Voxel as an argument to the Observers' update() method.
Overrides:
getMonitor in class Voxel

getPosRef

public final int[] getPosRef()
get a reference to the integer array pointing to the current position. This method is faster than getPos() (because it does not have to create a copy of the array); however, it should be used with care for read-only purposes. Directly editing the values will corrupt this iterator in possibly unexpected ways.

increment

public void increment(int axis)
increment the iterator by one sampling unit along the given axis The input is the "reordered" axis index in that the axis ordering specified by the volume will be applied to it.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if axis < 0 or >= the number of axes in the volume.

increment

public void increment()
increment the iterator by one voxel. The order of the axes specified by the volume will be taken into account.

incrementRow

public void incrementRow()
increment the iterator by one row. That is, increment by one sampling unit along the second axis. This method does nothing if the volume contains only one axis.

incrementSlice

public void incrementSlice()
increment the iterator by one slice. That is, increment by one sampling unit along the third axis. This method does nothing if the volume contains two or fewer axes.

decrement

public void decrement(int axis)
decrement the iterator by one sampling unit along the given axis. The input is the "reordered" axis index in that the axis ordering specified by the volume will be applied to it.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if axis < 0 or >= the number of axes in the volume.

decrement

public void decrement()
decrement the iterator by one voxel. The order of the axes specified by the volume will be taken into account.

decrementRow

public void decrementRow()
decrement the iterator by one row. That is, decrement by one sampling unit along the second axis. This method does nothing if the volume contains only one axis.

decrementSlice

public void decrementSlice()
decrement the iterator by one slice. That is, decrement by one sampling unit along the third axis. This method does nothing if the volume contains two or fewer axes.

isValid

public boolean isValid()
return true if the iterator currently points to a valid voxel from the volume, or false if there are no more voxels.

setAtFirst

public void setAtFirst()
set iterator at the first voxel

setAtLast

public void setAtLast()
set iterator at the first voxel

clone

public java.lang.Object clone()
return a clone of this iterator
Overrides:
clone in class Voxel

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD