edu.unh.sdb.datasource
Class ISBounds

java.lang.Object
  extended by edu.unh.sdb.common.Bounds
      extended by edu.unh.sdb.datasource.ISBounds
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ISBoundsIterator

public class ISBounds
extends Bounds
implements java.lang.Cloneable, java.io.Serializable

The ISBounds class is meant to represent hypercubic subregions in an n-dimensional index space. Typically, a lower and upper corner point are given to the constructor, although it is also possible to just specify the dimensions of the subregion, yielding an ISBounds of the proper size situated at the origin. The dimensionality of an ISBounds is taken from the dimensionality of the corner points, which are assumed to match.

See Also:
Serialized Form

Field Summary
protected  int[] lower
           
protected  int[] upper
           
 
Constructor Summary
  ISBounds(IndexSpaceID dimensions)
          This constructor takes a single IndexSpaceID that defines the dimensions of a hypercube with lower coordinates at the origin.
  ISBounds(IndexSpaceID corner1, IndexSpaceID corner2)
          This constructor takes two corner points (SpaceIDs) that define a hypercube of arbitrary dimensionality.
protected ISBounds(int dimensionality)
          This constructor just allocates space for the lower and upper arrays.
  ISBounds(int[] dimensions)
          This constructor takes a single integer array that defines the dimensions of a hypercube with lower coordinates at the origin.
  ISBounds(int[] lower, int[] upper)
          This constructor takes two corner points expressed as int arrays that define a hypercube of arbitrary dimensionality.
  ISBounds(int dim, int[] bounds)
          This constructor allocates an ISBounds of the dimensionality defined by the first argument.
  ISBounds(ISBounds bounds)
          Construct a copy of the argument bounds.
 
Method Summary
 ISBounds boundingVolume(ISBounds db)
          Deprecated. Use setToBoundingVolume( ISBounds )
 java.lang.Object clone()
          Return a copy of this ISBounds object
 boolean contains(IndexSpaceID id)
          Returns true if this Bounds contains the coordinates contained in the integer array.
 boolean contains(int[] coords)
          Returns true if this Bounds contains the coordinates contained in the integer array.
 boolean contains(ISBounds b2)
          Returns true if this Bounds completely contains the argument bounds.
 boolean containsExcludeUpper(IndexSpaceID id)
          Returns true if this Bounds contains the coordinates represented in the IndexSpaceID.
 boolean containsExcludeUpper(int[] coords)
          Returns true if this Bounds contains the coordinates represented in the integer array.
 ISBounds copy()
          Return a copy of this ISBounds object
 ISBounds copy(ISBounds b)
          Deprecated. Use set( ISBounds )
 ISBounds copyAndMove(int[] distance)
          Create a copy of this bounds moved by the relative amount specified by the argument.
 ISBounds copyAndMove(ISBounds b, int[] distance)
          Deprecated. Use setAndMove( ISBounds, int[] )
 ISBounds copyAndMoveCenterTo(IndexSpaceID loc)
          Create a copy of this bounds moved the center to the specified location.
 ISBounds copyAndMoveCenterTo(int[] loc)
          Create a copy of this bounds moved the center to the specified location.
 ISBounds copyAndMoveTo(int[] loc)
          Create a copy of this bounds moved the lower left corner to the specified location.
 ISBounds copyAndMoveTo(ISBounds b, int[] destination)
          Deprecated. Use setAndMoveTo( ISBounds, int[] )
