Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SPalette Class Reference

The spectral palette organizes light sources and reflectances. More...

#include <SPalette.h>

Collaboration diagram for SPalette:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SPalette ()
 constructor
 ~SPalette ()
 destructor
bool load (const char *filename)
 loads a palette definition
bool save (const char *filename)
 saves a palette definition
bool loadSpectrum (int rid, int lid, const char *filename)
 loads a single spectrum
bool saveSpectrum (int rid, int lid, const char *filename)
 saves a single spectrum
void reset ()
 clears all entries for lights and reflectances
bool createSpectrum ()
 Creates a spectrum from the given design criteria.
void setSmoothnessWeight (float weight)
 Sets m_WSmoothness.
void setErrorMinWeight (float weight)
 Sets m_WErrorMin.
void useV7 (bool useit=true)
 When finding a colour for a given spectrum you can make it correct in the V31 or in the V7 space.
void matchDesignColours ()
 sets the initial values of the design colours to the actual colours
dword getNLights () const
 returns number of lights.
int addLight (const vuColour31a &light)
 Add a light spectrum to the palette.
void removeLight (word index)
 Remove a light spectrum from the palette.
dword getNRefls () const
 returns number of lights.
int addReflectance (const vuColour31a &refl)
 Add a reflectance spectrum.
void removeReflectance (word index)
 Remove a reflectance spectrum from the palette.
vuColour31agetSpec (int rid, int lid)
 returns handle to a spectrum
booluseSpecBounds (int rid, int lid)
 use bounds? returns handle for bool
vuColour31agetSpecUB (int rid, int lid)
 handle to upper bound of spectrum
vuColour31agetSpecLB (int rid, int lid)
 handle to lower bound of spectrum
void setSpecName (int rid, int lid, const char *name)
 set name for spectrum
const char * getSpecName (int rid, int lid)
 get name of spectrum
boolgetSpecDesignState (int rid, int lid)
 tell whether the spectrum should be designed (returns bool handle)
vuColourRGBa getRLColour (dword rid, dword lid, bool useV7=false)
 compute the actual colour for a certain light-reflectance incidence
void setDesignRGBW (dword rid, dword lid, const vuColourRGBa &col)
 Sets the desired colour for a reflectance-light combination.
vuColourRGBagetDesignRGBW (dword rid, dword lid)
 returns handle to the currently set 'design colour'
boolgetDesignState (dword rid, dword lid)
 This flag indicates whether the entry should be used as a design criterium.
void attachFreeColour (dword rid, dword lid, int fcid)
 Attaches a 'free colour' slot to a light-reflectance combination.
void detachFreeColour (dword rid, dword lid)
 Removes an attached 'free colour' from a design node.
int getFreeColourID (int rid, int lid)
 returns ID of free colour attached to a design colour
dword getNFreeColour ()
 Returns number of slots for 'free colours' .
void setFreeColour (dword fcid, const vuColourRGBa &lb=vuColourRGBa(0.0f), const vuColourRGBa &ub=vuColourRGBa(1.0f))
 creates a 'free colour' slot, if it doen't already exist, lb and ub can be used to make a lower and upper bound
vuColourRGBagetFreeColUB (dword fcid)
 get handle to upper bound of free colour
vuColourRGBagetFreeColLB (dword fcid)
 get handle to lower bound of free colour
boolgetFreeColBoundState (dword fcid)
 should the bounds be used? (handle to flag)

Private Member Functions

SSpectrumgetSpecRec (int rid, int lid)
 returns handle to a spectral class
bool checkSetup ()
 marks 'free colour'-slots that are actually used and checks design colour mask for inconsistencies.
SMatrix makeErrorMat (const vuColour31a &diag)
 Returns weighted error minimizing matrix for the given spectrum.
SMatrix makeSmoothingMat ()
 Returns weighted smoothing matrix (31x31).
SMatrix makeCXFMat (const vuColour31a &diag)
 Returns a V31tRGB matrix accumulated with the diagonal matrix of the given Spectrum.
SMatrix makeCXFMat (const vuColour31a &diag, bool useV7)
 Returns a V31tRGB matrix accumulated with the diagonal matrix of the given Spectrum.

Private Attributes

vuDVector< SSpectrumm_Lights
 A growable array (vuDVector) of lights.
vuDVector< SSpectrumm_Refls
 A growable array (vuDVector) of reflectances.
vuDVector< vuDVector< SDesignColour > > m_DesCol
 A 2D field of RGB values holding the desired values for each light*reflectance combination.
