source: GTP/trunk/Lib/Vis/Preprocessing/src/Halton.cpp @ 2227

Revision 2227, 1.8 KB checked in by mattausch, 18 years ago (diff)

added render cost bound for objects, improved undersampling compensation

RevLine 
[355]1#include "Halton.h"
[2227]2#include "Timer/PerfTimer.h"
[355]3
[2227]4
[2105]5#define PREGENERATE_HALTON 0
6
[863]7namespace GtpVisibilityPreprocessor {
[860]8
[2076]9PerfTimer haltonTimer;
10
[355]11// global halton generator
12
[2076]13  Halton2 halton2;
14  float Halton2::_invBases[2];
[860]15
[2076]16  float Halton<1>::_invBases[1];
17  float Halton<2>::_invBases[2];
18  float Halton<3>::_invBases[3];
19  float Halton<4>::_invBases[4];
20  float Halton<5>::_invBases[5];
21  float Halton<6>::_invBases[6];
22 
23
24  Halton<1> dummmyHalton1(true);
25  Halton<2> dummmyHalton2(true);
26  Halton<3> dummmyHalton3(true);
27  Halton<4> dummmyHalton4(true);
28  Halton<5> dummmyHalton5(true);
29  Halton<6> dummmyHalton6(true);
[2105]30
31
32  int HaltonSequence::sPregeneratedDim = 0;
33  int HaltonSequence::sPregeneratedNumber = 0;
34  float *HaltonSequence::sPregeneratedValues = NULL;
[2076]35 
[2105]36#if PREGENERATE_HALTON
37  // pregenerate first 100k numbers for 6 dimensions
38  static HaltonSequence staticHalton(6, 200000);
39#endif
40 
41  // special construtor for pregenerating static halton sequences
42  HaltonSequence::HaltonSequence(const int dim,
43                                                                 const int number) {
44
45        sPregeneratedDim = 0;
46        sPregeneratedNumber = 0;
47        sPregeneratedValues = new float[number*dim];
48
49        float *p = sPregeneratedValues;
50        int i;
51        for (i=0; i < number; i++, p+=dim) {
52          GetNext(dim, p);
53        }
54       
55        sPregeneratedDim = dim;
56        sPregeneratedNumber = number;
57  }
58
[2076]59void
60HaltonSequence::GetNext(const int dimensions, float *p)
61{
[2105]62  //  haltonTimer.Entry();
63#if PREGENERATE_HALTON
64  if (index <= sPregeneratedNumber && dimensions <= sPregeneratedDim) {
65        float *pp = sPregeneratedValues + (sPregeneratedDim*(index-1));
66        for (int i=0; i < dimensions; i++)
67          p[i] = pp[i];
68  } else
69#endif
70        {
71          for (int i=0; i < dimensions; i++)
72                p[i] = (float)GetNumber(i+1);
73        }
[2076]74  GenerateNext();
[2105]75  //  haltonTimer.Exit();
[2076]76}
77
78}
Note: See TracBrowser for help on using the repository browser.