static ISBounds copyAndMoveToOrigin(ISBounds bounds)
          Deprecated. Use bounds.copyToOrigin( )
 ISBounds copyExpandBy(int n)
          Return a new ISBounds that has upper and lower coordinates that are moved outward by the specified distance.
 ISBounds copyIncreasedBy(int n)
          Return a new ISBounds that has upper coordinates that are increased by the specified amount from the upper coordinates of this ISBounds.
 IntegerIndexSpaceID copyLower()
          Return an IndexSpaceID representing the lower bounds.
 ISBounds copyLower(int[] lower)
          Deprecated. Use setLower( int [] )
 int[] copyLowerArray()
          Return a reference to the integer array representing the lower bounds.
 int[] copyLowerArray(int[] arr)
          Copy the lower bound coordinates into the array argument.
 ISBounds copyReducedBy(int n)
          Return a new ISBounds that has upper coordinates that are reduced by the specified amount from the upper coordinates of this ISBounds.
 ISBounds copyScaled(double[] scales)
          Return a new ISBounds with dimensions that have been scaled by the the argument array.
 ISBounds copyScaled(float[] scales)
          Return a new ISBounds with dimensions that have been scaled by the the argument array.
 ISBounds copyScaled(int[] scales)
          Return a new ISBounds with dimensions that have been scaled by the the argument array.
 ISBounds copyShrinkBy(int n)
          Return a new ISBounds that has upper and lower coordinates that are moved inward by the specified distance.
 ISBounds copyTo(IndexSpaceID lower)
          create a new ISBounds from this one with lower bounds at specified IndexSpace position and upper bounds defined by the size of this ISBounds.
 ISBounds copyTo(int[] lowerArray)
          create a new ISBounds from this one with lower bounds at specified position and upper bounds defined by the size of this ISBounds.
 ISBounds copyToOrigin()
          create a new ISBounds from this one with lower bounds at the origin, and upper bounds defined by the size of this ISBounds.
 IntegerIndexSpaceID copyUpper()
          Return an IndexSpaceID representing the upper bounds.
 ISBounds copyUpper(int[] upper)
          Deprecated. Use setUpper( int [] ) "this" is returned for convenience of use.
 int[] copyUpperArray()
          Return a copy of the integer array representing the upper bounds.
 int[] copyUpperArray(int[] arr)
          Copy the upper bound coordinates into the array argument.
static ISBounds createAtOrigin(IndexSpaceID id)
          create a new ISBounds with lower bounds at the origin, and upper bounds with the specified IndexSpaceID.
static ISBounds createAtOrigin(int[] coords)
          Create a new ISBounds with lower bounds at the origin, and upper bounds with coordinates corresponding to the integer array argument.
static ISBounds createCentered(IndexSpaceID shape, IndexSpaceID center)
          Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are the same as the dimensions of the 1st argument.
static ISBounds createCentered(int[] shape, int[] center)
          Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are given by the 1st argument.
static ISBounds createCentered(ISBounds shape, IndexSpaceID center)
          Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are the same as the dimensions of the 1st argument.
 int dim()
          Return dimensionality of Bounds.
 boolean equals(ISBounds b)
          Return true if parameter is equal to this object, false otherwise.
 boolean equalShape(ISBounds b)
          Return true if parameter has the same size in all dimensions as this object, false otherwise.
protected  boolean equalShapeAfterProject(ISBounds b)
          Returns true if the passed bounds has the same shape as this bounds after the higher dimensioned bounds is projected along any dimension that is of length 1.
 ISBounds expand(int n)
          Deprecated. Use copyExpandBy( int )
 int getDimension(int axis)
          Return the length of the axis specified as an argument.
 IndexSpaceID getDimensions()
          Return an IndexSpaceID with axis values denoting the size of each corresponding dimension of the ISBounds.
 int[] getDimensions(int[] dimensions)
          Fill the argument array with coordinate values denoting the size of each corresponding dimension of the ISBounds.
 int[] getDimensionsArray()
          Return an int array with axis values denoting the size of each corresponding dimension of the ISBounds.
 IntegerIndexSpaceID getLower()
          Return an IndexSpaceID representing the lower bounds.
 int getLower(int axis)
          Return an int representing the lower bound of the specified dimension.
 int[] getLowerArray()
          Return a reference to the integer array representing the upper bounds.
 int[] getLowerArray(int[] arr)
          Deprecated. Use copyLowerArray( int [] )
 IntegerIndexSpaceID getUpper()
          Return an IndexSpaceID representing the upper bounds.
 int getUpper(int axis)
          Return an int representing the upper bound of the specified dimension.
 int[] getUpperArray()
          Return a reference to the integer array representing the upper bounds.
 int[] getUpperArray(int[] arr)
          Deprecated. Use copyUpperArray( int [] )
 IndexSpaceID getVertex(int vertexNumber, IndexSpaceID id)
          Fills the second argument with the coordinates of the specified vertex.
 int[] getVertex(int vertexNumber, int[] coords)
          Fills the second argument with the coordinates of the specified vertex.
 boolean hasSameShape(ISBounds b)
          Returns true if the argument bounds has the same shape as this ISBounds, and false otherwise.
 ISBounds increase(int n)
          Deprecated. Use copyIncreasedBy( int )
 ISBounds increaseByOne()
          Deprecated. Use copyIncreasedBy( 1 )
 void increaseByOne(ISBounds b)
          Deprecated. rdb: I find the semantics very confusing. One would expect that the this object would be the one changed, not the argument object. Why do we need this? It is exactly the same as b.increaseByOne(); All other similar methods either change "this" or return a new object (except increaseByOne(ISB)).
 ISBounds intersection(ISBounds b2)
          Returns the intersecton of this object with the ISBounds argument.
 boolean intersects(ISBounds b2)
          If the intersection of this with the argument is non-empty, the method returns true, and false otherwise.
 ISBounds intersectWith(ISBounds b2)
          Updates this ISBounds to the intersection of itself with the argument.
 boolean isSlice(IndexSpaceID dimensionsID, int axis)
          Returns true if the argument IndexSpaceId represents the dimensions of a slice of this ISBounds of arbitrary thickness in the specified axis.
 long longVolume()
          Return the total volume of the ISBounds as a long.
