/* File: example2.cpp An example of the use of the Quasisampler class. Reminder: This is a toy implementation, created to aid in understanding how the system works. This example generates a set of points for a linear gradient function. Usage: example2 [magnitude_factor=50000] This is a toy (non-optimized) implementation of the importance sampling technique proposed in the paper: "Fast Hierarchical Importance Sampling with Blue Noise Properties", by Victor Ostromoukhov, Charles Donohue and Pierre-Marc Jodoin, to be presented at SIGGRAPH 2004. Implementation by Charles Donohue, Based on Mathematica code by Victor Ostromoukhov. Universite de Montreal 05.08.04 */ #include <iostream> #include "quasisampler_prototype.h" class MyQuasisampler : public Quasisampler { unsigned const_val; public: MyQuasisampler(unsigned val) : Quasisampler(100,100), const_val(val) {} unsigned getImportanceAt( Point2D pt ) { // This function returns a gradient in the x direction. return (unsigned)(const_val*(pt.x/100.0)); } }; typedef std::vector<Point2D> PointList; int main(int argc, char* argv[]) { unsigned mag_factor = 50000; if (argc>1) mag_factor = atoi(argv[1]); // initialize sampler MyQuasisampler test(mag_factor); // generate points PointList points = test.getSamplingPoints(); // print points for ( PointList::iterator it=points.begin(); it!=points.end(); it++ ) std::cout << it->x << "," << it->y << std::endl; return 0; }
00001 /* 00002 00003 File: example2.cpp 00004 00005 An example of the use of the Quasisampler class. 00006 Reminder: This is a toy implementation, created 00007 to aid in understanding how the system works. 00008 00009 This example generates a set of points for a 00010 linear gradient function. 00011 00012 Usage: example2 [magnitude_factor=50000] 00013 00014 00015 This is a toy (non-optimized) implementation of the importance sampling 00016 technique proposed in the paper: 00017 "Fast Hierarchical Importance Sampling with Blue Noise Properties", 00018 by Victor Ostromoukhov, Charles Donohue and Pierre-Marc Jodoin, 00019 to be presented at SIGGRAPH 2004. 00020 00021 00022 Implementation by Charles Donohue, 00023 Based on Mathematica code by Victor Ostromoukhov. 00024 Universite de Montreal 00025 05.08.04 00026 00027 */ 00028 00029 #include <iostream> 00030 #include "quasisampler_prototype.h" 00031 00032 00033 class MyQuasisampler : public Quasisampler 00034 { 00035 unsigned const_val; 00036 00037 public: 00038 MyQuasisampler(unsigned val) : Quasisampler(100,100), const_val(val) {} 00039 00040 unsigned getImportanceAt( Point2D pt ) 00041 { 00042 // This function returns a gradient in the x direction. 00043 return (unsigned)(const_val*(pt.x/100.0)); 00044 } 00045 }; 00046 00047 00048 typedef std::vector<Point2D> PointList; 00049 00050 int main(int argc, char* argv[]) 00051 { 00052 unsigned mag_factor = 50000; 00053 if (argc>1) mag_factor = atoi(argv[1]); 00054 00055 // initialize sampler 00056 MyQuasisampler test(mag_factor); 00057 00058 // generate points 00059 PointList points = test.getSamplingPoints(); 00060 00061 // print points 00062 for ( PointList::iterator it=points.begin(); it!=points.end(); it++ ) 00063 std::cout << it->x << "," << it->y << std::endl; 00064 00065 return 0; 00066 } 00067