RayCaster Class Reference

A ray caster renders an image by casting rays through the data. More...

#include <RayCaster.h>

Inheritance diagram for RayCaster:

Inheritance graph
[legend]
Collaboration diagram for RayCaster:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RayCaster (Data &aData, Gradient &aGradient, Size s=Size(1, 1), Color bgColor=Color(0, 0, 0, 255), RenderMode renderMode=RM_FrontToBack, InterpolationMode interpolationMode=IM_NearestNeighbour)
 ~RayCaster ()
void setViewerPosition (const Vector<> &A, const Vector<> &B, const Vector<> &C)
void setImageSize (const Size &s)
virtual Color getPixelColor (unsigned int x, unsigned int y)
 Gets the color of a specified screen pixel.
virtual Size getImageSize () const
 Gets the intrinsic size of the image per the current settings.
virtual void render (unsigned char *buffer)
 Render the image into a provided buffer, in RGBA (native-endian) format.
void setRenderMode (RenderMode newRenderMode)
RenderMode getRenderMode () const
void setInterpolationMode (InterpolationMode newInterpolationMode)
InterpolationMode getInterpolationMode () const
void setBGColor (Color newBGColor)
Color getBGColor () const
void setSampleRate (float newRate)
float getSampleRate () const
void enableLighting ()
void disableLighting ()
bool isLightingEnabled () const
Lighting * lighting ()

Protected Member Functions

Color applyTransferFunctions (unsigned short aDataValue, const Vector<> &gradient) const

Private Member Functions

void calcVectors ()
std::auto_ptr< Vector<> > intersectRayWithNearestPlane (const Vector<> &startPos, const Vector<> &direction) const
 Calculates the position where our viewing ray leaves the box of mData (if any).
std::auto_ptr< Vector<> > intersectRayWithFarthestPlane (const Vector<> &startPos, const Vector<> &direction) const
unsigned short getDataAt (float x, float y, float z) const
 Gets the data at the specified float position.
unsigned short getDataTrilinearInterpolated (float x, float y, float z)
Vector getGradientAt (float x, float y, float z) const
Vector getGradientTrilinearInterpolated (float x, float y, float z)
Color getPixelColor_FrontToBack (unsigned int x, unsigned int y)
Color getPixelColor_BackToFront (unsigned int x, unsigned int y)
void render_FrontToBack (unsigned char *buffer)
void render_BackToFront (unsigned char *buffer)
void compositeBackToFront (Color &dest, const Color &src)
 Composites one color onto another.
void compositeFrontToBack (Color &dest, const Color &src)

Private Attributes

Data & mData
Gradient & mGradient
Size mImageSize
Vector mTopLeft
Vector mTopRight
Vector mLowerRight
Vector mViewingDirection
Vector mRightVec
Vector mDownVec
Lighting mLighting
Color mBGColor
RenderMode mRenderMode
InterpolationMode mInterpolationMode
float mSampleRate
bool mEnableLighting
const Vector mMaxDataVector
const Plane mFrontPlane
const Plane mBackPlane
const Plane mTopPlane
const Plane mBottomPlane
const Plane mLeftPlane
const Plane mRightPlane

Detailed Description

A ray caster renders an image by casting rays through the data.

It is constructed using a reference to a data class, which has to outlive the renderer.

The viewing rectangle is specified using three points (A, B, C, as indicated in the ASCII art below). The viewing vector is calculated automatically as the cross product of two vectors of the sides of the rect.

   A------------------------------B
   | .                       *    |
   |      .             *         |
   |            .  *              |
   |           * M   .            |
   |      *               .       |
   | *                         .  |
   D------------------------------C
   


Constructor & Destructor Documentation

RayCaster::RayCaster (  Data &  aData,
Gradient &  aGradient,
Size  s = Size(1, 1),
Color  bgColor = Color(0, 0, 0, 255),
RenderMode  renderMode = RM_FrontToBack,
InterpolationMode  interpolationMode = IM_NearestNeighbour
) 
 

RayCaster::~RayCaster (   ) 
 


Member Function Documentation

Color RayCaster::applyTransferFunctions (  unsigned short  aDataValue,
const Vector<> &  gradient
)  const [protected]
 

void RayCaster::calcVectors (   )  [private]
 

void RayCaster::compositeBackToFront (  Color &  dest,
const Color &  src
)  [inline, private]
 

