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

TFRasterize.cpp

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 /// TFRasterize.cpp
00019 
00020 #include "TFElement.h"
00021 #include <limits>
00022 
00023 using namespace STF;
00024 using namespace std;
00025 using namespace gutz;
00026 
00027 typedef tfSType TFT;
00028 
00029 #if 0
00030 /// a generic rasterization algorithm
00031 template<class T>
00032 void TFElement::rasterize2D(Nrro::NrroIter<T> ni, 
00033                             const gutz::vec2i &posIdx, 
00034                             const STF::tfRangeIdx &valIdx) const
00035 {
00036    /// we will use float precicion for now
00037    vec2<T> mmm; /// min & max for the map
00038 
00039    if(numeric_limits<T>::epsilon()) /// float/double type
00040    {
00041       mmm = vec2<T>(T(0.0),T(1.0));
00042    }
00043    else /// integral type
00044    {
00045       mmm = vec2<T>(numeric_limits<T>::min(), numeric_limits<T>::max());
00046    }
00047 
00048    /// complete bounding box
00049    const PosType bmin = getMinBox();
00050    const PosType bmax = getMaxBox();
00051 
00052    /// bounding box for the current axies
00053    const int minX = clamp(0, int(bmin[posIdx.x] * ni->dim(1)), ni->dim(1));
00054    const int minY = clamp(0, int(bmin[posIdx.y] * ni->dim(2)), ni->dim(2));
00055    const int maxX = clamp(0, int(bmax[posIdx.x] * ni->dim(1)), ni->dim(1));
00056    const int maxY = clamp(0, int(bmax[posIdx.y] * ni->dim(2)), ni->dim(2));
00057 
00058    /// tf domain positions and deltas for rasterization
00059    const STF::tfSType px = minX/float(ni->dim(1));
00060    const STF::tfSType py = minY/float(ni->dim(2));
00061    const STF::tfSType dx = 1.0f/float(ni->dim(1));
00062    const STF::tfSType dy = 1.0f/float(ni->dim(2));
00063 
00064    /// temps used in inner loop, so we are not constructing tons of stuff
00065    tfSType u;
00066    ValType o;
00067    tfVec2 pos(px,py);
00068 
00069    /// Rasterize!!!
00070    for(int y = minY; y<= maxY; ++y, pos.y+=dy)  /// y axis
00071    {
00072       for(int x = minX; x<= maxX; ++x, pos.x+=dx) /// x axis
00073       {
00074          /// over values (values from this element)
00075          o = eval(pos, posIdx);
00076 #if 1
00077          /// update the map
00078          for(int i=0; i<ni->dim(0); ++i) /// for each element in map
00079          {
00080             /// get existing map value in tfDomain extents
00081             u = g_affine(T(mmm.x), ni(i,x,y), T(mmm.y), TFT(0.0), TFT(1.0));
00082             /// combine over (o) and under (u) values
00083             //_blend[valIdx[i]]->blend(o,u,valIdx[i]);
00084             /// update map in map type extents
00085             ni(i,x,y) = g_affine(TFT(0.0), o[valIdx[i]], TFT(1.0), T(mmm.x), T(mmm.y)); 
00086          }
00087 #endif
00088       }
00089       pos.x = px;
00090    }
00091 
00092 }
00093 
00094 //// a helper #def for declaring specific instantiations of the 
00095 //// templateed rasterize2D function
00096 #define genRasterize2D(T) \
00097    template \
00098    void TFElement::rasterize2D(Nrro::NrroIter<##T##> ni, \
00099                                const gutz::vec2i &posIdx, \
00100                                const STF::tfRangeIdx &valIdx) const
00101 
00102 //// need these declared since rasterize2D is defined in a .cpp file
00103 //// we need them to build!
00104 genRasterize2D(char);
00105 genRasterize2D(unsigned char);
00106 genRasterize2D(short);
00107 genRasterize2D(unsigned short);
00108 genRasterize2D(int);
00109 genRasterize2D(unsigned int);
00110 genRasterize2D(float);
00111 genRasterize2D(double);
00112 
00113 
00114 
00115 
00116 #endif

Send questions, comments, and bug reports to:
jmk