static void main(java.lang.String[] args)
          For debugging.
 ISBounds makeRelativeTo(IndexSpaceID localOrigin)
          Translate this ISBounds in space so it is expressed in the local coordinate system whose origin is at the IndexSpaceId passed as an argument.
 ISBounds makeRelativeTo(int[] localOrigin)
          Translate this ISBounds in space so it is expressed in the local coordinate system whose origin is at the IndexSpaceId passed as an argument.
 ISBounds move(IndexSpaceID distance)
          Translate the ISBounds object in space by the value of the parameter IndexSpaceID.
 ISBounds move(int[] distance)
          Translate the ISBounds object in space by the coordinates in the integer array argument.
 ISBounds move(int axis, int distance)
          Translate the ISBounds object in space along the specified axis by the specified distance.
 ISBounds moveCenterTo(IndexSpaceID location)
          Translate the ISBounds object in space so that the center is moved to the coordinates specified in the integer array argument.
 ISBounds moveCenterTo(int[] location)
          Translate the ISBounds object in space so that the center is moved to the coordinates specified in the integer array argument.
 ISBounds moveTo(IndexSpaceID location)
          Translate the ISBounds object in space so that the lower left corner is moved to the location specified by the parameter IndexSpaceID.
 ISBounds moveTo(int[] location)
          Translate the ISBounds object in space so that the lower left corner is moved to the coordinates specified int the integer array argument.
 ISBounds moveToOrigin()
          Translate this ISBounds in space so that the lower point is now at the origin.
static ISBounds newBoundsAtOrigin(IndexSpaceID id)
          Deprecated. Use createAtOrigin( isid )
 ISBounds project(int axis)
          Returns a new ISBounds which is the projection of this ISBounds onto a plane orthogonal to the specified axis.
 ISBounds reduce(int n)
          Deprecated. Use copyReducedBy( int )
 ISBounds reduceByOne()
          Deprecated. Use copyReducedBy( 1 )
 void reduceByOne(ISBounds b)
          Deprecated. rdb: I find the semantics very confusing. One would expect that the this object would be the one changed, not the argument object. Especially since our other similar methods either change "this" or return a new object (except decreaseByOne(ISB)).
 ISBounds set(ISBounds b)
          Copy the upper and lower bounds of the argument ISBounds into this object.
 ISBounds setAndMove(ISBounds b, int[] distance)
          Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument.
 ISBounds setAndMoveTo(ISBounds b, int[] destination)
          Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument.
 ISBounds setLower(IndexSpaceID lower)
          Set the lower bounds to the coordinates represented by the IndexSpaceID argument.
 ISBounds setLower(int[] lower)
          Set the lower bounds to the coordinates represented by the integer array argument.
 ISBounds setLower(int axis, int newValue)
          set the lower bounds of a given axis specified in the argument "this" is returned for convenience of use.
 ISBounds setToBoundingVolume(ISBounds db)
          Updates this ISBounds object to be the bounding volume of this ISBounds and the parameter ISBounds.
 ISBounds setUpper(IndexSpaceID upper)
          Set the upper bounds to the coordinates represented by the IndexSpaceID argument.
 ISBounds setUpper(int[] upper)
          Set the upper bounds to the coordinates represented by the integer array argument.
 ISBounds setUpper(int axis, int newValue)
          Set the upper bounds of a given axis specified in the argument "this" is returned for convenience of use.
 ISBounds slice(int axis, int coordinate)
          Returns a new ISBounds which is a slice of this ISBounds of thickness 1 in a plane orthogonal to the specified axis, having the given coordinate value for that axis.
 void split(ISBounds lowerBounds, ISBounds upperBounds, int splitAxis, int splitAxisCoord)
          The two argument bounds are set to represent two portions of this ISBounds split by a plane orthogonal to the splitAxis, at the coordinate value contained in splitAxisCoord.
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return a String representing the object indented by the argument string.
 int volume()
          Return the total volume of the ISBounds as an integer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lower

