MIPLinearInterp< MIPField_T > Class Template Reference

`#include <MIPInterp.h>`

Inheritance diagram for MIPLinearInterp< MIPField_T >:

## Classes

struct | InterpInfo

## Public Types

typedef MIPField_T::NestedType | FieldType
typedef FieldType::LinearInterp | LinearInterpType
typedef FieldType::value_type | value_type

## Public Member Functions

| MIPLinearInterp (const MIPField_T &mip)
| Must be constructed with a MIP field to operate on.
value_type | sample (const V3d &vsP, const float wsSpotSize) const
| Performs interpolation. A MIP field interpolation requires a spot size (which may be zero, forcing a lookup in the 0-level field).

## Private Member Functions

InterpInfo | interpInfo (const float wsSpotSize) const
| Computes between which levels to interpolate.

## Private Attributes

LinearInterpType | m_interp
| Linear interpolator.
const MIPField_T & | m_mip
| Const reference to MIP field.
std::vector< float > | m_wsVoxelSize
| Min world space voxel size for each MIP level.

## Detailed Description

template<typename MIPField_T>
class MIPLinearInterp< MIPField_T >

Definition at line 61 of file MIPInterp.h.

## Member Typedef Documentation

## FieldType

template<typename MIPField_T>

typedef MIPField_T::NestedType MIPLinearInterp< MIPField_T >::FieldType

Definition at line 67 of file MIPInterp.h.

## LinearInterpType

template<typename MIPField_T>

typedef FieldType::LinearInterp MIPLinearInterp< MIPField_T >::LinearInterpType

Definition at line 68 of file MIPInterp.h.

## value_type

template<typename MIPField_T>

typedef FieldType::value_type MIPLinearInterp< MIPField_T >::value_type

Definition at line 69 of file MIPInterp.h.

## Constructor & Destructor Documentation

## MIPLinearInterp()

template<typename MIPField_T>

MIPLinearInterp< MIPField_T >::MIPLinearInterp | ( | const MIPField_T & | mip | ) |

Must be constructed with a MIP field to operate on.

Definition at line 129 of file MIPInterp.h.

: m_mip(mip)
{
// Base voxel size (represents finest level)
const V3f wsVoxelSize = mip.mapping()->wsVoxelSize(0, 0, 0);
const float wsMinVoxelSize =
std::min(std::min(wsVoxelSize.x, wsVoxelSize.y), wsVoxelSize.z);
// All subsequent levels are a 2x mult on the base voxel size
for (size_t i = 0, end = mip.numLevels(); i < end; ++i) {
const float factor = std::pow(2.0f, static_cast<float>(i));
m_wsVoxelSize.push_back(wsMinVoxelSize * factor);
}
}
MIPLinearInterp
Definition MIPInterp.h:62
MIPLinearInterp::m_wsVoxelSize
std::vector< float > m_wsVoxelSize
Min world space voxel size for each MIP level.
Definition MIPInterp.h:118
MIPLinearInterp::m_mip
const MIPField_T & m_mip
Const reference to MIP field.
Definition MIPInterp.h:116

References m_mip, and m_wsVoxelSize.

## Member Function Documentation

## sample()

template<typename MIPField_T>

MIPLinearInterp< MIPField_T >::value_type MIPLinearInterp< MIPField_T >::sample | ( | const V3d & | vsP,
|  | const float | wsSpotSize ) const

Performs interpolation. A MIP field interpolation requires a spot size (which may be zero, forcing a lookup in the 0-level field).

Definition at line 147 of file MIPInterp.h.

{
const InterpInfo i = interpInfo(wsSpotSize);
if (i.lower == i.upper) {
// Special case where spot size is not in-between levels
if (i.lower == 0) {
// Special case for 0-level
return m_interp.sample(*m_mip.rawMipLevel(0), vsP);
} else {
// Not the 0-level, so we must transform vsP
V3f mipVsP;
m_mip.getVsMIPCoord(vsP, i.lower, mipVsP);
return m_interp.sample(*m_mip.rawMipLevel(i.lower), mipVsP);
}
} else {
// Quadrilinear interpolation
V3f mipVsP0, mipVsP1;
m_mip.getVsMIPCoord(V3f(vsP), i.lower, mipVsP0);
m_mip.getVsMIPCoord(V3f(vsP), i.upper, mipVsP1);
const value_type v0 = m_interp.sample(*m_mip.rawMipLevel(i.lower), mipVsP0);
const value_type v1 = m_interp.sample(*m_mip.rawMipLevel(i.upper), mipVsP1);
return FIELD3D_LERP(v0, v1, i.lerpT);
}
}
FIELD3D_LERP
#define FIELD3D_LERP
Definition SpiMathLib.h:91
V3f
Imath::V3f V3f
Definition SpiMathLib.h:73
MIPLinearInterp::m_interp
LinearInterpType m_interp
Linear interpolator.
Definition MIPInterp.h:120
MIPLinearInterp::value_type
FieldType::value_type value_type
Definition MIPInterp.h:69
MIPLinearInterp::interpInfo
InterpInfo interpInfo(const float wsSpotSize) const
Computes between which levels to interpolate.
Definition MIPInterp.h:178
MIPLinearInterp::InterpInfo
Definition MIPInterp.h:87

References FIELD3D_LERP, interpInfo(), MIPLinearInterp< MIPField_T >::InterpInfo::lerpT, MIPLinearInterp< MIPField_T >::InterpInfo::lower, m_interp, m_mip, and MIPLinearInterp< MIPField_T >::InterpInfo::upper.

## interpInfo()

template<typename MIPField_T>

MIPLinearInterp< MIPField_T >::InterpInfo MIPLinearInterp< MIPField_T >::interpInfo | ( | const float | wsSpotSize | ) | const

private

Computes between which levels to interpolate.

Definition at line 178 of file MIPInterp.h.

{
const size_t numLevels = m_mip.numLevels();
// First case, spot size smaller than first level
if (wsSpotSize <= m_wsVoxelSize[0]) {
return InterpInfo();
}
// Check in-between sizes
for (size_t i = 1, end = numLevels; i < end; ++i) {
if (wsSpotSize <= m_wsVoxelSize[i]) {
const float lerpT = FIELD3D_LERPFACTOR(wsSpotSize, m_wsVoxelSize[i - 1],
m_wsVoxelSize[i]);
return InterpInfo(i - 1, i, lerpT);
}
}
// Final case, spot size larger or equal to highest level
return InterpInfo(numLevels - 1, numLevels - 1, 0.0f);
}
FIELD3D_LERPFACTOR
#define FIELD3D_LERPFACTOR
Definition SpiMathLib.h:92

References FIELD3D_LERPFACTOR, m_mip, and m_wsVoxelSize.

Referenced by sample().

## Member Data Documentation

## m_mip

template<typename MIPField_T>

const MIPField_T& MIPLinearInterp< MIPField_T >::m_mip

private

Const reference to MIP field.

Definition at line 116 of file MIPInterp.h.

Referenced by interpInfo(), MIPLinearInterp(), and sample().

## m_wsVoxelSize

template<typename MIPField_T>

std::vector<float> MIPLinearInterp< MIPField_T >::m_wsVoxelSize

private

Min world space voxel size for each MIP level.

Definition at line 118 of file MIPInterp.h.

Referenced by interpInfo(), and MIPLinearInterp().

## m_interp

template<typename MIPField_T>

LinearInterpType MIPLinearInterp< MIPField_T >::m_interp

private

Linear interpolator.

Definition at line 120 of file MIPInterp.h.

Referenced by sample().

The documentation for this class was generated from the following file:

- export/MIPInterp.h