Field3D
LinearSparseFieldInterp< Data_T > Class Template Reference

#include <SparseField.h>

Inheritance diagram for LinearSparseFieldInterp< Data_T >:
RefBase

Public Types

typedef LinearSparseFieldInterp class_type
 
typedef boost::intrusive_ptr< LinearSparseFieldInterpPtr
 
typedef Data_T value_type
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

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.
 
RefBaseoperator= (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 charstaticClassName ()
 
static const charstaticClassType ()
 
- Static Public Member Functions inherited from RefBase
static const charstaticClassType ()
 

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 >
static const char * LinearSparseFieldInterp< Data_T >::staticClassName ( )
inlinestatic

Definition at line 100 of file SparseField.h.

101 {
102 return "LinearSparseFieldInterp";
103 }

◆ staticClassType()

template<typename Data_T >
static const char * LinearSparseFieldInterp< Data_T >::staticClassType ( )
inlinestatic

Definition at line 105 of file SparseField.h.

106 {
107 return ms_classType.name();
108 }
static TemplatedFieldType< LinearSparseFieldInterp< Data_T > > ms_classType
const char * name()
Definition Traits.h:284

References LinearSparseFieldInterp< Data_T >::ms_classType, and TemplatedFieldType< Field_T >::name().

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

113 {
114 // Pixel centers are at .5 coordinates
115 // NOTE: Don't use contToDisc for this, we're looking for sample
116 // point locations, not coordinate shifts.
118
119 // Lower left corner
120 V3i c1(static_cast<int>(floor(p.x)),
121 static_cast<int>(floor(p.y)),
122 static_cast<int>(floor(p.z)));
123 // Upper right corner
124 V3i c2(c1 + V3i(1));
125 // C1 fractions
127 // C2 fraction
129
130 const Box3i &dataWindow = field.dataWindow();
131
132 // Clamp the coordinates
133 c1.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c1.x));
134 c1.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c1.y));
135 c1.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c1.z));
136 c2.x = std::min(dataWindow.max.x, std::max(dataWindow.min.x, c2.x));
137 c2.y = std::min(dataWindow.max.y, std::max(dataWindow.min.y, c2.y));
138 c2.z = std::min(dataWindow.max.z, std::max(dataWindow.min.z, c2.z));
139
140 // Determine which block we're in
141 int i = c1.x, j = c1.y, k = c1.z, vi, vj, vk, bi, bj, bk;
142 field.applyDataWindowOffset(i, j, k);
143 field.getVoxelInBlock(i, j, k, vi, vj, vk);
144 field.getBlockCoord(i, j, k, bi, bj, bk);
145 int blockSize = 1 << field.blockOrder();
146
147 // If in the middle of a block, optimize lookup stencil
148 if (vi < blockSize - 1 && vj < blockSize - 1 && vk < blockSize - 1) {
149 if (field.blockIsAllocated(bi, bj, bk)) {
150 // Ensure block data is active and kept alive
151 const int blockId = field.blockId(bi, bj, bk);
152 const bool isDynamicLoad = field.isDynamicLoad();
153 if (isDynamicLoad) {
154 field.incBlockRef(blockId);
155 field.activateBlock(blockId);
156 }
157 // Only do work if the block is allocated
158 const Data_T * const p = field.blockData(bi, bj, bk);
159 const Data_T * const c111 =
160 p + vi + vj * blockSize + vk * blockSize * blockSize;
161 const Data_T * const c121 = c111 + blockSize * (c2.y - c1.y);
162 const Data_T * const
163 c112 = c111 + blockSize * blockSize * (c2.z - c1.z);
164 const Data_T * const c122 = c112 + blockSize * (c2.y - c1.y);
165 int xInc = c2.x - c1.x;
166 Data_T value = static_cast<Data_T>
167 (f1.x * (f1.y * (f1.z * *c111 +
168 f2.z * *c112) +
169 f2.y * (f1.z * *c121 +
170 f2.z * *c122)) +
171 f2.x * (f1.y * (f1.z * *(c111 + xInc) +
172 f2.z * *(c112 + xInc)) +
173 f2.y * (f1.z * *(c121 + xInc) +
174 f2.z * *(c122 + xInc))));
175 // Decrement the block ref count
176 if (isDynamicLoad) {
177 field.decBlockRef(blockId);
178 }
179 // Done.
180 return value;
181 } else {
182 return static_cast<Data_T>(field.getBlockEmptyValue(bi, bj, bk));
183 }
184 } else {
185 return static_cast<Data_T>
186 (f1.x * (f1.y * (f1.z * field.fastValue(c1.x, c1.y, c1.z) +
187 f2.z * field.fastValue(c1.x, c1.y, c2.z)) +
188 f2.y * (f1.z * field.fastValue(c1.x, c2.y, c1.z) +
189 f2.z * field.fastValue(c1.x, c2.y, c2.z))) +
190 f2.x * (f1.y * (f1.z * field.fastValue(c2.x, c1.y, c1.z) +
191 f2.z * field.fastValue(c2.x, c1.y, c2.z)) +
192 f2.y * (f1.z * field.fastValue(c2.x, c2.y, c1.z) +
193 f2.z * field.fastValue(c2.x, c2.y, c2.z))));
194 }
195
196 }
Imath::V3i V3i
Definition SpiMathLib.h:71
Imath::Box3i Box3i
Definition SpiMathLib.h:77
#define FIELD3D_MTX_T
Definition StdMathLib.h:99
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition Field.h:253
bool isDynamicLoad() const
Whether the field is dynamically loaded.
void applyDataWindowOffset(int &i, int &j, int &k) const
Applies data window offset.
const Data_T getBlockEmptyValue(int bi, int bj, int bk) const
Returns the constant value of an block, whether it's allocated already or not..
Data_T * blockData(int bi, int bj, int bk) const
Returns a pointer to the data in a block, or null if the given block is unallocated.
bool blockIsAllocated(int bi, int bj, int bk) const
Checks if a block is allocated.
void decBlockRef(const int blockId) const
Decrements the block ref count for the given block.
Data_T fastValue(int i, int j, int k) const
Read access to voxel. Notice that this is non-virtual.
void activateBlock(const int blockId) const
Activates a given block.
int blockOrder() const
Returns the block order.
void getVoxelInBlock(int i, int j, int k, int &vi, int &vj, int &vk) const
Calculates the coordinates in a block for the given voxel index.
void getBlockCoord(int i, int j, int k, int &bi, int &bj, int &bk) const
Calculates the block coordinates that a given set of voxel coords are in.
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
void incBlockRef(const int blockId) const
Increments the block ref count for the given block.
FIELD3D_VEC3_T< T > floor(const FIELD3D_VEC3_T< T > &v)
Floor function for Vec3.
Definition CoordSys.h:104

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

Definition at line 202 of file SparseField.h.

Referenced by LinearSparseFieldInterp< Data_T >::staticClassType().


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