Field3D
FieldInterp.h File Reference

Contains the FieldInterp base class and some standard interpolation classes. More...

#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
class  CubicGenericFieldInterp
class  CubicMACFieldInterp
class  FieldInterp
 Base class for interpolators. More...
class  LinearFieldInterp
class  LinearGenericFieldInterp
class  LinearMACFieldInterp
class  ProceduralFieldLookup

Functions

 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (FieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearGenericFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearMACFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicGenericFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicMACFieldInterp)
 FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (ProceduralFieldLookup)
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.

Detailed Description

Contains the FieldInterp base class and some standard interpolation classes.

Definition in file FieldInterp.h.


Function Documentation

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( FieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( LinearFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( CubicFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( LinearGenericFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( LinearMACFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( CubicGenericFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( CubicMACFieldInterp  )
FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION ( ProceduralFieldLookup  )
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 546 of file FieldInterp.h.

References FieldRes::mapping(), and FieldInterp::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.

Definition at line 1558 of file FieldInterp.h.

{
  return FIELD3D_VEC3_T<T>(vec.x * s, vec.y * s, vec.z * s);
}
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.

Definition at line 1597 of file FieldInterp.h.

Referenced by monotonicCubicInterpolant< V3h >(), monotonicCubicInterpolant< V3f >(), and monotonicCubicInterpolant< V3d >().

{
  typedef typename Data_T::BaseType T;

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

  for (int i = 0; i < 3; i++) {
    if (delta_k[i] == static_cast<T>(0)) {
      d_k[i] = static_cast<T>(0);
      d_k1[i]= static_cast<T>(0);
    }
  }

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

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

  return a3 * t3 + a2 * t2 + a1 * t1 + a0;
}
template<class T >
T monotonicCubicInterpolant ( const T &  f1,
const T &  f2,
const T &  f3,
const T &  f4,
double  t 
)

Definition at line 1566 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 1632 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 1642 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 1652 of file FieldInterp.h.

References monotonicCubicInterpolantVec().

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