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

TFRasterize2D01.h

Go to the documentation of this file.
00001 rasterize2D(Nrro::NrroIter<T> ni, 
00002             const gutz::vec2i &posIdx, 
00003             const STF::tfRangeIdx &valIdx) const
00004 {
00005       /// we will use float precicion for now
00006    vec2<T> mmm; /// min & max for the map
00007 
00008    if(numeric_limits<T>::epsilon()) /// float/double type
00009    {
00010       mmm = vec2<T>(T(0.0),T(1.0));
00011    }
00012    else /// integral type
00013    {
00014       mmm = vec2<T>(numeric_limits<T>::min(), numeric_limits<T>::max());
00015    }
00016 
00017    const tfSType left    = _posVec[LL][posIdx.x];
00018    const tfSType right   = _posVec[UR][posIdx.x];
00019    const tfSType bottom  = _posVec[LL][posIdx.y];
00020    const tfSType top     = _posVec[UR][posIdx.y];
00021 
00022    const tfSType width   = right - left;
00023    const tfSType height  = top - bottom;
00024    const tfSType hw      = width * tfSType(.5);
00025    const tfSType hh      = height * tfSType(.5);
00026 
00027    /// bounding box for the current axies
00028    const int minX = clamp(0, int(bmin[posIdx.x] * ni->dim(1)), ni->dim(1));
00029    const int minY = clamp(0, int(bmin[posIdx.y] * ni->dim(2)), ni->dim(2));
00030    const int maxX = clamp(0, int(bmax[posIdx.x] * ni->dim(1)), ni->dim(1));
00031    const int maxY = clamp(0, int(bmax[posIdx.y] * ni->dim(2)), ni->dim(2));
00032 
00033    /// tf domain positions and deltas for rasterization
00034    const STF::tfSType px = left;
00035    const STF::tfSType py = bottom;
00036    const STF::tfSType dx = 2.0f/float(ni->dim(1));
00037    const STF::tfSType dy = 2.0f/float(ni->dim(2));
00038 
00039    /// temps used in inner loop, so we are not constructing tons of stuff
00040    tfSType u;
00041    ValType o = _valVec[0];
00042    tfVec2 pos(-1,-1);
00043 
00044    /// Rasterize!!!
00045    for(int y = minY; y<= maxY; ++y, pos.y+=dy)  /// y axis
00046    {
00047       for(int x = minX; x<= maxX; ++x, pos.x+=dx) /// x axis
00048       {
00049          /// over values (values from this element)
00050          o[STF::ALPHA] = myEval(pos.x*pos.x + pos.y*pos.y) * _valVec[0][STF::ALPHA];
00051          /// update the map
00052          for(int i=0; i<4; ++i) /// for each element in map
00053          {
00054             /// get existing map value in tfDomain extents
00055             u = g_affine(T(mmm.x), ni(i,x,y), T(mmm.y), TFT(0.0), TFT(1.0));
00056             /// combine over (o) and under (u) values
00057             //_blend[valIdx[i]]->blend(o,u,valIdx[i]);
00058             /// update map in map type extents
00059             ni(i,x,y) = g_affine(TFT(0.0), o[valIdx[i]], TFT(1.0), T(mmm.x), T(mmm.y)); 
00060          }
00061       }
00062       pos.x = px;
00063    }
00064 }
00065 
00066 
00067 /// Hi this is one of the weirder things I have done, you can use this by
00068 /// decalring your own STF::tfSType myEval(T d) //T is float or double, preferably inline
00069 /// rasterize2D<> should be a template member function, you do this in a .cpp file:
00070 ///
00071 /// template<class T>
00072 /// void myClass:: #include "TFRasterize2D01.h" 
00073 ///

Send questions, comments, and bug reports to:
jmk