Field3D
Sparse::SparseBlock< Data_T > Class Template Reference

Storage for one individual block of a SparseField. More...

#include <SparseField.h>

List of all members.

Public Member Functions

void clear ()
 Remove data.
Data_T & dataRef ()
 Returns reference to start of memory.
void resize (int n)
 Alloc data.
 SparseBlock ()
 Ctor.
const Data_T & value (int i, int j, int k, int blockOrder) const
 Gets the const value of a given voxel.
Data_T & value (int i, int j, int k, int blockOrder)
 Gets the value of a given voxel.

Public Attributes

std::vector< Data_T > data
 Container for this block's data. It's either size 0 or size m_blockSize^3.
Data_T emptyValue
 The value to use if the block isn't allocated. We allow setting this per block so that we for example can have different inside/outside values when storing narrow-band levelsets.
bool isAllocated
 Whether the block is allocated or not.

Detailed Description

template<typename Data_T>
class Sparse::SparseBlock< Data_T >

Storage for one individual block of a SparseField.

Definition at line 85 of file SparseField.h.


Constructor & Destructor Documentation

template<typename Data_T>
Sparse::SparseBlock< Data_T >::SparseBlock ( ) [inline]

Ctor.

Definition at line 90 of file SparseField.h.

    : isAllocated(false),
      emptyValue(static_cast<Data_T>(0))
  { /* Empty */ }

Member Function Documentation

template<typename Data_T>
Data_T& Sparse::SparseBlock< Data_T >::value ( int  i,
int  j,
int  k,
int  blockOrder 
) [inline]

Gets the value of a given voxel.

Note:
Bit shift should be ok, indices are always positive.

Definition at line 98 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::data.

Referenced by SparseField< Data_T >::fastLValue(), SparseField< Data_T >::fastValue(), SparseField< Data_T >::const_iterator::operator*(), SparseField< Data_T >::const_iterator::operator->(), SparseField< Data_T >::iterator::setupNextBlock(), and SparseField< Data_T >::const_iterator::setupNextBlock().

  { return data[(k << blockOrder << blockOrder) + (j << blockOrder) + i]; }
template<typename Data_T>
const Data_T& Sparse::SparseBlock< Data_T >::value ( int  i,
int  j,
int  k,
int  blockOrder 
) const [inline]

Gets the const value of a given voxel.

Note:
Bit shift should be ok, indices are always positive.

Definition at line 104 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::data.

  { return data[(k << blockOrder << blockOrder) + (j << blockOrder) + i]; }
template<typename Data_T>
void Sparse::SparseBlock< Data_T >::resize ( int  n) [inline]

Alloc data.

Definition at line 108 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::data.

  { this->data.resize(n); }
template<typename Data_T>
void Sparse::SparseBlock< Data_T >::clear ( ) [inline]

Remove data.

Definition at line 112 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::data.

Referenced by SparseField< Data_T >::deallocBlock().

  { std::vector<Data_T>().swap(data); }
template<typename Data_T>
Data_T& Sparse::SparseBlock< Data_T >::dataRef ( ) [inline]

Returns reference to start of memory.

Definition at line 116 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::data.

  { return data[0]; }

Member Data Documentation

template<typename Data_T>
Data_T Sparse::SparseBlock< Data_T >::emptyValue

The value to use if the block isn't allocated. We allow setting this per block so that we for example can have different inside/outside values when storing narrow-band levelsets.

Definition at line 127 of file SparseField.h.

Referenced by SparseField< Data_T >::deallocBlock(), SparseField< Data_T >::fastLValue(), SparseField< Data_T >::fastValue(), SparseField< Data_T >::setBlockEmptyValue(), SparseField< Data_T >::iterator::setupNextBlock(), and SparseField< Data_T >::const_iterator::setupNextBlock().


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