LinearSparseFieldInterp< Data_T > Class Template Reference

`#include <SparseField.h>`

Inheritance diagram for LinearSparseFieldInterp< Data_T >:

## Public Types

typedef LinearSparseFieldInterp | class_type
typedef boost::intrusive_ptr< LinearSparseFieldInterp > | Ptr
typedef Data_T | value_type
Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBase > | Ptr
typedef boost::weak_ptr< RefBase > | WeakPtr

## Public Member Functions

value_type | sample (const SparseField< Data_T > &field, const V3d &vsP) const
Public Member Functions inherited from RefBase
void | ref () const
| Used by boost::intrusive_pointer.
size_t | refcnt ()
| Used by boost::intrusive_pointer.
void | unref () const
| Used by boost::intrusive_pointer.
WeakPtr | weakPtr () const
| RefBase ()
| RefBase (const RefBase &)
| Copy constructor.
RefBase & | operator= (const RefBase &)
| Assignment operator.
virtual | ~RefBase ()
| Destructor.
virtual bool | checkRTTI (const char *typenameStr)=0
| This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
bool | matchRTTI (const char *typenameStr)
| Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones.

## Static Public Member Functions

static const char * | staticClassName ()
static const char * | staticClassType ()
static const char * | staticClassType ()

## Public Attributes

| DEFINE_FIELD_RTTI_CONCRETE_CLASS

## Private Types

typedef RefBase | base
| Convenience typedef for referring to base class.

## Static Private Attributes

static TemplatedFieldType< LinearSparseFieldInterp< Data_T > > | ms_classType

## Detailed Description

template<typename Data_T>
class LinearSparseFieldInterp< Data_T >

Definition at line 86 of file SparseField.h.

## Member Typedef Documentation

## value_type

template<typename Data_T>

typedef Data_T LinearSparseFieldInterp< Data_T >::value_type

Definition at line 92 of file SparseField.h.

## Ptr

template<typename Data_T>

typedef boost::intrusive_ptr<LinearSparseFieldInterp> LinearSparseFieldInterp< Data_T >::Ptr

Definition at line 93 of file SparseField.h.

## class_type

template<typename Data_T>

typedef LinearSparseFieldInterp LinearSparseFieldInterp< Data_T >::class_type

Definition at line 97 of file SparseField.h.

## base

template<typename Data_T>

typedef RefBase LinearSparseFieldInterp< Data_T >::base

private

Convenience typedef for referring to base class.

Definition at line 207 of file SparseField.h.

## Member Function Documentation

## staticClassName()

template<typename Data_T>

const char * LinearSparseFieldInterp< Data_T >::staticClassName | ( |  | ) |

inline static

Definition at line 100 of file SparseField.h.

{
return "LinearSparseFieldInterp";
}

## staticClassType()

template<typename Data_T>

const char * LinearSparseFieldInterp< Data_T >::staticClassType | ( |  | ) |

inline static

Definition at line 105 of file SparseField.h.

{
return ms_classType.name();
}
LinearSparseFieldInterp::ms_classType
static TemplatedFieldType< LinearSparseFieldInterp< Data_T > > ms_classType
Definition SparseField.h:202

References ms_classType.

## sample()

template<typename Data_T>

value_type LinearSparseFieldInterp< Data_T >::sample | ( | const SparseField< Data_T > & | field,
|  | const V3d & | vsP ) const

inline

Definition at line 112 of file SparseField.h.

