ValueHandlerTempl< ValueT > Struct Template Reference

Inheritance diagram for ValueHandlerTempl< ValueT >:

ValueHandler

List of all members.

Public Member Functions

virtual Real64 getValue (const UInt8 *data, UInt32 channels, UInt32 width, UInt32 height, UInt32 c, UInt32 x1, UInt32 y1, UInt32 z1, UInt32 x2, UInt32 y2, UInt32 z2, Real64 *weightX, Real64 *weightY, Real64 *weightZ)
virtual void setValue (Real64 value, UInt8 *data, UInt32 channels, UInt32 width, UInt32 height, UInt32 c, UInt32 x, UInt32 y, UInt32 z)


Detailed Description

template<class ValueT>
struct ValueHandlerTempl< ValueT >

Definition at line 194 of file OSGImageScaler.cpp.


Member Function Documentation

template<class ValueT>
virtual Real64 ValueHandlerTempl< ValueT >::getValue ( const UInt8 *  data,
UInt32  channels,
UInt32  width,
UInt32  height,
UInt32  c,
UInt32  x1,
UInt32  y1,
UInt32  z1,
UInt32  x2,
UInt32  y2,
UInt32  z2,
Real64 *  weightX,
Real64 *  weightY,
Real64 *  weightZ 
) [inline, virtual]

Implements ValueHandler.

Definition at line 196 of file OSGImageScaler.cpp.

00205     {
00206         Real64 result = 0;
00207         UInt32 x,y,z;
00208 
00209         for(z = 0 ; z <= (z2-z1) ; ++z)
00210         {
00211             for(y = 0 ; y <= (y2-y1) ; ++y)
00212             {
00213                 ValueT *valueP = (ValueT*)(data) +
00214                     (z1 + z) * (height*width*channels) +
00215                     (y1 + y) * (width*channels) +
00216                     (x1)     * (channels) + c;
00217                 for(x = 0 ; x <= (x2-x1) ; ++x)
00218                 {
00219                     result += (Real64)*(valueP) *
00220                         (weightX[x] * weightY[y] * weightZ[z]);
00221                     valueP += channels;
00222                 }
00223             }
00224         }
00225         return result;
00226     }

template<class ValueT>
virtual void ValueHandlerTempl< ValueT >::setValue ( Real64  value,
UInt8 *  data,
UInt32  channels,
UInt32  width,
UInt32  height,
UInt32  c,
UInt32  x,
UInt32  y,
UInt32  z 
) [inline, virtual]

Implements ValueHandler.

Definition at line 227 of file OSGImageScaler.cpp.

00230     {
00231         // clamp value.
00232         Real64 maxValue = (Real64)TypeTraits<ValueT>::getMax();
00233         if(value > maxValue)
00234         {
00235             value = maxValue;
00236         }
00237         else
00238         {
00239             if(value < 0.0)
00240                 value = 0.0;
00241         }
00242 
00243         ValueT *valueP = (ValueT*)(data);
00244         valueP = valueP + 
00245             z * (width*height*channels) +
00246             y * (width*channels) +
00247             x * (channels) +
00248             c;
00249 
00250         *valueP = (ValueT)value;
00251     }


The documentation for this struct was generated from the following file:

Generated on Mon Mar 17 12:03:00 2008 for OpenSG by  doxygen 1.5.5