vuDVector< SFreeColourm_FreeCol
 slots for 'free' colours.
bool m_UseV7
 perform optimization using V7 colour Xform?
float m_WSmoothness
 Weight for smoothness as a design criterion.
bool m_UseSmoothness
 switch for whether to use smoothness or not
float m_WErrorMin
 Weight for the error minimizing matrix.
bool m_UseErrorMin
 switch for using the error minimizing matrix
SOptimizer m_Optimizer
 The optimizer used for fitting spectra into the given criteria.
SMatrix m_C31t7
 for conversion from V31 to V7
dword m_NDesCol
 number of design colours used
dword m_NDesSpec
 number of spectra used for design
SMatrix m_CXF31toRGB
 colour conversion matrix.
SMatrix m_CXF7toRGB
 colour conversion matrix.
SMatrix m_CXF31to7
 colour conversion matrix.

Detailed Description

The spectral palette organizes light sources and reflectances.

This is a framework for designing spectra for lights and reflectances. The SOptimizer is used to find spectra fulfilling certain design criteria.

Definition at line 28 of file SPalette.h.


Constructor & Destructor Documentation

SPalette::SPalette  ) 
 

constructor

SPalette::~SPalette  ) 
 

destructor


Member Function Documentation

int SPalette::addLight const vuColour31a light  ) 
 

Add a light spectrum to the palette.

Returns:
index in the list

Referenced by vuSpecPalette::OnAddLight(), vuSpecPalette::OnLoadPal(), and vuTFDesignSpec::updatePalette().

int SPalette::addReflectance const vuColour31a refl  ) 
 

Add a reflectance spectrum.

Returns:
index in the list

Referenced by vuSpecPalette::OnAddReflectance(), vuSpecPalette::OnLoadPal(), and vuTFDesignSpec::updatePalette().

void SPalette::attachFreeColour dword  rid,
dword  lid,
int  fcid
 

Attaches a 'free colour' slot to a light-reflectance combination.

The fcid is the index of the 'free colour'. If set to -1 the only the design colour will be used during optimization.

Referenced by vuSpecPalette::OnDCFC().

bool SPalette::checkSetup  )  [private]
 

marks 'free colour'-slots that are actually used and checks design colour mask for inconsistencies.

bool SPalette::createSpectrum  ) 
 

Creates a spectrum from the given design criteria.

This function builds a matrix and solves for a (positivity constrained) least squares solution using SOptimizer.

Referenced by vuSpecPalette::OnCreateSpectrum().

void SPalette::detachFreeColour dword  rid,
dword  lid
[inline]
 

Removes an attached 'free colour' from a design node.

Definition at line 263 of file SPalette.h.

vuColourRGBa& SPalette::getDesignRGBW dword  rid,
dword  lid
 

returns handle to the currently set 'design colour'

Referenced by vuSpecPalette::OnGetAllDCColours(), vuSpecPalette::OnGetDCColour(), and vuSpecPalette::PaintColours().

bool& SPalette::getDesignState dword  rid,
dword  lid
[inline]
 

This flag indicates whether the entry should be used as a design criterium.

Definition at line 254 of file SPalette.h.

Referenced by vuSpecPalette::OnCBDCDesign(), vuSpecPalette::OnColourClick(), and vuSpecPalette::PaintColours().

bool& SPalette::getFreeColBoundState dword  fcid  )  [inline]
 

should the bounds be used? (handle to flag)

Definition at line 285 of file SPalette.h.

Referenced by vuSpecPalette::OnCBFCUseB(), and vuSpecPalette::OnDCFC().

vuColourRGBa& SPalette::getFreeColLB dword  fcid  )  [inline]
 

get handle to lower bound of free colour

Definition at line 282 of file SPalette.h.

int SPalette::getFreeColourID int  rid,
int  lid
[inline]
 

returns ID of free colour attached to a design colour

Definition at line 266 of file SPalette.h.

Referenced by vuSpecPalette::OnCBFCUseB(), and vuSpecPalette::OnColourClick().

vuColourRGBa& SPalette::getFreeColUB dword  fcid  )  [inline]
 

get handle to upper bound of free colour

Definition at line 279 of file SPalette.h.

dword SPalette::getNFreeColour  )  [inline]
 

Returns number of slots for 'free colours' .

Definition at line 272 of file SPalette.h.

References dword.

dword SPalette::getNLights  )  const [inline]
 

returns number of lights.

Definition at line 188 of file SPalette.h.

References dword.

Referenced by vuSpecPalette::getNLights(), vuTFDesignSpec::updateFromPalette(), and vuTFDesignSpec::updatePalette().