protected int[] lower

upper

protected int[] upper
Constructor Detail

ISBounds

public ISBounds(IndexSpaceID corner1,
                IndexSpaceID corner2)
This constructor takes two corner points (SpaceIDs) that define a hypercube of arbitrary dimensionality. Notice that the getLower() and getUpper() methods may or may not return the same IndexSpaceID values given in this constructor.


ISBounds

public ISBounds(IndexSpaceID dimensions)
This constructor takes a single IndexSpaceID that defines the dimensions of a hypercube with lower coordinates at the origin. Notice that the upper coordinates will each be one less than the corresponding coordinate in the argument IndexSpaceID. This constructor takes the absolute value of all coordinates in the argument.


ISBounds

public ISBounds(int[] dimensions)
This constructor takes a single integer array that defines the dimensions of a hypercube with lower coordinates at the origin. Notice that the upper coordinates will each be one less than the corresponding coordinate in the argument array. This constructor takes the absolute value of all coordinates in the argument. It is an error for any value in the dimensions array to be less than 1.


ISBounds

public ISBounds(int[] lower,
                int[] upper)
This constructor takes two corner points expressed as int arrays that define a hypercube of arbitrary dimensionality.


ISBounds

public ISBounds(ISBounds bounds)
Construct a copy of the argument bounds. 09/20/07 new implementation that avoids clone();


ISBounds

protected ISBounds(int dimensionality)
This constructor just allocates space for the lower and upper arrays.


ISBounds

public ISBounds(int dim,
                int[] bounds)
This constructor allocates an ISBounds of the dimensionality defined by the first argument. The second argument is an array whose length is 2 times the dimensionality. The first dim entries are the lower bounds, the 2nd dim are the upper.

Method Detail

newBoundsAtOrigin

public static ISBounds newBoundsAtOrigin(IndexSpaceID id)
Deprecated. Use createAtOrigin( isid )

create a new ISBounds with lower bounds at the origin, and upper bounds with the specified IndexSpaceID.


createAtOrigin

public static ISBounds createAtOrigin(IndexSpaceID id)
create a new ISBounds with lower bounds at the origin, and upper bounds with the specified IndexSpaceID.


createAtOrigin

public static ISBounds createAtOrigin(int[] coords)
Create a new ISBounds with lower bounds at the origin, and upper bounds with coordinates corresponding to the integer array argument. This method may elect to use the array argument directly, without making a copy. This implementation assumes that a freshly created array of ints will be initialized to zero.


createCentered

public static ISBounds createCentered(ISBounds shape,
                                      IndexSpaceID center)
Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are the same as the dimensions of the 1st argument.


createCentered

public static ISBounds createCentered(IndexSpaceID shape,
                                      IndexSpaceID center)
Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are the same as the dimensions of the 1st argument.


createCentered

public static ISBounds createCentered(int[] shape,
                                      int[] center)
Create a new ISBounds with its center at the ISID specified by the second argument and whose dimensions are given by the 1st argument.


copyTo

public final ISBounds copyTo(IndexSpaceID lower)
create a new ISBounds from this one with lower bounds at specified IndexSpace position and upper bounds defined by the size of this ISBounds.


copyTo

public final ISBounds copyTo(int[] lowerArray)
create a new ISBounds from this one with lower bounds at specified position and upper bounds defined by the size of this ISBounds.


copyToOrigin

public final ISBounds copyToOrigin()
create a new ISBounds from this one with lower bounds at the origin, and upper bounds defined by the size of this ISBounds.


copy

public final ISBounds copy()
Return a copy of this ISBounds object


clone

public java.lang.Object clone()
Return a copy of this ISBounds object

Specified by:
clone in class Bounds

copy

public final ISBounds copy(ISBounds b)
Deprecated. Use set( ISBounds )

Copy the upper and lower bounds of the argument ISBounds into this object. No new memory is allocated. Dimensionalities should match. "this" is returned for convenience of use.


set

public final ISBounds set(ISBounds b)
Copy the upper and lower bounds of the argument ISBounds into this object. No new memory is allocated. Dimensionalities should match. "this" is returned for convenience of use.


copyAndMoveTo

public final ISBounds copyAndMoveTo(ISBounds b,
                                    int[] destination)
