JitteredSampleGenerator.cpp

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @file   JitteredSampleGenerator.cpp
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @date   Fall 2008
00005    
00006    @brief
00007       Jittered point sample generation over a given 2D domain where M*N 
00008    samples are generated randomly within M*N uniformly-spaced subdomains
00009    <!-------------------------------------------------------------------->**/
00010 
00011 #include "JitteredSampleGenerator.h"
00012 #include <Random.h>
00013 #include <QtCore>
00014 using namespace std;
00015 
00016 template <class SG>
00017 void JitteredSG<SG>::generate(PointSampleList &outSamples, 
00018                               const Viewport &viewport)
00019 {
00020    const unsigned width   = viewport.getWidth();
00021    const unsigned height  = viewport.getHeight();
00022    
00023    const real_t binWidth  = viewport.getInvWidth();
00024    const real_t binHeight = viewport.getInvHeight();
00025    
00026    for(unsigned i = 0; i < height; ++i) {
00027       for(unsigned j = 0; j < width; ++j) {
00028          const real_t x = j * binWidth + Random::sample(0, binWidth);
00029          const real_t y = i * binWidth + Random::sample(0, binHeight);
00030          
00031          SG::_addSample(PointSample(x, y), outSamples);
00032       }
00033    }
00034 }
00035 
00036 // force explicit template specialization of JitteredSampleGenerator and 
00037 // JitteredSampleGeneratorThread
00038 #include <generators.h>
00039 DECLARE_SAMPLE_GENERATOR(Jittered);
00040 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6