OpenWalnut  1.4.0
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Friends
WTransferFunction Class Reference

A class that stores a 1D transfer function which consists of a linear interpolation of alpha and color values. More...

#include <WTransferFunction.h>

List of all members.

Classes

struct  AlphaEntry
 Alpha entries represent linearly interpolated transparency values along the isovalue scale. More...
struct  ColorEntry
 Color entries are linearly interpolated colors along isovalues. More...
struct  Entry
 Prototype for a storage element. More...
struct  LessPred
 Templatized comparison predicate for internal searching. More...

Public Member Functions

 WTransferFunction ()
 Default constructor of a meaningless transfer function.
 WTransferFunction (const WTransferFunction &rhs)
 Deep copy constructor.
WTransferFunctionoperator= (const WTransferFunction &rhs)
 Deep copy operator.
bool operator== (const WTransferFunction &rhs) const
 Check equivalence of two transfer functions.
bool operator!= (const WTransferFunction &rhs) const
 Check equivalence of two transfer functions.
 ~WTransferFunction ()
 Default destuctor.
size_t numAlphas () const
 Get the number of alphas.
size_t numColors () const
 Get the number of colors.
double getAlphaIsovalue (size_t i) const
 Get the isovalue at a given index in the alpha values.
double getColorIsovalue (size_t i) const
 The isovalue of the color at a given index.
double getAlpha (size_t i) const
 Get alpha at given index.
const WColor & getColor (size_t i) const
 Get color at given index.
void addColor (double iso, const WColor &color)
 Insert a new color point.
void addAlpha (double iso, double alpha)
 Insert a new alpha point.
void setHistogram (std::vector< double > &data)
 Set the histogram going along with the transfer function.
void removeHistogram ()
 Clears the histogram data so the gui won't show any.
const std::vector< double > & getHistogram () const
 Returns the histogram.
void sample1DTransferFunction (unsigned char *array, int width, double min, double max) const
 sample/render the transfer function linearly between min and max in an RGBA texture.

Static Public Member Functions

static WTransferFunction createFromRGBA (unsigned char const *const rgba, size_t size)
 Try to estimate a transfer function from an RGBA image.

Private Attributes

std::vector< ColorEntrym_colors
 Sorted list of colors.
std::vector< AlphaEntrym_alphas
 Sorted list of alpha values.
double m_isomin
 The smallest used iso value.
double m_isomax
 The largest used iso value.
std::vector< double > m_histogram
 Sores a histogram.

Friends

std::ostream & operator<< (std::ostream &out, const WTransferFunction &tf)
 Default output operator.

Detailed Description

A class that stores a 1D transfer function which consists of a linear interpolation of alpha and color values.

Definition at line 37 of file WTransferFunction.h.


Constructor & Destructor Documentation

Default constructor of a meaningless transfer function.

Definition at line 43 of file WTransferFunction.h.

Deep copy constructor.

Parameters:
rhsthe value to histogram

Definition at line 52 of file WTransferFunction.h.

Default destuctor.

Definition at line 94 of file WTransferFunction.h.


Member Function Documentation

void WTransferFunction::addAlpha ( double  iso,
double  alpha 
)

Insert a new alpha point.

Parameters:
isothe new iso value
alphathe new alpha value at the given iso value

Definition at line 210 of file WTransferFunction.cpp.

References m_alphas, m_colors, m_isomax, and m_isomin.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::create(), and createFromRGBA().

void WTransferFunction::addColor ( double  iso,
const WColor &  color 
)

Insert a new color point.

Parameters:
isothe new iso value
colorthe new color at the given iso value

Definition at line 186 of file WTransferFunction.cpp.

References m_alphas, m_colors, m_isomax, and m_isomin.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::create(), and createFromRGBA().

WTransferFunction WTransferFunction::createFromRGBA ( unsigned char const *const  rgba,
size_t  size 
) [static]

Try to estimate a transfer function from an RGBA image.

Parameters:
rgba,:values between 0 and 255 representing the red, green, and blue channel
size,:number of color entries in rgba
Returns:
approximated transfer function

the threshold here is larger than for alpha, becuase we compare all colors at once

Definition at line 234 of file WTransferFunction.cpp.

References addAlpha(), and addColor().

double WTransferFunction::getAlpha ( size_t  i) const [inline]

Get alpha at given index.

Parameters:
ithe index to query
Returns:
the alpha value at index i

Definition at line 146 of file WTransferFunction.h.

References m_alphas.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

double WTransferFunction::getAlphaIsovalue ( size_t  i) const [inline]

Get the isovalue at a given index in the alpha values.

Parameters:
ithe index of the point to query
Returns:
the alpha values position/isovalue at index i

Definition at line 124 of file WTransferFunction.h.

