00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#ifndef _ZFXMATH_INCLUDE_SH_DEVICE_H_
00015
#define _ZFXMATH_INCLUDE_SH_DEVICE_H_
00016
00017
#include <assert.h>
00018
#include "SphericalHarmonics.h"
00019
#include "SHRotateMatrix.h"
00020
#include "SHRotate.h"
00021
#include "NRook.h"
00022
00023
namespace ZFXMath
00024 {
00025
00026
namespace SphericalHarmonics
00027 {
00028
00038
template<
class PrecisionType,
class FuncValueType >
00039 struct TDevice
00040 {
00052 TDevice(
int numBands,
int numSamples ) :
00053 m_NumBands( numBands ),
00054 m_NumSamples( numSamples )
00055 {
00056 assert( numBands > 0 );
00057 assert( numSamples > 0 );
00058
00059
00060 m_Samples = GenerateSamples<PrecisionType>( m_NumSamples );
00061
00062
00063 m_CoeffsAllocator =
new TCoeffs<PrecisionType>::Allocator( m_NumSamples * m_NumBands * m_NumBands );
00064
00065
00066 m_SHValues =
new TCoeffs<PrecisionType>[m_NumSamples];
00067
00068
for (
int i = 0; i < m_NumSamples; i++)
00069 {
00070
00071
TSample<PrecisionType>& s = m_Samples[i];
00072
00073
00074 TCoeffs<PrecisionType>& sh = m_SHValues[i] = TCoeffs<PrecisionType>( m_NumBands, m_CoeffsAllocator );
00075
00076
00077
for (
int l = 0; l < m_NumBands; l++)
00078
for (
int m = -l; m <= l; m++)
00079 sh(l, m) = y<PrecisionType>(l, m, s.
theta, s.
phi);
00080 }
00081 }
00082
00083 ~
TDevice()
00084 {
00085
delete m_CoeffsAllocator;
00086
delete[] m_SHValues;
00087 }
00088
00100 void Project(
const TSphericalFunction< PrecisionType, FuncValueType >& func,
00101
TCoeffs< FuncValueType >& dest )
00102 {
00103 SphericalHarmonics::Project( func, m_Samples, m_SHValues, m_NumSamples, dest );
00104 }
00105
00106
private:
00107
00108
00109
int m_NumSamples;
00110
00111
00112
int m_NumBands;
00113
00114
00115
TSample<PrecisionType>* m_Samples;
00116
00117
00118
typename TCoeffs<PrecisionType>::Allocator* m_CoeffsAllocator;
00119
00120
00121
TCoeffs<PrecisionType>* m_SHValues;
00122
00123 };
00124
00125 };
00126
00127 };
00128
00129
#endif //_ZFXMATH_INCLUDE_SH_DEVICE_H__