edu.unh.sdb.datasource
Class Slice

java.lang.Object
  extended by edu.unh.sdb.datasource.Slice
Direct Known Subclasses:
SliceIterator

public class Slice
extends java.lang.Object

A class that knows how to read data for the intersection between a Volume over a DataSource and a Plane. The data is read from a DataSource.

Author:
dlipsa

Constructor Summary
Slice(byte[] outsideColor, byte[] insideColor, Volume volume, Plane plane, DataSource dataSource)
          Creates a new instance of Slice and sets its parameters
 
Method Summary
 int[][] getBounds()
           
 int getBytesPerTexel()
           
 DataSource getDataSource()
           
 javax.vecmath.Point2d[] getIntersection2d()
           
 javax.vecmath.Point3d[] getIntersection3d()
           
 int getMaxProjectionAxis()
           
 float[] getNormalArray()
          Required for ObliquePlaneIteratorInterface
 Plane getPlane()
           
 int[] getPlaneShapeArray()
           
 ISBounds getSpaceBounds()
           
 int[] getSpaceShapeArray()
           
 javax.vecmath.Point2d[] getTextureCoordinates()
           
 byte[] getTextureData()
           
 int[] getTextureDimensions()
           
 Volume getVolume()
           
 void init()
          Initialize the slice by allocating memory for the data to be read, seting the default transfer function and performing other initialisations This initialisation can be done once per iteration.
 void log(java.lang.String fileName)
           
static void projectTuple(javax.vecmath.Tuple3d source, javax.vecmath.Tuple2d dest, int axis)
          Project the 'source' on a plane perpendicular on 'axis' and store the result in 'dest'.
 void read()
          Calculates the intersection between the Plane and the Volume and fills the the intersection poligon with data
 void setDataSource(DataSource dataSource)
          Sets the data source where the volume is stored.
static void setGoodScanConversionOrder(boolean good)
           
 void setInsideColor(byte[] color)
          Sets the color for the texture inside the bounds of the slice projection
 void setOutsideColor(byte[] color)
          Sets the color for the texture ouside the bounds of the slice projection
 void setPlane(Plane plane)
          Specifies the plane we want to intersect with the volume
 void setTransferFunction(TransferFunction transferFunction)
          Specifies how do we convert the Datum read from the file into a rgba tupple.
 void setVertical(javax.vecmath.Vector3d vertical)
          Specifies a vector perpendicular on the normal of the intersection plane.
 void setVolume(Volume volume)
          Specifies the volume we iterate over
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Slice

public Slice(byte[] outsideColor,
             byte[] insideColor,
             Volume volume,
             Plane plane,
             DataSource dataSource)
Creates a new instance of Slice and sets its parameters

Method Detail

getBytesPerTexel

public int getBytesPerTexel()
Returns:
How many bytes do we use per texel, when we store the texture. Currently this is 4 (rgba)

setTransferFunction

public void setTransferFunction(TransferFunction transferFunction)
Specifies how do we convert the Datum read from the file into a rgba tupple.


setVolume

public void setVolume(Volume volume)
Specifies the volume we iterate over


getVolume

public Volume getVolume()
Returns:
volume we iterate over

setPlane

public void setPlane(Plane plane)
Specifies the plane we want to intersect with the volume


getPlane

public Plane getPlane()
Returns:
plane we want to intersect with the volume

setDataSource

public void setDataSource(DataSource dataSource)
Sets the data source where the volume is stored.


getDataSource

public DataSource getDataSource()
Returns:
The data source where the volume is stored.

setOutsideColor

public void setOutsideColor(byte[] color)
Sets the color for the texture ouside the bounds of the slice projection


setInsideColor

public void setInsideColor(byte[] color)
Sets the color for the texture inside the bounds of the slice projection


setGoodScanConversionOrder

public static void setGoodScanConversionOrder(boolean good)

getTextureData

public byte[] getTextureData()
Returns:
a byte array containing the texture.

getTextureDimensions

public int[] getTextureDimensions()
Returns:
the x,y dimensions of the texture. These are a power of 2.

getBounds

public int[][] getBounds()
Returns:
bounds[0] contains the lower and upper bounds for the x coordinate bounds[1] contains the same for the y coordinate. These coordinates delimit the rectangle that includes the intersection poligon projected to maximum projection orthogonal plane.

getIntersection3d

public javax.vecmath.Point3d[] getIntersection3d()
Returns:
the 3d points that form the intersection polygon.

getIntersection2d

public javax.vecmath.Point2d[] getIntersection2d()
Returns:
the 2d points that form the intersection polygon seen from a direction normal to the plane of the polygon.

getMaxProjectionAxis

public int getMaxProjectionAxis()
Returns:
the axis perpendicular on the plane for which the slice has the maximum projection area

getTextureCoordinates

public javax.vecmath.Point2d[] getTextureCoordinates()
Returns:
the 2d points that form the intersection polygon, translated and scaled such that they are between [0,1].

init

public void init()
Initialize the slice by allocating memory for the data to be read, seting the default transfer function and performing other initialisations This initialisation can be done once per iteration. In an iteration the slice will slide along its normal until the entire volume will be traversed.


read

public void read()
Calculates the intersection between the Plane and the Volume and fills the the intersection poligon with data


setVertical

public void setVertical(javax.vecmath.Vector3d vertical)
Specifies a vector perpendicular on the normal of the intersection plane. The intersection poligon is displayed rotated such that this vector is vertical.


getSpaceBounds

public ISBounds getSpaceBounds()

getSpaceShapeArray

public int[] getSpaceShapeArray()

getNormalArray

public float[] getNormalArray()
Required for ObliquePlaneIteratorInterface


getPlaneShapeArray

public int[] getPlaneShapeArray()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

projectTuple

public static void projectTuple(javax.vecmath.Tuple3d source,
                                javax.vecmath.Tuple2d dest,
                                int axis)
Project the 'source' on a plane perpendicular on 'axis' and store the result in 'dest'.


log

public void log(java.lang.String fileName)