References m_alphas.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

const WColor& WTransferFunction::getColor ( size_t  i) const [inline]

Get color at given index.

Parameters:
ithe index to query
Returns:
the color at index i

Definition at line 157 of file WTransferFunction.h.

References m_colors.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

double WTransferFunction::getColorIsovalue ( size_t  i) const [inline]

The isovalue of the color at a given index.

Parameters:
ithe index of the point to query.
Returns:
the color values position/isovalue at index i

Definition at line 135 of file WTransferFunction.h.

References m_colors.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

const std::vector< double >& WTransferFunction::getHistogram ( ) const [inline]

Returns the histogram.

Returns:
a reference to the internal representation of the histogram

Definition at line 205 of file WTransferFunction.h.

References m_histogram.

Get the number of alphas.

Returns:
the number of alpha points

Definition at line 103 of file WTransferFunction.h.

References m_alphas.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

Get the number of colors.

Returns:
the number of color points

Definition at line 113 of file WTransferFunction.h.

References m_colors.

Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString().

bool WTransferFunction::operator!= ( const WTransferFunction rhs) const

Check equivalence of two transfer functions.

Returns:
negated result of operator==
Parameters:
rhsthe value to compare with

Definition at line 91 of file WTransferFunction.cpp.

WTransferFunction& WTransferFunction::operator= ( const WTransferFunction rhs) [inline]

Deep copy operator.

Parameters:
rhsthe value to copy
Returns:
reference to current object
reference to current object

Definition at line 64 of file WTransferFunction.h.

References m_alphas, m_colors, m_histogram, m_isomax, and m_isomin.

bool WTransferFunction::operator== ( const WTransferFunction rhs) const

Check equivalence of two transfer functions.

Returns:
true if this object contains exactly the same data as rhs
Parameters:
rhsobject to compare with

Definition at line 33 of file WTransferFunction.cpp.

References m_alphas, m_colors, m_histogram, m_isomax, and m_isomin.

Clears the histogram data so the gui won't show any.

Definition at line 195 of file WTransferFunction.h.

References m_histogram.

void WTransferFunction::sample1DTransferFunction ( unsigned char *  array,
int  width,
double  min,
double  max 
) const

sample/render the transfer function linearly between min and max in an RGBA texture.

Parameters:
arraypointer to an allocated data structure
widthis the number of RGBA samples.
minthe lowest value to be sampled
maxthe hightes value to be sampled
Postcondition:
array contains the sampled data
Precondition:
array is allocated and has space for width elements

Definition at line 115 of file WTransferFunction.cpp.

References m_alphas, m_colors, m_isomax, and m_isomin.

void WTransferFunction::setHistogram ( std::vector< double > &  data) [inline]

Set the histogram going along with the transfer function.

This should be changed in the future to be handled in a different way. A good option would be to introduce an object encapsulating a transfer function and histogram information.

Parameters:
datathe histogram data between m_isomin and m_isomax

Definition at line 187 of file WTransferFunction.h.

References m_histogram.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const WTransferFunction tf 
) [friend]

Default output operator.

Currently stores values the same way as it is done in the properties. This code should only be used for debugging and you should not rely on the interface.

Parameters:
tfThe transfer function to output
outThe stream to which we write
Returns:
reference to out

Definition at line 354 of file WTransferFunction.cpp.


Member Data Documentation

std::vector<AlphaEntry> WTransferFunction::m_alphas [private]

Sorted list of alpha values.

Definition at line 348 of file WTransferFunction.h.

Referenced by addAlpha(), addColor(), getAlpha(), getAlphaIsovalue(), numAlphas(), operator=(), operator==(), and sample1DTransferFunction().

std::vector<ColorEntry> WTransferFunction::m_colors [private]

Sorted list of colors.

Definition at line 343 of file WTransferFunction.h.

Referenced by addAlpha(), addColor(), getColor(), getColorIsovalue(), numColors(), operator=(), operator==(), and sample1DTransferFunction().

std::vector< double > WTransferFunction::m_histogram [private]

Sores a histogram.

This is used for property-handling only and does not change the transfer function at all.

Definition at line 364 of file WTransferFunction.h.

Referenced by getHistogram(), operator=(), operator==(), removeHistogram(), and setHistogram().

double WTransferFunction::m_isomax [private]

The largest used iso value.

Definition at line 358 of file WTransferFunction.h.

Referenced by addAlpha(), addColor(), operator=(), operator==(), and sample1DTransferFunction().

double WTransferFunction::m_isomin [private]

The smallest used iso value.

Definition at line 353 of file WTransferFunction.h.

Referenced by addAlpha(), addColor(), operator=(), operator==(), and sample1DTransferFunction().


The documentation for this class was generated from the following files: