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

Revision 2588, 1.8 KB checked in by bittner, 17 years ago (diff)

sceneBox bugfix

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