1 #ifndef sincinterpolator_h 2 #define sincinterpolator_h 24 static SincTableManager&
STM();
29 Table(
int lsinc,
int nsinc,
float emax,
float fmax,
33 bool isOK()
const {
return asinc2_.get2DData(); }
35 bool hasSameDesign(
float fmax,
int lmax)
const;
41 int getNumbers()
const;
43 inline void setValue(
int idx,
int idy,
float val )
44 { asinc2_.set( idx, idy, val ); }
45 inline float getValue(
int idx,
int idy )
const 46 {
return asinc2_.get( idx, idy ); }
62 friend class RotatorExecutor;
66 const Table* getTable(
float fmax,
int lmax);
72 int getTableIdx(
float fmax,
int lmax)
const;
75 static const Table* makeTable(
float fmax,
int lmax);
76 static float sinc(
float x);
79 static float**
makeArray(
int n1,
int n2) {
return 0; }
141 virtual bool initTable(
float fmax,
int lmax);
142 inline bool isTableOK()
const;
144 inline od_int64 getTableBytes()
const;
145 inline float getMaximumError()
const;
146 inline float getMaximumFrequency()
const;
147 inline int getMaximumLength()
const;
155 bool init() {
return initTable( 0.3f, 8 ); }
157 inline float getTableVal(
int idx,
int idy)
const;
179 template <
class RT,
class PT>
187 void setInput(
const RT*,
bool datahasnoudf=
false);
188 bool isOK()
const {
return data_ && isTableOK(); }
189 bool initTable(
float fmax,
int lmax);
191 RT getValue(PT)
const;
201 template <
class RT,
class PT>
207 bool isOK()
const {
return isTableOK(); }
208 bool initTable(
float fmax,
int lmax);
210 RT getValue(PT,PT)
const;
223 template <
class RT,
class PT>
229 bool isOK()
const {
return isTableOK(); }
230 bool initTable(
float fmax,
int lmax);
232 RT getValue(PT,PT,PT)
const;
278 bool hasudfs =
false;
279 for (
int idx=0; idx<sz; idx++ )
294 template <
class RT,
class PT>
305 template <
class RT,
class PT>
316 template <
class RT,
class PT>
327 template <
class RT,
class PT>
337 #define mKSinc(frac) ( mCast(int,frac*nsincm1_+0.5) ) 338 #define mValidPos(is,ns) ( (is > -1 && is < ns) ) 339 #define mCheckUdf(totidx) \ 341 if ( isudfarr_ && isudfarr_[totidx] ) \ 344 #define mAddVal(val,weight,totidx,outval) \ 347 outval += val * weight; \ 349 #define mAddValW(val,totidx,weight,outval,sumweights) \ 352 outval += val * weight; \ 353 sumweights += weight; \ 356 template <
class RT,
class PT>
365 const PT floorx = floor(x);
373 for (
int isinc=0,idx=idx0; isinc<
lsinc_; isinc++,idx++ )
378 for (
int isinc=0,idx=idx0; isinc<
lsinc_; isinc++,idx++ )
380 const int idx1 = idx < 0 ? 0 : idx >=
nx_ ?
nx_-1 : idx;
386 float sumweights = 0.f;
387 for (
int isinc=0,idx=idx0; isinc<
lsinc_; isinc++,idx++ )
402 template <
class RT,
class PT>
414 template <
class RT,
class PT>
426 template <
class RT,
class PT>
438 const PT floorx = floor(x);
439 const PT floory = floor(y);
447 double out = 0., outx;
450 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
453 const float asincxval = asincx[ixsinc];
457 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
462 out += outx * asincxval;
467 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
470 const float asincxval = asincx[ixsinc];
474 const int idx1 = idx < 0 ? 0 : idx >=
nx_ ?
nx_-1 : idx;
475 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
477 const int idy1 = idy < 0 ? 0 : idy >=
ny_ ?
ny_-1 : idy;
481 out += outx * asincxval;
486 double sumweights = 0., sumx;
487 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
489 outx = 0.; sumx = 0.;
490 const float asincxval = asincx[ixsinc];
494 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
502 out += outx * asincxval;
513 template <
class RT,
class PT>
527 template <
class RT,
class PT>
541 #define mGetOffset(idx,idy,idz) ( idz + nz_*( idy + ny_*idx ) ) 542 template <
class RT,
class PT>
557 const PT floorx = floor(x);
558 const PT floory = floor(y);
559 const PT floorz = floor(z);
574 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
577 const float asincxval = asincx[ixsinc];
581 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
584 const float asincyval = asincy[iysinc];
588 for (
int izsinc=0,idz=idz0; izsinc<
lsinc_; izsinc++,idz++ )
593 outx += outy * asincyval;
595 out += asincxval * outx;
600 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
603 const float asincxval = asincx[ixsinc];
607 const int idx1 = idx < 0 ? 0 : idx >=
nx_ ?
nx_-1 : idx;
608 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
611 const float asincyval = asincy[iysinc];
615 const int idy1 = idy < 0 ? 0 : idy >=
ny_ ?
ny_-1 : idy;
616 for (
int izsinc=0,idz=idz0; izsinc<
lsinc_; izsinc++,idz++ )
618 const int idz1 = idz < 0 ? 0 : idz >=
nz_ ?
nz_-1 : idz;
622 outx += outy * asincyval;
624 out += asincxval * outx;
629 double sumweights = 0., sumx, sumy;
630 for (
int ixsinc=0,idx=idx0; ixsinc<
lsinc_; ixsinc++,idx++ )
632 outx = 0.; sumx = 0.;
633 const float asincxval = asincx[ixsinc];
637 for (
int iysinc=0,idy=idy0; iysinc<
lsinc_; iysinc++,idy++ )
639 outy = 0.; sumy = 0.;
640 const float asincyval = asincy[iysinc];
644 for (
int izsinc=0,idz=idz0; izsinc<
lsinc_; izsinc++,idz++ )
650 outx += outy * asincyval;
653 out += asincxval * outx;
#define mExpClass(module)
Definition: commondefs.h:160
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
bool isOK() const
Definition: sincinterpolator.h:33
Kaiser Window Function.
Definition: windowfunction.h:107
Extrapolation
Definition: sincinterpolator.h:149
int nx_
Definition: sincinterpolator.h:196
int nx_
Definition: sincinterpolator.h:237
od_int64 getTableBytes() const
Definition: sincinterpolator.h:260
float getTableVal(int idx, int idy) const
Definition: sincinterpolator.h:263
static const float snapdist
Definition: sincinterpolator.h:169
int getLength() const
Definition: windowfunction.h:124
int nsincm1_
Definition: sincinterpolator.h:164
bool initTable(float fmax, int lmax)
Definition: sincinterpolator.h:328
float getValue(int idx, int idy) const
Definition: sincinterpolator.h:45
#define mIsZero(x, eps)
Definition: commondefs.h:53
bool isTableOK() const
Definition: sincinterpolator.h:248
bool initTable(float fmax, int lmax)
Definition: sincinterpolator.h:415
#define mCast(tp, v)
Definition: commondefs.h:124
int nx_
Definition: sincinterpolator.h:215
RT getValue(PT, PT) const
Definition: sincinterpolator.h:427
#define od_int64
Definition: plftypes.h:36
int ny_
Definition: sincinterpolator.h:238
ObjectSet< const Table > tables_
Definition: sincinterpolator.h:69
int lsinc_
Definition: sincinterpolator.h:59
int nym_
Definition: sincinterpolator.h:218
~Table()
Definition: sincinterpolator.h:31
SincInterpolator3D(const RT *data, int nx, int ny, int nz)
Definition: sincinterpolator.h:514
Mathematical function.
Definition: mathfunc.h:61
int getMaximumLength() const
Definition: sincinterpolator.h:257
bool initUndefTable(const RT *, od_int64 sz)
Definition: sincinterpolator.h:268
Definition: sincinterpolator.h:180
SincTableManager()
Definition: sincinterpolator.h:22
int ishift_
Definition: sincinterpolator.h:165
static void deleteArray(float **, int n1)
Definition: sincinterpolator.h:80
void deleteAndZeroArrPtr(T *&ptr, bool isowner=true)
Definition: ptrman.h:37
int nxm_
Definition: sincinterpolator.h:240
int lmax_
Definition: sincinterpolator.h:57
void setValue(int idx, int idy, float val)
Definition: sincinterpolator.h:43
int getMaximumLength() const
Definition: sincinterpolator.h:38
Definition: sincinterpolator.h:224
Set of pointers to objects.
Definition: commontypes.h:32
static float ** makeArray(int n1, int n2)
Definition: sincinterpolator.h:79
float getMaximumFrequency() const
Definition: sincinterpolator.h:254
int nzm_
Definition: sincinterpolator.h:242
#define mNINT32(x)
Definition: commondefs.h:45
float getMaximumError() const
Definition: sincinterpolator.h:251
SincInterpolator2D(const RT *, int nx, int ny)
Definition: sincinterpolator.h:403
A manager used for constructing the table necessary for Sinc interpolations. The manager creates one ...
Definition: sincinterpolator.h:19
Definition: geom2dascio.h:21
#define mAddVal(val, weight, totidx, outval)
Definition: sincinterpolator.h:344
float getMaximumError() const
Definition: sincinterpolator.h:36
#define mKSinc(frac)
Definition: sincinterpolator.h:337
virtual bool initTable(float fmax, int lmax)
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
bool isOK() const
Definition: sincinterpolator.h:207
bool * isudfarr_
Definition: sincinterpolator.h:162
A Math Function as in F(x,y,z).
Definition: mathfunc.h:122
int nz_
Definition: sincinterpolator.h:239
#define mTryAlloc(var, stmt)
Catches bad_alloc and sets ptr to null as normal.
Definition: commondefs.h:241
void setInput(const RT *, bool datahasnoudf=false)
Definition: sincinterpolator.h:306
#define mValidPos(is, ns)
Definition: sincinterpolator.h:338
const float ** asinc_
Definition: sincinterpolator.h:175
bool setSize(int)
Definition: sincinterpolator.h:317
int nxm_
Definition: sincinterpolator.h:217
#define mDefEps
Definition: commondefs.h:58
bool isOK() const
Definition: sincinterpolator.h:229
Threads::Mutex lock_
Definition: sincinterpolator.h:70
#define mDefEpsF
Definition: commondefs.h:56
A sinc interpolator for bandlimited uniformly-sampled functions y(x). Interpolators can be designed f...
Definition: sincinterpolator.h:134
A Math Function as in F(x,y).
Definition: mathfunc.h:105
int nym_
Definition: sincinterpolator.h:241
od_int64 getTableBytes() const
#define mGetOffset(idx, idy, idz)
Definition: sincinterpolator.h:541
bool extrapcst_
Definition: sincinterpolator.h:166
bool initTable(float fmax, int lmax)
Definition: sincinterpolator.h:528
bool isOK() const
Definition: sincinterpolator.h:188
int lsinc_
Definition: sincinterpolator.h:163
int nxm_
Definition: sincinterpolator.h:197
bool init()
Definition: sincinterpolator.h:155
Is a lock that allows a thread to have exlusive rights to something.
Definition: thread.h:43
SincInterpolator1D(const RT *=0, int sz=-1)
Definition: sincinterpolator.h:295
const RT * data_
Definition: sincinterpolator.h:195
RT getValue(PT, PT, PT) const
Definition: sincinterpolator.h:543
RT getValue(PT) const
Definition: sincinterpolator.h:357
Definition: sincinterpolator.h:26
int ny_
Definition: sincinterpolator.h:216
int nsinc_
Definition: sincinterpolator.h:58
Definition: sincinterpolator.h:202
#define mClass(module)
Definition: commondefs.h:164
SceneTransformManager & STM()
float ** asinc_
Definition: sincinterpolator.h:54
bool extrapzero_
Definition: sincinterpolator.h:167
const RT * data_
Definition: sincinterpolator.h:236
float fmax_
Definition: sincinterpolator.h:56
float emax_
Definition: sincinterpolator.h:55
const SincTableManager::Table * table_
Definition: sincinterpolator.h:174
float getMaximumFrequency() const
Definition: sincinterpolator.h:37
Array2DImpl< float > asinc2_
Definition: sincinterpolator.h:50
const RT * data_
Definition: sincinterpolator.h:214
#define mAddValW(val, totidx, weight, outval, sumweights)
Definition: sincinterpolator.h:349