dword SPalette::getNRefls  )  const [inline]
 

returns number of lights.

Definition at line 198 of file SPalette.h.

References dword.

Referenced by vuSpecPalette::getNRefls(), vuTFDesignSpec::updateFromPalette(), and vuTFDesignSpec::updatePalette().

vuColourRGBa SPalette::getRLColour dword  rid,
dword  lid,
bool  useV7 = false
 

compute the actual colour for a certain light-reflectance incidence

Referenced by vuSpecPalette::OnGetAllDCColours(), vuSpecPalette::OnGetDCColour(), and vuSpecPalette::PaintColours().

vuColour31a& SPalette::getSpec int  rid,
int  lid
[inline]
 

returns handle to a spectrum

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 211 of file SPalette.h.

Referenced by vuSpecPalette::OnColourClick(), vuSpecPalette::OnCreatePlanckian(), vuSpecPalette::OnDivideScalar(), vuSpecPalette::OnMultiplyScalar(), vuSpecPalette::PaintColours(), vuSpecPalette::PaintSpectrum(), vuTFDesignSpec::updateFromPalette(), and vuTFDesignSpec::updatePalette().

bool& SPalette::getSpecDesignState int  rid,
int  lid
[inline]
 

tell whether the spectrum should be designed (returns bool handle)

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 241 of file SPalette.h.

Referenced by vuSpecPalette::OnCBSPDesign(), and vuSpecPalette::PaintColours().

vuColour31a& SPalette::getSpecLB int  rid,
int  lid
[inline]
 

handle to lower bound of spectrum

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 226 of file SPalette.h.

Referenced by vuSpecPalette::OnColourClick(), and vuSpecPalette::OnSPLowerBound().

const char* SPalette::getSpecName int  rid,
int  lid
[inline]
 

get name of spectrum

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 236 of file SPalette.h.

SSpectrum& SPalette::getSpecRec int  rid,
int  lid
[inline, private]
 

returns handle to a spectral class

Definition at line 293 of file SPalette.h.

vuColour31a& SPalette::getSpecUB int  rid,
int  lid
[inline]
 

handle to upper bound of spectrum

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 221 of file SPalette.h.

Referenced by vuSpecPalette::OnColourClick(), and vuSpecPalette::OnSPUpperBound().

bool SPalette::load const char *  filename  ) 
 

loads a palette definition

Returns:
false=error, true=success

Referenced by SPaled::OnInit(), and vuSpecPalette::OnLoadPal().

bool SPalette::loadSpectrum int  rid,
int  lid,
const char *  filename
 

loads a single spectrum

Returns:
false=error, true=success

Referenced by vuSpecPalette::OnLoadSP().

SMatrix SPalette::makeCXFMat const vuColour31a diag,
bool  useV7
[private]
 

Returns a V31tRGB matrix accumulated with the diagonal matrix of the given Spectrum.

The switch useV7 decides whether to do diagonal multiply in V7.

SMatrix SPalette::makeCXFMat const vuColour31a diag  )  [inline, private]
 

Returns a V31tRGB matrix accumulated with the diagonal matrix of the given Spectrum.

Definition at line 307 of file SPalette.h.

SMatrix SPalette::makeErrorMat const vuColour31a diag  )  [private]
 

Returns weighted error minimizing matrix for the given spectrum.

SMatrix SPalette::makeSmoothingMat  )  [private]
 

Returns weighted smoothing matrix (31x31).

void SPalette::matchDesignColours  ) 
 

sets the initial values of the design colours to the actual colours

Referenced by vuTFDesignSpec::updatePalette().

void SPalette::removeLight word  index  ) 
 

Remove a light spectrum from the palette.

Index in the list of lights.

void SPalette::removeReflectance word  index  ) 
 

Remove a reflectance spectrum from the palette.

Index in the list of reflectances.

void SPalette::reset  ) 
 

clears all entries for lights and reflectances

Referenced by vuTFDesignSpec::parseTFunc().

bool SPalette::save const char *  filename  ) 
 

saves a palette definition

Returns:
false=error, true=success

Referenced by vuSpecPalette::OnSavePal().

bool SPalette::saveSpectrum int  rid,
int  lid,
const char *  filename
 

saves a single spectrum

Returns:
false=error, true=success

Referenced by vuSpecPalette::OnSaveSP().

void SPalette::setDesignRGBW dword  rid,
dword  lid,
const vuColourRGBa col
 

Sets the desired colour for a reflectance-light combination.

The alpha value is interpreted as a weight for that colour.

