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

RevLine 
[2588]1#include "common.h"
[355]2#include "Halton.h"
[2575]3
[2588]4#ifdef USE_PERFTIMER 
[2227]5#include "Timer/PerfTimer.h"
[2575]6#endif
[355]7
[2588]8
[2105]9#define PREGENERATE_HALTON 0
10
[863]11namespace GtpVisibilityPreprocessor {
[860]12
[2575]13 
[2588]14#ifdef USE_PERFTIMER
[2076]15PerfTimer haltonTimer;
[2575]16#endif
17 
[355]18// global halton generator
19
[2076]20  Halton2 halton2;
21  float Halton2::_invBases[2];
[860]22
[2575]23  //float Halton<6>::_invBases[6];
[2076]24 
[2575]25  template<int T> float Halton<T>::_invBases[T];
26 
[2076]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);
[2105]33
34
35  int HaltonSequence::sPregeneratedDim = 0;
36  int HaltonSequence::sPregeneratedNumber = 0;
37  float *HaltonSequence::sPregeneratedValues = NULL;
[2076]38 
[2105]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
[2076]62void
63HaltonSequence::GetNext(const int dimensions, float *p)
64{
[2105]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        }
[2076]77  GenerateNext();
[2105]78  //  haltonTimer.Exit();
[2076]79}
80
81}
Note: See TracBrowser for help on using the repository browser.