{
// Pixel centers are at .5 coordinates
// NOTE: Don't use contToDisc for this, we're looking for sample
// point locations, not coordinate shifts.
FIELD3D_VEC3_T<double> p(vsP - FIELD3D_VEC3_T<double>(0.5));
// Lower left corner
V3i c1(static_cast<int>(floor(p.x)),
static_cast<int>(floor(p.y)),
static_cast<int>(floor(p.z)));
// Upper right corner
V3i c2(c1 + V3i(1));
// C1 fractions
FIELD3D_VEC3_T<double> f1(static_cast<FIELD3D_VEC3_T<double> >(c2) - p);
// C2 fraction
FIELD3D_VEC3_T<double> f2(static_cast<FIELD3D_VEC3_T<double> >(1.0) - f1);
const Box3i &dataWindow = field.dataWindow();
// Clamp the coordinates
c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
// Determine which block we're in
int i = c1.x, j = c1.y, k = c1.z, vi, vj, vk, bi, bj, bk;
field.applyDataWindowOffset(i, j, k);
field.getVoxelInBlock(i, j, k, vi, vj, vk);
field.getBlockCoord(i, j, k, bi, bj, bk);
int blockSize = 1 << field.blockOrder();
// If in the middle of a block, optimize lookup stencil
if (vi < blockSize - 1 && vj < blockSize - 1 && vk < blockSize - 1) {
if (field.blockIsAllocated(bi, bj, bk)) {
// Ensure block data is active and kept alive
const int blockId = field.blockId(bi, bj, bk);
const bool isDynamicLoad = field.isDynamicLoad();
if (isDynamicLoad) {
field.incBlockRef(blockId);
field.activateBlock(blockId);
}
// Only do work if the block is allocated
const Data_T * const p = field.blockData(bi, bj, bk);
const Data_T * const c111 =
p + vi + vj * blockSize + vk * blockSize * blockSize;
const Data_T * const c121 = c111 + blockSize * (c2.y - c1.y);
const Data_T * const
c112 = c111 + blockSize * blockSize * (c2.z - c1.z);
const Data_T * const c122 = c112 + blockSize * (c2.y - c1.y);
int xInc = c2.x - c1.x;
Data_T value = static_cast<Data_T>
(f1.x * (f1.y * (f1.z * *c111 +
f2.z * *c112) +
f2.y * (f1.z * *c121 +
f2.z * *c122)) +
f2.x * (f1.y * (f1.z * *(c111 + xInc) +
f2.z * *(c112 + xInc)) +
f2.y * (f1.z * *(c121 + xInc) +
f2.z * *(c122 + xInc))));
// Decrement the block ref count
if (isDynamicLoad) {
field.decBlockRef(blockId);
}
// Done.
return value;
} else {
return static_cast<Data_T>(field.getBlockEmptyValue(bi, bj, bk));
}
} else {
return static_cast<Data_T>
(f1.x * (f1.y * (f1.z * field.fastValue(c1.x, c1.y, c1.z) +
f2.z * field.fastValue(c1.x, c1.y, c2.z)) +
f2.y * (f1.z * field.fastValue(c1.x, c2.y, c1.z) +
f2.z * field.fastValue(c1.x, c2.y, c2.z))) +
f2.x * (f1.y * (f1.z * field.fastValue(c2.x, c1.y, c1.z) +
f2.z * field.fastValue(c2.x, c1.y, c2.z)) +
f2.y * (f1.z * field.fastValue(c2.x, c2.y, c1.z) +
f2.z * field.fastValue(c2.x, c2.y, c2.z))));
}
}
V3i
Imath::V3i V3i
Definition SpiMathLib.h:71
LinearSparseFieldInterp
Definition SparseField.h:87

References SparseField< Data_T >::activateBlock(), SparseField< Data_T >::applyDataWindowOffset(), SparseField< Data_T >::blockData(), SparseField< Data_T >::blockId(), SparseField< Data_T >::blockIsAllocated(), SparseField< Data_T >::blockOrder(), FieldRes::dataWindow(), SparseField< Data_T >::decBlockRef(), SparseField< Data_T >::fastValue(), FIELD3D_VEC3_T, SparseField< Data_T >::getBlockCoord(), SparseField< Data_T >::getBlockEmptyValue(), SparseField< Data_T >::getVoxelInBlock(), SparseField< Data_T >::incBlockRef(), and SparseField< Data_T >::isDynamicLoad().

## Member Data Documentation

## DEFINE_FIELD_RTTI_CONCRETE_CLASS

template<typename Data_T>

LinearSparseFieldInterp< Data_T >::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 98 of file SparseField.h.

## ms_classType

template<typename Data_T>

TemplatedFieldType<LinearSparseFieldInterp<Data_T> > LinearSparseFieldInterp< Data_T >::ms_classType

static private

Definition at line 202 of file SparseField.h.

Referenced by staticClassType().

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

- export/SparseField.h