arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

TFBlend.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     3-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 /// TFBlend.h
00019 
00020 /// TF Element blend strategies, for combining multiple overlapping 
00021 /// elements in the tf data domian.
00022 
00023 #ifndef __SIMIAN_TF_BLEND_DOT_H
00024 #define __SIMIAN_TF_BLEND_DOT_H
00025 
00026 #include "TFParams.h"
00027 //#include <smartptr.h>
00028 
00029 #if 0
00030 /////////////////////////////////////////////////////////////////////////
00031 /// blend op interface
00032 class TFBlendOP : public gutz::Counted {
00033 public:
00034    typedef STF::tfSType     SType; ///scalar type
00035    typedef STF::tfRangeType VType; ///vector type
00036 
00037    virtual ~TFBlendOP() {}
00038 
00039    /// blend o[i] over u[i]
00040    virtual SType blend(const VType &o, const VType &u, const int i) const = 0;
00041 
00042 protected:
00043    TFBlendOP() {}
00044    TFBlendOP &operator=(const TFBlendOP &) {} /// not used
00045 };
00046 
00047 typedef gutz::SmartPtr<TFBlendOP> TFBlendOPSP;
00048 #endif
00049 
00050 /////////////////////////////////////////////////////////////////////////
00051 //// summation
00052 class TFBlendSum
00053 {
00054 public:
00055    typedef STF::tfSType     SType;
00056    typedef STF::tfRangeType VType;
00057 
00058    TFBlendSum() {}
00059    ~TFBlendSum() {}
00060 
00061    static
00062    SType blend(const VType &o, const VType &u, const int i)
00063    {
00064       return o[i] + u[i];
00065    }
00066    
00067 protected:
00068 };
00069 
00070 /////////////////////////////////////////////////////////////////////////
00071 /// alpha blend
00072 class TFBlendOverAlpha 
00073 {
00074 public:
00075    typedef STF::tfSType     SType;
00076    typedef STF::tfRangeType VType;
00077 
00078    TFBlendOverAlpha() {}
00079    ~TFBlendOverAlpha() {}
00080 
00081    static
00082    SType blend(const VType &o, const VType &u, const int i)
00083    {
00084       if(i != STF::ALPHA)
00085          return o[i]*o[STF::ALPHA] + u[i]*(1.0f - o[STF::ALPHA]);
00086       return o[i] + u[i]*(1.0f - o[STF::ALPHA]);
00087    }
00088 
00089 };
00090 
00091 
00092 #if 0
00093 /////////////////////////////////////////////////////////////////////////
00094 /////////////////////////////////////////////////////////////////////////
00095 /// an array of blend ops
00096 /////////////////////////////////////////////////////////////////////////
00097 /////////////////////////////////////////////////////////////////////////
00098 
00099 class TFBlend {
00100 public:
00101    /// default
00102    TFBlend()
00103    {
00104       _boVec[0] = new TFBlendSum();
00105       for(int i=1; i<STF::TF_MAX_R; ++i)
00106          _boVec[i] = new TFBlendSum();
00107    }
00108    /// copy
00109    TFBlend(const TFBlend &b)
00110    { for(int i=0; i<STF::TF_MAX_R; ++i) _boVec[i] = b._boVec[i]; }
00111    ~TFBlend() {}
00112    /// assign
00113    TFBlend &operator=(const TFBlend &b)
00114    { for(int i=0; i<STF::TF_MAX_R; ++i) _boVec[i] = b._boVec[i]; return *this; }
00115 
00116    /// [] accessor, since we really are an array
00117    TFBlendOPSP &operator[](int i) { return _boVec[i]; }
00118    const TFBlendOPSP &operator[](int i) const { return _boVec[i]; }
00119 
00120    /// size should be the same as the max range dim
00121    int size() { return STF::TF_MAX_R; }
00122 
00123    /// set get a blendOP in the array
00124    void        setBlendOP(int idx, TFBlendOP *op) { _boVec[idx] = op; }
00125    TFBlendOPSP getBlendOP(int idx) const          {return _boVec[idx];}
00126 protected:
00127    TFBlendOPSP _boVec[STF::TF_MAX_R];
00128 
00129 };
00130 
00131 #endif
00132 
00133 #endif
00134 
00135 

Send questions, comments, and bug reports to:
jmk