Dataset Class Reference
[Graphics]

Loads and holds volumetric data. More...

#include <Dataset.hpp>

List of all members.

Public Member Functions

 Dataset (string filename)
virtual ~Dataset ()
unsigned char getAsByte (const Index &I) const
float getAsFloat (const Index &I) const
short getAsShort (const Index &I) const
unsigned short getAsUnsignedShort (const Index &I) const
int getBlock () const
void * getData ()
int getDepth () const
string getFilename () const
GLint getFootprint () const
DatasetHeader getHeader () const
int getLength () const
int getHeight () const
int getHigh () const
int getLow () const
int getMax () const
int getMin () const
int getMaximumDimension () const
GLenum getType () const
int getWidth () const
char * findPointerTo (const Index &I) const
void load (bool raw=false)
void normalize ()
void print () const
void print (Index I)
void set (const Index &I, const void *value, GLenum type)
void write (const string &filename, int every=1)

Protected Member Functions

void checkIndex (const Index &I) const
void get (const Index &I, void *&value) const
void initDimensions ()
void initTypeBlock ()
void normalizeAsUnsignedShort ()
void readData ()

Private Attributes

DatasetHeader header
GLenum type
int block
int length
int width
int height
int depth
int widthTimesHeight
void * data

Detailed Description

Loads and holds volumetric data.

In most cases, the user is only concerned with getting values from the data.

To get one value, use one of the getAs methods. However, you should use getType() to determine which one to call first since they will throw an exception if it doesn't match the dataset's type. We suggest using a switch statement for this purpose.

Of course, some purposes will need an actual pointer to all of the data, such as using the dataset as an OpenGL texture. In that case, use getData() and getType().


Constructor & Destructor Documentation

Dataset ( string  filename  ) 

Creates a new Dataset from a file.

Parameters:
[in] filename Path to the file containing the data.
~Dataset (  )  [virtual]

Deallocates the data.


Member Function Documentation

void checkIndex ( const Index index  )  const [protected]

Makes sure that an index is in bounds.

Parameters:
[in] index Integer coordinates specifying the location in dataset.
Exceptions:
Exception if index is out of bounds
char * findPointerTo ( const Index I  )  const

Finds a position in the array.

Parameters:
[in] I Integer coordinates specifying the location in dataset.
void get ( const Index index,
void *&  value 
) const [protected]

Gets the value of an element in the data.

To dereference the pointer properly, use getType().

Parameters:
[in] index Integer coordinates specifying the location in dataset.
[out] value Pointer to the value that will be set.
Note:
We don't make this method public because it has the potential to change the data. (Even though it is declared const.)
unsigned char getAsByte ( const Index I  )  const

Gets the value of an element in the data.

Parameters:
[in] I Integer coordinates specifying the location in dataset.
Exceptions:
Exception if the dataset's type is not GL_UNSIGNED_BYTE.
Returns:
Copy of the value as an unsigned byte.
Note:
Remember if you want to print the value, cast it to an int first.
float getAsFloat ( const Index I  )  const

Gets the value of an element in the data.

Parameters:
[in] I Integer coordinates specifying the location in dataset.
Exceptions:
Exception if the dataset's type is not GL_FLOAT.
Returns:
Copy of the value as a float.
short getAsShort ( const Index I  )  const

Gets the value of an element in the data.

Parameters:
[in] I Integer coordinates specifying the location in dataset.
Exceptions:
Exception if the dataset's type is not GL_SHORT.
Returns:
Copy of the value as a short.
unsigned short getAsUnsignedShort ( const Index I  )  const

Gets the value of an element in the data.

Parameters:
[in] I Integer coordinates specifying the location in dataset.
Exceptions:
Exception if the dataset's type is not GL_SHORT.
Returns:
Copy of the value as a short.
int getBlock (  )  const [inline]
Returns:
Number of bytes in one sample.
void * getData (  )  [inline]
Returns:
Pointer to the start of all the data.
int getDepth (  )  const [inline]
Returns:
Number of samples in the Z direction.
string getFilename (  )  const [inline]
Returns:
Path to the file the dataset was loaded from.
GLint getFootprint (  )  const [inline]
Returns:
Size in memory of the data.
DatasetHeader getHeader (  )  const [inline]
Returns:
Header as read from the file.
int getHeight (  )  const [inline]
Returns:
Number of samples in the Y direction.
int getHigh (  )  const [inline]
Returns:
Highest value according to the header.
int getLength (  )  const [inline]
Returns:
Number of total samples in the dataset.
int getLow (  )  const [inline]
Returns:
Lowest value according to the header.
int getMax (  )  const [inline]
Returns:
Maximum possible value according to the header.
int getMaximumDimension (  )  const
Returns:
the maximum of width, height, and depth.
See also:
getWidth()
getHeight()
getDepth()
int getMin (  )  const [inline]
Returns:
Minimum possible value according to the header.
GLenum getType (  )  const [inline]

Currently, the return value will be one of

  • GL_UNSIGNED_BYTE,
  • GL_SHORT, or
  • GL_UNSIGNED_SHORT, or
  • GL_FLOAT,

which can then be used in a switch statement.

Returns:
Enumeration representing the type of the data.
int getWidth (  )  const [inline]
Returns:
Number of samples in the X direction.
void initDimensions (  )  [protected]

Initializes the dimensions of the dataset from its header.

See also:
getWidth()
getHeight()
getDepth()
void initTypeBlock (  )  [protected]

Initializes the Dataset's type and block based on the header.

See also:
getType()
getBlock()
void print ( Index  index  ) 

Prints a value in the dataset.

Parameters:
[in] index Integer coordinates specifying the location in dataset.
void print (  )  const [inline]

Prints the header of the dataset.

void readData (  )  [protected]

Reads the data from the file into the data array.

void set ( const Index index,
const void *  value,
GLenum  type 
)

Sets a sample in the dataset.

Parameters:
[in] index Index specifying the location of the sample.
[in] value Pointer to the value that the sample will be set to.
[in] type Type of the value to set.
Exceptions:
const_char* if the type passed does not match.
See also:
getType()

The documentation for this class was generated from the following files:
Generated on Wed Jun 9 01:36:35 2010 for Gander by  doxygen 1.6.3