FieldInterp.h File Reference
Fields

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< 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

| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicFieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicGenericFieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (CubicMACFieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (FieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearFieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearGenericFieldInterp)
| FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION (LinearMACFieldInterp)
| 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>
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() [1/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | FieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [2/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | LinearFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [3/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | CubicFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [4/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | LinearGenericFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [5/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | LinearMACFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [6/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | CubicGenericFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [7/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | CubicMACFieldInterp |  | ) |

## FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION() [8/8]

FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION | ( | ProceduralFieldLookup |  | ) |

## wsSample()

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.

{
V3d vsP;
f->mapping()->worldToVoxel(wsP, vsP);
return interp.sample(*f, vsP);
}
V3d
Imath::V3d V3d
Definition SpiMathLib.h:74
FieldInterp::sample
virtual Data_T sample(const Field< Data_T > &data, const V3d &vsP) const =0

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

## isPointInField()

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);
}

## isLegalVoxelCoord()

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);
}

## operator*()

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.

Definition at line 1558 of file FieldInterp.h.

{
return FIELD3D_VEC3_T<T>(vec.x * s, vec.y * s, vec.z * s);
}
FIELD3D_VEC3_T
#define FIELD3D_VEC3_T
Definition SpiMathLib.h:88

References FIELD3D_VEC3_T.

## monotonicCubicInterpolant() [1/2]

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.

Referenced by CubicFieldInterp< Data_T >::sample(), CubicGenericFieldInterp< Field_T >::sample(), and CubicMACFieldInterp< Data_T >::sample().

## monotonicCubicInterpolantVec()

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.

{
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;
}

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

## monotonicCubicInterpolant() [2/2]

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;
}

## monotonicCubicInterpolant< V3h >()

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.

{
return monotonicCubicInterpolantVec(f1, f2, f3, f4, t);
}
monotonicCubicInterpolantVec
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_...
Definition FieldInterp.h:1597

References monotonicCubicInterpolantVec().

## monotonicCubicInterpolant< V3f >()

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.

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

References monotonicCubicInterpolantVec().

## monotonicCubicInterpolant< V3d >()

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.

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

References monotonicCubicInterpolantVec().