void SPalette::setErrorMinWeight float  weight  ) 
 

Sets m_WErrorMin.

Referenced by vuSpecPalette::OnErrorW().

void SPalette::setFreeColour dword  fcid,
const vuColourRGBa lb = vuColourRGBa(0.0f),
const vuColourRGBa ub = vuColourRGBa(1.0f)
 

creates a 'free colour' slot, if it doen't already exist, lb and ub can be used to make a lower and upper bound

void SPalette::setSmoothnessWeight float  weight  ) 
 

Sets m_WSmoothness.

Referenced by vuSpecPalette::OnSmoothW().

void SPalette::setSpecName int  rid,
int  lid,
const char *  name
[inline]
 

set name for spectrum

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 231 of file SPalette.h.

Referenced by vuSpecPalette::OnSPName().

bool& SPalette::useSpecBounds int  rid,
int  lid
[inline]
 

use bounds? returns handle for bool

Either rid or lid has to be -1, the other holds the index for the light/reflectance you're inquiring about.

Definition at line 216 of file SPalette.h.

Referenced by vuSpecPalette::OnCBSPUseB().

void SPalette::useV7 bool  useit = true  )  [inline]
 

When finding a colour for a given spectrum you can make it correct in the V31 or in the V7 space.

This function tells which one to use. To minimize the difference between the results of the two colour spaces use setErrorMinWeight().

Definition at line 181 of file SPalette.h.

Referenced by vuSpecPalette::CreateWidgets(), and vuSpecPalette::OnCBUseV7().


Member Data Documentation

SMatrix SPalette::m_C31t7 [private]
 

for conversion from V31 to V7

Definition at line 357 of file SPalette.h.

SMatrix SPalette::m_CXF31to7 [private]
 

colour conversion matrix.

Definition at line 363 of file SPalette.h.

SMatrix SPalette::m_CXF31toRGB [private]
 

colour conversion matrix.

Definition at line 361 of file SPalette.h.

SMatrix SPalette::m_CXF7toRGB [private]
 

colour conversion matrix.

Definition at line 362 of file SPalette.h.

vuDVector< vuDVector<SDesignColour> > SPalette::m_DesCol [private]
 

A 2D field of RGB values holding the desired values for each light*reflectance combination.

The alpha values of the colours are used as weights for the minimization. (Indexing is m_DesCol[reflID][lightID])

Definition at line 331 of file SPalette.h.

vuDVector< SFreeColour > SPalette::m_FreeCol [private]
 

slots for 'free' colours.

Definition at line 334 of file SPalette.h.

vuDVector<SSpectrum> SPalette::m_Lights [private]
 

A growable array (vuDVector) of lights.

Use add/removeLight() for accessing this array to maintain consistence with m_DesCol.

Definition at line 321 of file SPalette.h.

dword SPalette::m_NDesCol [private]
 

number of design colours used

Definition at line 359 of file SPalette.h.

dword SPalette::m_NDesSpec [private]
 

number of spectra used for design

Definition at line 360 of file SPalette.h.

SOptimizer SPalette::m_Optimizer [private]
 

The optimizer used for fitting spectra into the given criteria.

Definition at line 355 of file SPalette.h.

vuDVector<SSpectrum> SPalette::m_Refls [private]
 

A growable array (vuDVector) of reflectances.

Use add/removeReflectance() for accessing this array to maintain consistence with m_DesCol.

Definition at line 325 of file SPalette.h.

bool SPalette::m_UseErrorMin [private]
 

switch for using the error minimizing matrix

Definition at line 352 of file SPalette.h.

bool SPalette::m_UseSmoothness [private]
 

switch for whether to use smoothness or not

Definition at line 344 of file SPalette.h.

bool SPalette::m_UseV7 [private]
 

perform optimization using V7 colour Xform?

Definition at line 337 of file SPalette.h.

float SPalette::m_WErrorMin [private]
 

Weight for the error minimizing matrix.

0 - inactive. This matrix is a combination of (c31tRGB - (c7tRGB*c31t7)) for each light source. The resulting vector is an indication for the error in the 7model.

Definition at line 350 of file SPalette.h.

float SPalette::m_WSmoothness [private]
 

Weight for smoothness as a design criterion.

0 - inactive. Appends a 2nd derivative filter toeplitz(m_Smoothness*(-1 2 -1)...) to the optimization matrix.

Definition at line 342 of file SPalette.h.


The documentation for this class was generated from the following file:
Generated on Wed Dec 15 21:21:02 2004 for vuVolume by  doxygen 1.3.9.1