Deprecated. Use setAndMoveTo( ISBounds, int[] )

Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument. No new memory is allocated. Dimensionalities should match. This is an *absolute* move. "this" is returned for convenience of use.


setAndMoveTo

public final ISBounds setAndMoveTo(ISBounds b,
                                   int[] destination)
Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument. No new memory is allocated. Dimensionalities should match. This is an *absolute* move. "this" is returned for convenience of use.


copyAndMove

public final ISBounds copyAndMove(ISBounds b,
                                  int[] distance)
Deprecated. Use setAndMove( ISBounds, int[] )

Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument. No new memory is allocated. Dimensionalities should match. This is a *relative* move. "this" is returned for convenience of use.


copyAndMove

public final ISBounds copyAndMove(int[] distance)
Create a copy of this bounds moved by the relative amount specified by the argument.


copyAndMoveTo

public final ISBounds copyAndMoveTo(int[] loc)
Create a copy of this bounds moved the lower left corner to the specified location.


copyAndMoveCenterTo

public final ISBounds copyAndMoveCenterTo(int[] loc)
Create a copy of this bounds moved the center to the specified location.


copyAndMoveCenterTo

public final ISBounds copyAndMoveCenterTo(IndexSpaceID loc)
Create a copy of this bounds moved the center to the specified location.


setAndMove

public final ISBounds setAndMove(ISBounds b,
                                 int[] distance)
Set the bounds of this object so it is the same shape as the ISBounds argument, but translated to the location represented by the array argument. No new memory is allocated. Dimensionalities should match. This is a *relative* move. "this" is returned for convenience of use.


copyLower

public final ISBounds copyLower(int[] lower)
Deprecated. Use setLower( int [] )

Copy the contents of the argument array into the lower coordinate for this bounds. No new memory is allocated. "this" is returned for convenience of use.


copyUpper

public final ISBounds copyUpper(int[] upper)
Deprecated. Use setUpper( int [] ) "this" is returned for convenience of use.

Copy the contents of the argument array into the upper coordinate for this bounds. No new memory is allocated.


setLower

public final ISBounds setLower(IndexSpaceID lower)
Set the lower bounds to the coordinates represented by the IndexSpaceID argument. "this" is returned for convenience of use.


setUpper

public final ISBounds setUpper(IndexSpaceID upper)
Set the upper bounds to the coordinates represented by the IndexSpaceID argument. "this" is returned for convenience of use.


setLower

public final ISBounds setLower(int[] lower)
Set the lower bounds to the coordinates represented by the integer array argument. "this" is returned for convenience of use.


setUpper

public final ISBounds setUpper(int[] upper)
Set the upper bounds to the coordinates represented by the integer array argument. "this" is returned for convenience of use.


setUpper

public final ISBounds setUpper(int axis,
                               int newValue)
Set the upper bounds of a given axis specified in the argument "this" is returned for convenience of use.


setLower

public final ISBounds setLower(int axis,
                               int newValue)
set the lower bounds of a given axis specified in the argument "this" is returned for convenience of use.


copyLower

public final IntegerIndexSpaceID copyLower()
Return an IndexSpaceID representing the lower bounds.


getLower

public final IntegerIndexSpaceID getLower()
Return an IndexSpaceID representing the lower bounds.


getLower

public final int getLower(int axis)
Return an int representing the lower bound of the specified dimension.


getUpper

public final int getUpper(int axis)
Return an int representing the upper bound of the specified dimension.


copyUpper

public final IntegerIndexSpaceID copyUpper()
Return an IndexSpaceID representing the upper bounds.


getUpper

public final IntegerIndexSpaceID getUpper()
Return an IndexSpaceID representing the upper bounds.


getLowerArray

public final int[] getLowerArray()
Return a reference to the integer array representing the upper bounds.


copyLowerArray

public final int[] copyLowerArray()
Return a reference to the integer array representing the lower bounds.


getLowerArray

public final int[] getLowerArray(int[] arr)
Deprecated. Use copyLowerArray( int [] )

