Field3D
FieldInterp.h File Reference
#include "Field.h"
#include "DenseField.h"
#include "MACField.h"
#include "ProceduralField.h"
#include "RefCount.h"
#include "ns.h"

Go to the source code of this file.

Classes

class  CubicFieldInterp< Data_T >
class  CubicGenericFieldInterp< Field_T >
class  CubicMACFieldInterp< Data_T >
class  FieldInterp< Data_T >
 Base class for interpolators. More...
class  LinearFieldInterp< Data_T >
class  LinearGenericFieldInterp< Field_T >
class  LinearMACFieldInterp< Data_T >
class  ProceduralFieldLookup< Data_T >

Functions

bool isLegalVoxelCoord (const V3d &vsP, const Box3d &vsDataWindow)
 Checks whether the floating - point voxel coordinate is within the given (floating point) data window.
bool isPointInField (const FieldRes::Ptr f, const V3d &wsP)
 Checks whether the point is within the given field.
template<class Data_T >
Data_T monotonicCubicInterpolant (const Data_T &f1, const Data_T &f2, const Data_T &f3, const Data_T &f4, double t)
 Monotonic cubic interpolation References: http://en.wikipedia.org/wiki/Monotone_cubic_interpolation http://en.wikipedia.org/wiki/Cubic_Hermite_spline.
template<class T >
monotonicCubicInterpolant (const T &f1, const T &f2, const T &f3, const T &f4, double t)
template<>
V3d monotonicCubicInterpolant< V3d > (const V3d &f1, const V3d &f2, const V3d &f3, const V3d &f4, double t)
template<>
V3f monotonicCubicInterpolant< V3f > (const V3f &f1, const V3f &f2, const V3f &f3, const V3f &f4, double t)
template<>
V3h monotonicCubicInterpolant< V3h > (const V3h &f1, const V3h &f2, const V3h &f3, const V3h &f4, double t)
template<class Data_T >
Data_T monotonicCubicInterpolantVec (const Data_T &f1, const Data_T &f2, const Data_T &f3, const Data_T &f4, double t)
 Monotonic cubic interpolation on 3 - vectors References: http://en.wikipedia.org/wiki/Monotone_cubic_interpolation http://en.wikipedia.org/wiki/Cubic_Hermite_spline.
template<class S , class T >
FIELD3D_VEC3_T< T > operator* (S s, const FIELD3D_VEC3_T< T > vec)
 Scalar times Vec3 multiplication. Makes the interpolation calls cleaner.
template<class Data_T >
Data_T wsSample (const typename Field< Data_T >::Ptr f, const FieldInterp< Data_T > &interp, const V3d &wsP)
 Helper function for interpolating in world space.

Function Documentation

template<class Data_T >
Data_T wsSample ( const typename Field< Data_T >::Ptr  f,
const FieldInterp< Data_T > &  interp,
const V3d wsP 
)

Helper function for interpolating in world space.

Definition at line 223 of file FieldInterp.h.

References FieldRes::mapping(), and FieldInterp< Data_T >::sample().

{
  V3d vsP;
  f->mapping()->worldToVoxel(wsP, vsP);
  return interp.sample(*f, vsP);
}
bool isPointInField ( const FieldRes::Ptr  f,
const V3d wsP 
)

Checks whether the point is within the given field.

Definition at line 52 of file FieldInterp.cpp.

{
  V3d lsP;
  f->mapping()->worldToLocal(wsP, lsP);
  return (lsP.x > 0.0 && lsP.x <= 1.0 && 
          lsP.y > 0.0 && lsP.y <= 1.0 && 
          lsP.z > 0.0 && lsP.z <= 1.0);
}
bool isLegalVoxelCoord ( const V3d vsP,
const Box3d vsDataWindow 
)

Checks whether the floating - point voxel coordinate is within the given (floating point) data window.

Definition at line 63 of file FieldInterp.cpp.

{
  return vsP.x > (vsDataWindow.min.x) && 
    vsP.x < (vsDataWindow.max.x) &&
    vsP.y > (vsDataWindow.min.y) && 
    vsP.y < (vsDataWindow.max.y) &&
    vsP.z > (vsDataWindow.min.z) && 
    vsP.z < (vsDataWindow.max.z);
}
template<class S , class T >
FIELD3D_VEC3_T<T> operator* ( s,
const FIELD3D_VEC3_T< T >  vec 
)

Scalar times Vec3 multiplication. Makes the interpolation calls cleaner.

template<class Data_T >
Data_T monotonicCubicInterpolant ( const Data_T &  f1,
const Data_T &  f2,
const Data_T &  f3,
const Data_T &  f4,
double  t 
)
template<class Data_T >
Data_T monotonicCubicInterpolantVec ( const Data_T &  f1,
const Data_T &  f2,
const Data_T &  f3,
const Data_T &  f4,
double  t 
)

Monotonic cubic interpolation on 3 - vectors References: http://en.wikipedia.org/wiki/Monotone_cubic_interpolation http://en.wikipedia.org/wiki/Cubic_Hermite_spline.

Monotonic cubic interpolation on 3-vectors.

template<class T >
T monotonicCubicInterpolant ( const T &  f1,
const T &  f2,
const T &  f3,
const T &  f4,
double  t 
)

Definition at line 1102 of file FieldInterp.h.

{
  T d_k = T(.5) * (f3 - f1);
  T d_k1 = T(.5) * (f4 - f2);
  T delta_k = f3 - f2;

  if (delta_k == static_cast<T>(0)) {
    d_k = static_cast<T>(0);
    d_k1 = static_cast<T>(0);
  }

  T a0 = f2;
  T a1 = d_k;
  T a2 = (T(3) * delta_k) - (T(2) * d_k) - d_k1;
  T a3 = d_k + d_k1 - (T(2) * delta_k);

  T t1 = t;
  T t2 = t1 * t1;
  T t3 = t2 * t1;

  return a3 * t3 + a2 * t2 + a1 * t1 + a0;
}
template<>
V3h monotonicCubicInterpolant< V3h > ( const V3h f1,
const V3h f2,
const V3h f3,
const V3h f4,
double  t 
) [inline]

Definition at line 1168 of file FieldInterp.h.

References monotonicCubicInterpolantVec().

{
  return monotonicCubicInterpolantVec(f1, f2, f3, f4, t);
}
template<>
V3f monotonicCubicInterpolant< V3f > ( const V3f f1,
const V3f f2,
const V3f f3,
const V3f f4,
double  t 
) [inline]

Definition at line 1178 of file FieldInterp.h.

References monotonicCubicInterpolantVec().

{
  return monotonicCubicInterpolantVec(f1, f2, f3, f4, t);
}
template<>
V3d monotonicCubicInterpolant< V3d > ( const V3d f1,
const V3d f2,
const V3d f3,
const V3d f4,
double  t 
) [inline]

Definition at line 1188 of file FieldInterp.h.

References monotonicCubicInterpolantVec().

{
  return monotonicCubicInterpolantVec(f1, f2, f3, f4, t);
}