| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object | +--ncsa.horizon.util.Voxel
A Voxel represents a position in a data space whose dimensions are specified in its constructor call. Positions in the space are described (naturally) by a vector giving the component of the position along each axis; these components can be queried, for example, via the getPos() method returning an integer array . Component positions restricted to the range of a regular integer; however, the positions are in general floating point numbers--that is, Voxels can describe fractional positions within the space. If a fractional position is desired, one can call getExactPos() (returning a double array).
(It should be noted that a Voxel object does not include the data value or color associated with the position. This is perhaps contrary to other uses of the term "voxel"--the author apologizes.)
It is assumed that most applications will be interested integer positions in the space (e.g. because the data exists at integer positions within a data array). Thus, the Voxel class is optimized for access to integer positions (via the IntLikeDblArray class), even when a Voxel is actually set to a fractions position. If a Voxel is set to a fractional position and one asks for a whole position by calling getPos(), the nearest whole position will be returned.
Components of the position can be accessed individually via the methods that take an axis index. The first axis has an index of zero.
In this implementation, Voxels are immutable--that is, they refer to a single position that cannot change. (This is a new with Horizon 2.0.) Thus, isMutable() always returns false. When Voxel.isMutable() returns false, objects can feel free to share a reference to the Voxel without worry about it changing. In contrast, a MoveableVoxel is change-able (isMutable() returns true). Voxel subclasses (like MoveableVoxel) should override their isMutable() methods to return true if they allow the position to change with time.
See also Volume, Slice, Segment, MoveableVoxel, VolumeIterator, and IntLikeDblArray.
| Field Summary | |
| static int | MAX_AXIS_POSITION
the maximum position along one axis that a Voxel can have. |
| Constructor Summary | |
| Voxel(int nax)
create a Voxel in a space of nax dimensions and initialize it to the origin (i.e. position = [0, 0, 0, ...]). |
|
| Voxel(int nax,
int[] in)
create a Voxel in a space of nax dimensions and initialize it with a position. |
|
| Voxel(int[] in)
create a Voxel in a space of in.length dimensions and initialize it with a position. |
|
| Voxel(int nax,
double[] in)
create a Voxel in a space of nax dimensions and initialize it with a position. |
|
| Voxel(double[] in)
create a Voxel in a space of nax dimensions and initialize it with a position. |
|
| Voxel(Voxel that)
create an immutable Voxel positioned at the location of anoher Voxel |
|
| Method Summary | |
| Voxel | add(Voxel vox)
return a Voxel that is the sum of this Voxel and the projection of another Voxel into this space. |
| double | axisPos(int i)
Deprecated. get the projection of the Voxel's position along the i-th axis. |
| java.lang.Object | clone()
create a deep copy of this Voxel |
| static int[] | doubleToInt(double[] in)
convert a double array to an integer array. |
| boolean | equals(Voxel vox)
return true if another Voxel is (in principle) at the same location as this Voxel. |
| boolean | equals(java.lang.Object vox)
|
| double | getExactPos(int i)
get the exact projection of the Voxel's position along the i-th axis. |
| double[] | getExactPos()
get the exact projection of the Voxel's position along the i-th axis. |
| java.util.Observable | getMonitor()
return an Observable monitor for listening for changes to this Voxel, or null if this Voxel is immutable. |
| int | getNaxes()
return the number of dimensions in the space containing this Voxel |
| int | getPos(int i)
get the projection of the Voxel's position along the i-th axis, rounded to the nearest integer. |
| int[] | getPos()
return the position of this voxel rounded to the nearest whole voxel |
| double[] | getValues(int firstaxis)
Deprecated. return an array of doubles representing the position along each axis |
| int | hashCode()
compute a hashcode for this Voxel. |
| static double[] | intToDouble(int[] in)
converts a integer array to double array. |
| boolean | isMutable()
return true if the position of this Voxel can change |
| static int[] | roundDoubleToInt(double[] in)
convert a double array to an integer array. |
| static int[] | roundToInt(double[] in)
round a double array to an integer array. |
| Voxel | subtract(Voxel vox)
return a Voxel that is the differenc of another Voxel from this Voxel |
| java.lang.String | toString()
converts position to (x, y, ...) formatted string |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
public static final int MAX_AXIS_POSITION
| Constructor Detail |
public Voxel(int nax)
throws ValueOutOfBoundsException
nax
- number of axes or dimensions in the space
public Voxel(int nax,
int[] in)
throws ValueOutOfBoundsException
nax
- number of axes or dimensions in the space
in
- an array containing the position. The first nax
elements will be used. If the array size is smaller
than nax, the remaining components will be 0.public Voxel(int[] in)
in
- an array containing the position. The first nax
elements will be used. If the array size is smaller
than nax, the remaining components will be 0.
public Voxel(int nax,
double[] in)
throws ValueOutOfBoundsException,
PositionOutOfBoundsException
nax
- number of axes or dimensions in the space
in
- an array containing the position. The first nax
elements will be used. If the array size is smaller
than nax, the remaining components will be 0.
public Voxel(double[] in)
throws PositionOutOfBoundsException
nax
- number of axes or dimensions in the space
in
- an array containing the position. The first nax
elements will be used. If the array size is smaller
than nax, the remaining components will be 0.public Voxel(Voxel that)
| Method Detail |
public int getNaxes()
public int getPos(int i)
throws java.lang.ArrayIndexOutOfBoundsException
public double axisPos(int i)
throws java.lang.ArrayIndexOutOfBoundsException
public double getExactPos(int i)
throws java.lang.ArrayIndexOutOfBoundsException
public double[] getExactPos()
throws java.lang.ArrayIndexOutOfBoundsException
public double[] getValues(int firstaxis)
throws java.lang.ArrayIndexOutOfBoundsException
firstaxis
- index at which first value should appearpublic int[] getPos()
public java.lang.String toString()
public java.lang.Object clone()
public boolean equals(Voxel vox)
public boolean equals(java.lang.Object vox)
public boolean isMutable()
public java.util.Observable getMonitor()
public static int[] roundToInt(double[] in)
throws PositionOutOfBoundsException
public Voxel add(Voxel vox)
public Voxel subtract(Voxel vox)
public static int[] doubleToInt(double[] in)
public static int[] roundDoubleToInt(double[] in)
public static double[] intToDouble(int[] in)
public final int hashCode()
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||