Return a copy of the integer array representing the upper bounds. public final int [] copyLowerArray() { return (int[])this.lower.clone(); } /** Copy the lower bound coordinates into the array argument. A reference to the argument is returned.


copyLowerArray

public final int[] copyLowerArray(int[] arr)
Copy the lower bound coordinates into the array argument. A reference to the argument is returned.


getUpperArray

public final int[] getUpperArray()
Return a reference to the integer array representing the upper bounds. Package access.


copyUpperArray

public final int[] copyUpperArray()
Return a copy of the integer array representing the upper bounds.


getUpperArray

public final int[] getUpperArray(int[] arr)
Deprecated. Use copyUpperArray( int [] )

Copy the upper bound coordinates into the array argument. A reference to the argument is returned.


copyUpperArray

public final int[] copyUpperArray(int[] arr)
Copy the upper bound coordinates into the array argument. A reference to the argument is returned.


dim

public final int dim()
Return dimensionality of Bounds.

Specified by:
dim in class Bounds

equals

public boolean equals(ISBounds b)
Return true if parameter is equal to this object, false otherwise. In this case equality means that all bounds parameters are the same.


equalShape

public boolean equalShape(ISBounds b)
Return true if parameter has the same size in all dimensions as this object, false otherwise. If the dimensionalities do not match, we'll try to see if shapes still match because the higher dimensional bounds has length 1 in all the "extra" dimensions, and the others match.


equalShapeAfterProject

protected boolean equalShapeAfterProject(ISBounds b)
Returns true if the passed bounds has the same shape as this bounds after the higher dimensioned bounds is projected along any dimension that is of length 1. Of course, we have to project the argument along any axis of length 1 as well.

Parameters:
b -
Returns:

volume

public final int volume()
Return the total volume of the ISBounds as an integer. "Volume" is defined to be the total number of elements within the dataspace enclosed by the ISBounds. If the volume does not fit into an int, an exception is thrown.


longVolume

public final long longVolume()
Return the total volume of the ISBounds as a long. "Volume" is defined to be the total number of elements within the dataspace enclosed by the ISBounds.


getDimensions

public final IndexSpaceID getDimensions()
Return an IndexSpaceID with axis values denoting the size of each corresponding dimension of the ISBounds.


increase

public final ISBounds increase(int n)
Deprecated. Use copyIncreasedBy( int )


copyIncreasedBy

public final ISBounds copyIncreasedBy(int n)
Return a new ISBounds that has upper coordinates that are increased by the specified amount from the upper coordinates of this ISBounds. A convenience function.


getDimensionsArray

public final int[] getDimensionsArray()
Return an int array with axis values denoting the size of each corresponding dimension of the ISBounds.


getDimensions

public final int[] getDimensions(int[] dimensions)
Fill the argument array with coordinate values denoting the size of each corresponding dimension of the ISBounds. A reference to the argument array is returned as a convenience. A null argument is legal and results in the allocation of a correct length array. If the argument is not null, it should have a length corresponding to the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will be created.


getDimension

public final int getDimension(int axis)
Return the length of the axis specified as an argument.


project

public ISBounds project(int axis)
Returns a new ISBounds which is the projection of this ISBounds onto a plane orthogonal to the specified axis. The dimensionality of the result will therefore always be one less than the dimensionality of this object, as long as the axis is valid for this ISBounds. If the specified axis is not valid, an error is created.


slice

public ISBounds slice(int axis,
                      int coordinate)
Returns a new ISBounds which is a slice of this ISBounds of thickness 1 in a plane orthogonal to the specified axis, having the given coordinate value for that axis. The dimensionality of the result matches the dimensionality of this ISBounds, as long as the axis is valid for this ISBounds. If the specified axis is not valid, then an error is created.


isSlice

public boolean isSlice(IndexSpaceID dimensionsID,
                       int axis)
Returns true if the argument IndexSpaceId represents the dimensions of a slice of this ISBounds of arbitrary thickness in the specified axis.


split

public void split(ISBounds lowerBounds,
                  ISBounds upperBounds,
                  int splitAxis,
                  int splitAxisCoord)
The two argument bounds are set to represent two portions of this ISBounds split by a plane orthogonal to the splitAxis, at the coordinate value contained in splitAxisCoord. This coordinate value must be equal to or greater than the lower bound of this object in the split axis, and less than the upper bound. Otherwise, an error is created.


getVertex

public int[] getVertex(int vertexNumber,
                       int[] coords)
Fills the second argument with the coordinates of the specified vertex. The vertices are stored in a "bitwise" order. That is, vertex 0 consists of all lower coords. Vertex 1 is similar, except that it uses the upper coordinate for axis 0. In summary, the bits in the vertex number determine whether the lower or upper coordinate will be chosen for the vertex location. If the coords array is null, a new array will be created. A reference to the coords array is returned.


getVertex

public IndexSpaceID getVertex(int vertexNumber,
                              IndexSpaceID id)
Fills the second argument with the coordinates of the specified vertex. The vertices are stored in a "bitwise" order. That is, vertex 0 consists of all lower coords. Vertex 1 is similar, except that it uses the upper coordinate for axis 0. In summary, the bits in the vertex number determine whether the lower or upper coordinate will be chosen for the vertex location. If the IndexSpaceID is null, a new IntegerIndexSpaceID will be created. A reference to the coords array is returned.


hasSameShape

public final boolean hasSameShape(ISBounds b)
Returns true if the argument bounds has the same shape as this ISBounds, and false otherwise. No explicit check of dimensionality is done, and shape checking is only done up to and including the highest dimension of this bounds. However, if the argument bounds is of a lower dimensionality than this ISBounds, a DimensionalityError will be created.


expand

public final ISBounds expand(int n)
Deprecated. Use copyExpandBy( int )


copyExpandBy

public final ISBounds copyExpandBy(int n)
Return a new ISBounds that has upper and lower coordinates that are moved outward by the specified distance. That is, the lower coordinates are decreased, while the upper coordinates are increased. The "center of gravity" is not changed.


reduceByOne

public final ISBounds reduceByOne()
Deprecated. Use copyReducedBy( 1 )

Return a new ISBounds that has upper coordinates that are exactly one less than the upper coordinates of this ISBounds.


reduceByOne

public final void reduceByOne(ISBounds b)
Deprecated. rdb: I find the semantics very confusing. One would expect that the this object would be the one changed, not the argument object. Especially since our other similar methods either change "this" or return a new object (except decreaseByOne(ISB)).

Copies coordinates into the argument ISBounds such that the lower coordinates are unchanged, but the upper coordinates are reduced by one. A convenience function.


reduce

public final ISBounds reduce(int n)
Deprecated. Use copyReducedBy( int )


copyReducedBy

public final ISBounds copyReducedBy(int n)
Return a new ISBounds that has upper coordinates that are reduced by the specified amount from the upper coordinates of this ISBounds. A convenience function.


copyShrinkBy

public final ISBounds copyShrinkBy(int n)
Return a new ISBounds that has upper and lower coordinates that are moved inward by the specified distance. That is, the lower coordinates are increased, while the upper coordinates are reduced. The "center of gravity" is not changed.


increaseByOne

public final ISBounds increaseByOne()
Deprecated. Use copyIncreasedBy( 1 )

Return a new ISBounds that has upper coordinates that are exactly one greater than the upper coordinates of this ISBounds.


increaseByOne

public final void increaseByOne(ISBounds b)
Deprecated. rdb: I find the semantics very confusing. One would expect that the this object would be the one changed, not the argument object. Why do we need this? It is exactly the same as b.increaseByOne(); All other similar methods either change "this" or return a new object (except increaseByOne(ISB)).

Copies coordinates into the argument ISBounds such that the lower coordinates are unchanged, but the upper coordinates are increased by one. A convenience function.


copyScaled

public final ISBounds copyScaled(double[] scales)
Return a new ISBounds with dimensions that have been scaled by the the argument array. The lower bounds are not affected, but each coordinate of the upper bounds is modified to reflect the scaling.


copyScaled

public final ISBounds copyScaled(float[] scales)
Return a new ISBounds with dimensions that have been scaled by the the argument array. The lower bounds are not affected, but each coordinate of the upper bounds is modified to reflect the scaling.


copyScaled

public final ISBounds copyScaled(int[] scales)
Return a new ISBounds with dimensions that have been scaled by the the argument array. The lower bounds are not affected, but each coordinate of the upper bounds is modified to reflect the scaling.


move

public final ISBounds move(IndexSpaceID distance)
Translate the ISBounds object in space by the value of the parameter IndexSpaceID. Each coordinate of the IndexSpaceID is added to the coordinates of the upper and lower bounds of this ISBounds. "this" is returned for convenience of use. This is a *relative* move.


move

public final ISBounds move(int[] distance)
Translate the ISBounds object in space by the coordinates in the integer array argument. Each coordinate is added to the coordinates of the upper and lower bounds of this ISBounds. "this" is returned for convenience of use. This is a *relative* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


move

public final ISBounds move(int axis,
                           int distance)
Translate the ISBounds object in space along the specified axis by the specified distance. The distance argument is added to the coordinates of the upper and lower bounds of this ISBounds. If the specified axis is not less than the dimensionality of this ISBounds, a dimensionality error is created. "this" is returned for convenience of use. This is a *relative* move.


moveTo

public final ISBounds moveTo(IndexSpaceID location)
Translate the ISBounds object in space so that the lower left corner is moved to the location specified by the parameter IndexSpaceID. This is an *absolute* move. The IndexSpaceID should have the same dimensionality as the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created. "this" is returned for convenience of use.


moveTo

public final ISBounds moveTo(int[] location)
Translate the ISBounds object in space so that the lower left corner is moved to the coordinates specified int the integer array argument. This is an *absolute* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will be created. For convenience the object itself is returned as the result of the method.


moveCenterTo

public final ISBounds moveCenterTo(int[] location)
Translate the ISBounds object in space so that the center is moved to the coordinates specified in the integer array argument. This is an *absolute* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will be created. For convenience the object itself is returned as the result of the method.


moveCenterTo

public final ISBounds moveCenterTo(IndexSpaceID location)
Translate the ISBounds object in space so that the center is moved to the coordinates specified in the integer array argument. This is an *absolute* move. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will be created. For convenience the object itself is returned as the result of the method.


moveToOrigin

public ISBounds moveToOrigin()
Translate this ISBounds in space so that the lower point is now at the origin. For convenience, this is returned as the value of the method.


makeRelativeTo

public ISBounds makeRelativeTo(IndexSpaceID localOrigin)
Translate this ISBounds in space so it is expressed in the local coordinate system whose origin is at the IndexSpaceId passed as an argument.


makeRelativeTo

public ISBounds makeRelativeTo(int[] localOrigin)
Translate this ISBounds in space so it is expressed in the local coordinate system whose origin is at the IndexSpaceId passed as an argument.


copyAndMoveToOrigin

public static final ISBounds copyAndMoveToOrigin(ISBounds bounds)
Deprecated. Use bounds.copyToOrigin( )

Returns a new ISBounds of the same shape as the argument bounds, but moved to the origin.


boundingVolume

public final ISBounds boundingVolume(ISBounds db)
Deprecated. Use setToBoundingVolume( ISBounds )

Updates this ISBounds object to be the bounding volume of this ISBounds and the parameter ISBounds. If the dimensionality of the parameter ISBounds does not match the dimensionality of this ISBounds, then a DimensionalityException is thrown. "this" is returned for convenience of use.


setToBoundingVolume

public ISBounds setToBoundingVolume(ISBounds db)
Updates this ISBounds object to be the bounding volume of this ISBounds and the parameter ISBounds. If the dimensionality of the parameter ISBounds does not match the dimensionality of this ISBounds, then a DimensionalityException is thrown. "this" is returned for convenience of use.


intersects

public boolean intersects(ISBounds b2)
If the intersection of this with the argument is non-empty, the method returns true, and false otherwise. This object is unchanged.


intersection

public ISBounds intersection(ISBounds b2)
Returns the intersecton of this object with the ISBounds argument. If the intersection doesn't exist, then return null.


intersectWith

public ISBounds intersectWith(ISBounds b2)
Updates this ISBounds to the intersection of itself with the argument. Returns this as a convenience. Throws an exception if the intersection is null.


contains

public boolean contains(ISBounds b2)
Returns true if this Bounds completely contains the argument bounds.


containsExcludeUpper

public boolean containsExcludeUpper(int[] coords)
Returns true if this Bounds contains the coordinates represented in the integer array. Unlike the usual contains method, If the coordinates lie on an upper edge of the bounds, this method will return false. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


containsExcludeUpper

public boolean containsExcludeUpper(IndexSpaceID id)
Returns true if this Bounds contains the coordinates represented in the IndexSpaceID. Unlike the usual contains method, If the coordinates lie on an upper edge of the bounds, this method will return false. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


contains

public boolean contains(IndexSpaceID id)
Returns true if this Bounds contains the coordinates contained in the integer array. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


contains

public boolean contains(int[] coords)
Returns true if this Bounds contains the coordinates contained in the integer array. The array argument should have a length corresponding to the dimensionality of the bounds object. However, if the argument array is too long, the extra elements will be ignored. If it is too short, a DimensionalityError will will be created.


toString

public java.lang.String toString()
Return a String representing the object.

Specified by:
toString in class Bounds

toString

public java.lang.String toString(java.lang.String indent)
Return a String representing the object indented by the argument string.


main

public static void main(java.lang.String[] args)
For debugging. Runs basic tests on the ISBounds class.