Composites one color onto another.

void RayCaster::compositeFrontToBack (  Color &  dest,
const Color &  src
)  [inline, private]
 

void RayCaster::disableLighting (   ) 
 

void RayCaster::enableLighting (   ) 
 

Color RayCaster::getBGColor (   )  const
 

unsigned short RayCaster::getDataAt (  float  x,
float  y,
float  z
)  const [inline, private]
 

Gets the data at the specified float position.

unsigned short RayCaster::getDataTrilinearInterpolated (  float  x,
float  y,
float  z
)  [inline, private]
 

Vector RayCaster::getGradientAt (  float  x,
float  y,
float  z
)  const [inline, private]
 

Vector RayCaster::getGradientTrilinearInterpolated (  float  x,
float  y,
float  z
)  [inline, private]
 

Size RayCaster::getImageSize (   )  const [virtual]
 

Gets the intrinsic size of the image per the current settings.

Implements ARender.

InterpolationMode RayCaster::getInterpolationMode (   )  const
 

Color RayCaster::getPixelColor (  unsigned int  x,
unsigned int  y
)  [virtual]
 

Gets the color of a specified screen pixel.

Implements ARender.

Color RayCaster::getPixelColor_BackToFront (  unsigned int  x,
unsigned int  y
)  [private]
 

Color RayCaster::getPixelColor_FrontToBack (  unsigned int  x,
unsigned int  y
)  [private]
 

RenderMode RayCaster::getRenderMode (   )  const
 

float RayCaster::getSampleRate (   )  const
 

std::auto_ptr< Vector<> > RayCaster::intersectRayWithFarthestPlane (  const Vector<> &  startPos,
const Vector<> &  direction
)  const [private]
 

std::auto_ptr< Vector<> > RayCaster::intersectRayWithNearestPlane (  const Vector<> &  startPos,
const Vector<> &  direction
)  const [private]
 

Calculates the position where our viewing ray leaves the box of mData (if any).

bool RayCaster::isLightingEnabled (   )  const
 

Lighting * RayCaster::lighting (   ) 
 

void RayCaster::render (  unsigned char *  buffer  )  [virtual]
 

Render the image into a provided buffer, in RGBA (native-endian) format.

Buffer must be of size getImageSize.width() * getImageSize.height() * 4.

Implements ARender.

void RayCaster::render_BackToFront (  unsigned char *  buffer  )  [private]
 

void RayCaster::render_FrontToBack (  unsigned char *  buffer  )  [private]
 

void RayCaster::setBGColor (  Color  newBGColor  ) 
 

void RayCaster::setImageSize (  const Size &  s  ) 
 

void RayCaster::setInterpolationMode (  InterpolationMode  newInterpolationMode  ) 
 

void RayCaster::setRenderMode (  RenderMode  newRenderMode  ) 
 

void RayCaster::setSampleRate (  float  newRate  ) 
 

void RayCaster::setViewerPosition (  const Vector<> &  A,
const Vector<> &  B,
const Vector<> &  C
) 
 


Member Data Documentation

const Plane RayCaster::mBackPlane [private]
 

Color RayCaster::mBGColor [private]
 

const Plane RayCaster::mBottomPlane [private]
 

Data& RayCaster::mData [private]
 

Vector RayCaster::mDownVec [private]
 

bool RayCaster::mEnableLighting [private]
 

const Plane RayCaster::mFrontPlane [private]
 

Gradient& RayCaster::mGradient [private]
 

Size RayCaster::mImageSize [private]
 

InterpolationMode RayCaster::mInterpolationMode [private]
 

const Plane RayCaster::mLeftPlane [private]
 

Lighting RayCaster::mLighting [private]
 

Vector RayCaster::mLowerRight [private]
 

const Vector RayCaster::mMaxDataVector [private]
 

RenderMode RayCaster::mRenderMode [private]
 

const Plane RayCaster::mRightPlane [private]
 

Vector RayCaster::mRightVec [private]
 

float RayCaster::mSampleRate [private]
 

Vector RayCaster::mTopLeft [private]
 

const Plane RayCaster::mTopPlane [private]
 

Vector RayCaster::mTopRight [private]
 

Vector RayCaster::mViewingDirection [private]
 


The documentation for this class was generated from the following files:
Generated on Mon Dec 19 00:13:45 2005 for Visualization by  doxygen 1.4.5