Field3D
SparseField< Data_T > Class Template Reference

This Field subclass stores voxel data in block-allocated arrays. More...

#include <SparseField.h>

Inheritance diagram for SparseField< Data_T >:
ResizableField< Data_T > WritableField< Data_T > Field< Data_T > FieldRes FieldBase RefBase

Classes

class  block_iterator
 
class  const_iterator
 
class  iterator
 

Public Types

typedef SparseField< Data_T > class_type
 
typedef CubicGenericFieldInterp< SparseField< Data_T > > CubicInterp
 
typedef LinearSparseFieldInterp< Data_T > LinearInterp
 
typedef boost::intrusive_ptr< SparseFieldPtr
 
typedef std::vector< PtrVec
 
- Public Types inherited from ResizableField< Data_T >
typedef ResizableField< Data_T > class_type
 
typedef boost::intrusive_ptr< ResizableFieldPtr
 
- Public Types inherited from WritableField< Data_T >
typedef WritableField< Data_T > class_type
 
typedef boost::intrusive_ptr< WritableFieldPtr
 
- Public Types inherited from Field< Data_T >
typedef Field< Data_T > class_type
 
typedef boost::intrusive_ptr< FieldPtr
 
typedef Data_T value_type
 Allows us to reference the template class. More...
 
typedef std::vector< PtrVec
 This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInputFile::readVectorLayers() will return its data in. More...
 
- Public Types inherited from FieldRes
typedef FieldRes class_type
 
typedef boost::intrusive_ptr< FieldResPtr
 
typedef std::vector< PtrVec
 
- Public Types inherited from FieldBase
typedef FieldBase class_type
 
typedef boost::intrusive_ptr< FieldBasePtr
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

Public Member Functions

void activateBlock (const int blockId) const
 Activates a given block. More...
 
void addReference (const std::string &filename, const std::string &layerPath, int valuesPerBlock, int occupiedBlocks)
 Internal function to create a Reference for the current field, for use in dynamic reading. More...
 
void applyDataWindowOffset (int &i, int &j, int &k) const
 Applies data window offset. More...
 
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. More...
 
int blockId (int blockI, int blockJ, int blockK) const
 Calculates the block number based on a block i,j,k index. More...
 
bool blockIndexIsValid (int bi, int bj, int bk) const
 Returns whether a block index is valid. More...
 
bool blockIsAllocated (int bi, int bj, int bk) const
 Checks if a block is allocated. More...
 
int blockOrder () const
 Returns the block order. More...
 
V3i blockRes () const
 Returns the resolution of the block array. More...
 
int blockSize () const
 Returns the block size. More...
 
virtual void clear (const Data_T &value)
 Clears all the voxels in the storage. More...
 
void decBlockRef (const int blockId) const
 Decrements the block ref count for the given block. More...
 
Data_T & fastLValue (int i, int j, int k)
 Write access to voxel. Notice that this is non-virtual. More...
 
Data_T fastValue (int i, int j, int k) const
 Read access to voxel. Notice that this is non-virtual. More...
 
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. More...
 
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.. More...
 
bool getGrainBounds (const size_t idx, Box3i &vsBounds) const
 Bounding box of the given 'grain'. More...
 
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. More...
 
void incBlockRef (const int blockId) const
 Increments the block ref count for the given block. More...
 
bool isDynamicLoad () const
 Whether the field is dynamically loaded. More...
 
size_t numGrains () const
 Number of 'grains' to use with threaded access. More...
 
template<typename Functor_T >
int releaseBlocks (Functor_T func)
 Releases any blocks that are deemed empty. This can be used to clean up after algorithms that write "zero" values to the buffer, as well as after any narrow band levelset algorithms. More...
 
void setBlockEmptyValue (int bi, int bj, int bk, const Data_T &val)
 Sets the constant value of an block. If the block is already allocated, it gets deallocated. More...
 
void setBlockOrder (int order)
 Sets the block order (i.e. the power-of-2 to use as block size. More...
 
void setupReferenceBlocks ()
 Internal function to setup the Reference's block pointers, for use with dynamic reading. More...
 
bool voxelIsInAllocatedBlock (int i, int j, int k) const
 Checks if a voxel is in an allocated block. More...
 
Constructors & destructor
 SparseField ()
 Constructs an empty buffer. More...
 
 SparseField (const SparseField &o)
 Copy constructor. More...
 
 ~SparseField ()
 Destructor. More...
 
SparseFieldoperator= (const SparseField &o)
 Assignment operator. For cache-managed fields, it creates a new file reference, and for non-managed fields, it copies the data. More...
 
From Field
virtual Data_T value (int i, int j, int k) const
 Read access to a voxel. The coordinates are in integer voxel space . More...
 
virtual long long int memSize () const
 Returns the memory usage (in bytes) More...
 
virtual size_t voxelCount () const
 Counts the number of voxels. For most fields, this is just the volume of the data window, but sparse data structures can override this to return a better value. More...
 
From WritableField
virtual Data_T & lvalue (int i, int j, int k)
 Write access to a voxel. The coordinates are global coordinates. More...
 
Iterators
const_iterator cbegin () const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard. More...
 
const_iterator cbegin (const Box3i &subset) const
 Const iterator to first element of specific subset. More...
 
const_iterator cend () const
 Const iterator pointing one element past the last valid one. More...
 
const_iterator cend (const Box3i &subset) const
 Const iterator pointing one element past the last valid one (for a subset) More...
 
iterator begin ()
 Iterator to first element. More...
 
iterator begin (const Box3i &subset)
 Iterator to first element of specific subset. More...
 
iterator end ()
 Iterator pointing one element past the last valid one. More...
 
iterator end (const Box3i &subset)
 Iterator pointing one element past the last valid one (for a subset) More...
 
block_iterator blockBegin () const
 
block_iterator blockEnd () const
 Const iterator pointing to element one past the last valid block. More...
 
- Public Member Functions inherited from ResizableField< Data_T >
void copyFrom (typename Field< Data_T >::Ptr other)
 Copies the data from another Field, also resizes. More...
 
template<class Data_T2 >
void copyFrom (typename Field< Data_T2 >::Ptr other)
 Copies the data from another Field of another template class, also resizes. More...
 
void matchDefinition (FieldRes::Ptr fieldToMatch)
 Sets up this field so that resolution and mapping matches the other. More...
 
void setSize (const V3i &size)
 Resizes the object. More...
 
void setSize (const Box3i &extents)
 Resizes the object. More...
 
void setSize (const Box3i &extents, const Box3i &dataWindow)
 Resizes the object. More...
 
void setSize (const V3i &size, int padding)
 Resizes the object with padding. More...
 
- Public Member Functions inherited from WritableField< Data_T >
iterator begin ()
 Iterator to first element. More...
 
iterator begin (const Box3i &subset)
 Iterator to first element of specific subset. More...
 
iterator end ()
 Iterator pointing one element past the last valid one. More...
 
iterator end (const Box3i &subset)
 Iterator pointing one element past the last valid one (for a subset) More...
 
- Public Member Functions inherited from Field< Data_T >
const_iterator cbegin () const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard. More...
 
const_iterator cbegin (const Box3i &subset) const
 Const iterator to first element of specific subset. More...
 
const_iterator cend () const
 Const iterator pointing one element past the last valid one. More...
 
const_iterator cend (const Box3i &subset) const
 Const iterator pointing one element past the last valid one (for a subset) More...
 
virtual std::string dataTypeString () const
 
virtual ~Field ()
 Dtor. More...
 
- Public Member Functions inherited from FieldRes
V3i const dataResolution () const
 
const Box3idataWindow () const
 Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field subclass. More...
 
const Box3iextents () const
 Returns the extents of the data. This signifies the relevant area that the data exists over. However, the data window (below) may be smaller than the extents, in which case it is only safe to call value() for those coordinate inside the data window. More...
 
 FieldRes ()
 This constructor ensures that we have a valid mapping at all times. More...
 
 FieldRes (const FieldRes &src)
 Base class copy constructor. More...
 
bool isInBounds (int i, int j, int k) const
 Returns true is the indicies are in bounds of the data window. More...
 
FieldMapping::Ptr mapping ()
 Returns a pointer to the mapping. More...
 
const FieldMapping::Ptr mapping () const
 Returns a pointer to the mapping. More...
 
virtual void mappingChanged ()
 Tells the subclass that the mapping changed. More...
 
void setMapping (FieldMapping::Ptr mapping)
 Sets the field's mapping. More...
 
- Public Member Functions inherited from FieldBase
 FieldBase ()
 Constructor. More...
 
 FieldBase (const FieldBase &)
 Copy Constructor. More...
 
virtual ~FieldBase ()
 Destructor. More...
 
virtual std::string className () const =0
 Returns the class name of the object. Used by the class pool and when writing the data to disk. More...
 
virtual std::string classType () const =0
 Returns the full class type string. More...
 
FieldMetadata< FieldBase > & metadata ()
 accessor to the m_metadata class More...
 
const FieldMetadata< FieldBase > & metadata () const
 Read only access to the m_metadata class. More...
 
virtual void metadataHasChanged (const std::string &)
 This function should implemented by concrete classes to get the callback when metadata changes. More...
 
void copyMetadata (const FieldBase &field)
 Copies the metadata from a second field. More...
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer. More...
 
size_t refcnt ()
 Used by boost::intrusive_pointer. More...
 
void unref () const
 Used by boost::intrusive_pointer. More...
 
WeakPtr weakPtr () const
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor. More...
 
RefBaseoperator= (const RefBase &)
 Assignment operator. More...
 
virtual ~RefBase ()
 Destructor. More...
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();. More...
 
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. More...
 

Static Public Member Functions

static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from ResizableField< Data_T >
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from WritableField< Data_T >
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from Field< Data_T >
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from FieldRes
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from FieldBase
static const char * staticClassName ()
 
static const char * staticClassType ()
 
- Static Public Member Functions inherited from RefBase
static const char * staticClassType ()
 

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
 
- Public Attributes inherited from ResizableField< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from WritableField< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from Field< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from FieldRes
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from FieldBase
std::string attribute
 Optional name of the attribute the field represents. More...
 
std::string name
 Optional name of the field. More...
 

Protected Types

typedef ResizableField< Data_T > base
 
typedef Sparse::SparseBlock< Data_T > Block
 
- Protected Types inherited from ResizableField< Data_T >
typedef WritableField< Data_T > base
 
- Protected Types inherited from FieldRes
typedef MatrixFieldMapping default_mapping
 

Protected Member Functions

virtual void sizeChanged ()
 Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes. More...
 
Convenience methods
void setupBlocks ()
 Initializes the block structure. Will clear any existing data. More...
 
void deallocBlock (Block &block, const Data_T &emptyValue)
 Deallocated the data of the given block and sets its empty value. More...
 

Protected Attributes

int m_blockOrder
 Block order (size = 2^blockOrder) More...
 
V3i m_blockRes
 Block array resolution. More...
 
Blockm_blocks
 Array of blocks. Not using std::vector since SparseBlock is noncopyable. More...
 
int m_blockXYSize
 Block array res.x * res.y. More...
 
Data_T m_dummy
 Dummy value used when needing to return but indicating a failed call. More...
 
int m_fileId
 File id. Used with m_fileManager if active. Otherwise -1. More...
 
SparseFileManagerm_fileManager
 Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use. More...
 
size_t m_numBlocks
 Number of blocks in field. More...
 
- Protected Attributes inherited from FieldRes
Box3i m_dataWindow
 Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval. More...
 
Box3i m_extents
 Defines the extents of the the storage. This may be larger or smaller than the data window, and in the case where it is larger, care must be taken not to access voxels outside the data window. This should be treated as a closed (i.e. inclusive) interval. More...
 
FieldMapping::Ptr m_mapping
 Pointer to the field's mapping. More...
 

Private Member Functions

void copyBlockStates (const SparseField< Data_T > &o)
 Internal function to copy empty values and allocated flags, without copying data, used when copying a dynamically read field. More...
 
void copySparseField (const SparseField &o)
 Copies internal data, including blocks, from another SparseField, used by copy constructor and operator=. More...
 

Static Private Attributes

static TemplatedFieldType< SparseField< Data_T > > ms_classType
 

Friends

class SparseFieldIO
 

From FieldBase

 FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
 
virtual FieldBase::Ptr clone () const
 Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from ResizableField< Data_T >
static TemplatedFieldType< ResizableField< Data_T > > ms_classType
 

Detailed Description

template<class Data_T>
class SparseField< Data_T >

This Field subclass stores voxel data in block-allocated arrays.

Empty blocks aren't allocated. This effectively optimizes away memory use for "empty" voxels.

Refer to using_fields for examples of how to use this in your code.

Todo:
Make this class thread safe!

Definition at line 350 of file SparseField.h.

Member Typedef Documentation

template<class Data_T>
typedef boost::intrusive_ptr<SparseField> SparseField< Data_T >::Ptr

Definition at line 357 of file SparseField.h.

template<class Data_T>
typedef std::vector<Ptr> SparseField< Data_T >::Vec

Definition at line 358 of file SparseField.h.

template<class Data_T>
typedef LinearSparseFieldInterp<Data_T> SparseField< Data_T >::LinearInterp

Definition at line 360 of file SparseField.h.

template<class Data_T>
typedef CubicGenericFieldInterp<SparseField<Data_T> > SparseField< Data_T >::CubicInterp

Definition at line 361 of file SparseField.h.

template<class Data_T>
typedef SparseField<Data_T> SparseField< Data_T >::class_type

Definition at line 365 of file SparseField.h.

template<class Data_T>
typedef ResizableField<Data_T> SparseField< Data_T >::base
protected

Definition at line 582 of file SparseField.h.

template<class Data_T>
typedef Sparse::SparseBlock<Data_T> SparseField< Data_T >::Block
protected

Definition at line 583 of file SparseField.h.

Constructor & Destructor Documentation

template<class Data_T >
SparseField< Data_T >::SparseField ( )

Constructs an empty buffer.

Definition at line 1274 of file SparseField.h.

References SparseField< Data_T >::setupBlocks().

1275  : base(),
1277  m_blocks(NULL),
1278  m_fileManager(NULL)
1279 {
1280  setupBlocks();
1281 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
#define BLOCK_ORDER
Definition: SparseField.h:57
void setupBlocks()
Initializes the block structure. Will clear any existing data.
Definition: SparseField.h:1828
ResizableField< Data_T > base
Definition: SparseField.h:582
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
SparseField< Data_T >::SparseField ( const SparseField< Data_T > &  o)

Copy constructor.

Definition at line 1286 of file SparseField.h.

References SparseField< Data_T >::copySparseField().

1287  : base(o),
1289  m_blocks(NULL),
1291 {
1292  copySparseField(o);
1293 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
void copySparseField(const SparseField &o)
Copies internal data, including blocks, from another SparseField, used by copy constructor and operat...
Definition: SparseField.h:1328
ResizableField< Data_T > base
Definition: SparseField.h:582
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
SparseField< Data_T >::~SparseField ( )

Destructor.

Definition at line 1298 of file SparseField.h.

References SparseField< Data_T >::m_blocks, SparseField< Data_T >::m_fileId, SparseField< Data_T >::m_fileManager, and SparseFileManager::removeFieldFromCache().

1299 {
1300  if (m_fileManager) {
1301  // this file is dynamically managed, so we need to ensure the
1302  // cache doesn't point to this field's blocks because they are
1303  // about to be deleted
1305  }
1306  if (m_blocks) {
1307  delete[] m_blocks;
1308  }
1309 }
void removeFieldFromCache(int refIdx)
Definition: SparseFile.h:1152
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616

Member Function Documentation

template<class Data_T>
static const char* SparseField< Data_T >::staticClassName ( )
inlinestatic

Definition at line 368 of file SparseField.h.

369  {
370  return "SparseField";
371  }
template<class Data_T>
static const char* SparseField< Data_T >::staticClassType ( )
inlinestatic

Definition at line 373 of file SparseField.h.

References FieldBase::name, and RefBase::operator=().

374  {
376  }
This Field subclass stores voxel data in block-allocated arrays.
Definition: SparseField.h:350
std::string name
Optional name of the field.
Definition: Field.h:176
template<class Data_T >
SparseField< Data_T > & SparseField< Data_T >::operator= ( const SparseField< Data_T > &  o)

Assignment operator. For cache-managed fields, it creates a new file reference, and for non-managed fields, it copies the data.

Definition at line 1315 of file SparseField.h.

References SparseField< Data_T >::copySparseField(), and RefBase::operator=().

1316 {
1317  if (this != &o) {
1318  this->base::operator=(o);
1319  copySparseField(o);
1320  }
1321  return *this;
1322 }
RefBase & operator=(const RefBase &)
Assignment operator.
Definition: RefCount.h:134
void copySparseField(const SparseField &o)
Copies internal data, including blocks, from another SparseField, used by copy constructor and operat...
Definition: SparseField.h:1328
template<class Data_T >
void SparseField< Data_T >::clear ( const Data_T &  value)
virtual

Clears all the voxels in the storage.

Reimplemented from WritableField< Data_T >.

Definition at line 1422 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::emptyValue, SparseField< Data_T >::end(), SparseField< Data_T >::m_blocks, SparseField< Data_T >::m_numBlocks, SparseField< Data_T >::setupBlocks(), and SparseField< Data_T >::value().

1423 {
1424  // If we're clearing, we can get rid of all current blocks
1425  setupBlocks();
1426  Block *p = m_blocks, *end = m_blocks + m_numBlocks;
1427  while (p != end) {
1428  p->emptyValue = value;
1429  ++p;
1430  }
1431 }
iterator end()
Iterator pointing one element past the last valid one.
Definition: SparseField.h:1784
virtual Data_T value(int i, int j, int k) const
Read access to a voxel. The coordinates are in integer voxel space .
Definition: SparseField.h:1568
void setupBlocks()
Initializes the block structure. Will clear any existing data.
Definition: SparseField.h:1828
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
void SparseField< Data_T >::setBlockOrder ( int  order)

Sets the block order (i.e. the power-of-2 to use as block size.

Note
This will clear out any existing data.

Definition at line 1436 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder, and SparseField< Data_T >::setupBlocks().

Referenced by SparseFieldIO::read().

1437 {
1438  m_blockOrder = order;
1439  setupBlocks();
1440 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
void setupBlocks()
Initializes the block structure. Will clear any existing data.
Definition: SparseField.h:1828
template<class Data_T >
int SparseField< Data_T >::blockOrder ( ) const

Returns the block order.

Definition at line 1445 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

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

1446 {
1447  return m_blockOrder;
1448 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
template<class Data_T >
int SparseField< Data_T >::blockSize ( ) const

Returns the block size.

Definition at line 1453 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

Referenced by SparseField< Data_T >::fastLValue(), SparseField< Data_T >::memSize(), SparseField< Data_T >::releaseBlocks(), detail::threadingBlockSize(), and SparseField< Data_T >::voxelCount().

1454 {
1455  return 1 << m_blockOrder;
1456 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
template<class Data_T >
bool SparseField< Data_T >::voxelIsInAllocatedBlock ( int  i,
int  j,
int  k 
) const

Checks if a voxel is in an allocated block.

Definition at line 1461 of file SparseField.h.

References SparseField< Data_T >::applyDataWindowOffset(), SparseField< Data_T >::blockIsAllocated(), and SparseField< Data_T >::getBlockCoord().

1462 {
1463  int bi, bj, bk;
1464  applyDataWindowOffset(i, j, k);
1465  getBlockCoord(i, j, k, bi, bj, bk);
1466  return blockIsAllocated(bi, bj, bk);
1467 }
void applyDataWindowOffset(int &i, int &j, int &k) const
Applies data window offset.
Definition: SparseField.h:455
bool blockIsAllocated(int bi, int bj, int bk) const
Checks if a block is allocated.
Definition: SparseField.h:1472
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.
Definition: SparseField.h:1860
template<class Data_T >
bool SparseField< Data_T >::blockIsAllocated ( int  bi,
int  bj,
int  bk 
) const

Checks if a block is allocated.

Definition at line 1472 of file SparseField.h.

References SparseField< Data_T >::blockId(), Sparse::SparseBlock< Data_T >::isAllocated, and SparseField< Data_T >::m_blocks.

Referenced by detail::checkInputEmpty(), LinearSparseFieldInterp< Data_T >::sample(), and SparseField< Data_T >::voxelIsInAllocatedBlock().

1473 {
1474  const Block &block = m_blocks[blockId(bi, bj, bk)];
1475  return block.isAllocated;
1476 }
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
bool isAllocated
Whether the block is allocated or not.
Definition: SparseField.h:303
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
const Data_T SparseField< Data_T >::getBlockEmptyValue ( int  bi,
int  bj,
int  bk 
) const

Returns the constant value of an block, whether it's allocated already or not..

Definition at line 1481 of file SparseField.h.

References SparseField< Data_T >::blockId(), Sparse::SparseBlock< Data_T >::emptyValue, and SparseField< Data_T >::m_blocks.

Referenced by detail::checkInputEmpty(), and LinearSparseFieldInterp< Data_T >::sample().

1482 {
1483  return m_blocks[blockId(bi, bj, bk)].emptyValue;
1484 }
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
Data_T emptyValue
The value to use if the block isn&#39;t allocated. We allow setting this per block so that we for example...
Definition: SparseField.h:308
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
void SparseField< Data_T >::setBlockEmptyValue ( int  bi,
int  bj,
int  bk,
const Data_T &  val 
)

Sets the constant value of an block. If the block is already allocated, it gets deallocated.

Definition at line 1489 of file SparseField.h.

References SparseField< Data_T >::blockId(), SparseField< Data_T >::deallocBlock(), Sparse::SparseBlock< Data_T >::emptyValue, Sparse::SparseBlock< Data_T >::isAllocated, and SparseField< Data_T >::m_blocks.

1491 {
1492  Block &block = m_blocks[blockId(bi, bj, bk)];
1493  if (block.isAllocated) {
1494  deallocBlock(block, val);
1495  } else {
1496  block.emptyValue = val;
1497  }
1498 }
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
void deallocBlock(Block &block, const Data_T &emptyValue)
Deallocated the data of the given block and sets its empty value.
Definition: SparseField.h:1940
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
bool SparseField< Data_T >::blockIndexIsValid ( int  bi,
int  bj,
int  bk 
) const

Returns whether a block index is valid.

Definition at line 1503 of file SparseField.h.

References SparseField< Data_T >::m_blockRes.

1504 {
1505  return bi >= 0 && bj >= 0 && bk >= 0 &&
1506  bi < m_blockRes.x && bj < m_blockRes.y && bk < m_blockRes.z;
1507 }
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
template<class Data_T >
V3i SparseField< Data_T >::blockRes ( ) const

Returns the resolution of the block array.

Definition at line 1512 of file SparseField.h.

References SparseField< Data_T >::m_blockRes.

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

1513 {
1514  return m_blockRes;
1515 }
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
template<class Data_T >
template<typename Functor_T >
int SparseField< Data_T >::releaseBlocks ( Functor_T  func)

Releases any blocks that are deemed empty. This can be used to clean up after algorithms that write "zero" values to the buffer, as well as after any narrow band levelset algorithms.

Parameters
funcA function object with the method "bool check(SparseBlock&)"
Returns
Number of released blocks

Definition at line 1521 of file SparseField.h.

References SparseField< Data_T >::blockSize(), FieldRes::dataResolution(), SparseField< Data_T >::deallocBlock(), SparseField< Data_T >::m_blockRes, SparseField< Data_T >::m_blocks, and SparseField< Data_T >::m_numBlocks.

1522 {
1523  Data_T emptyValue;
1524  int numDeallocs = 0;
1525 
1526  // If the block is on the edge of the field, it may have unused
1527  // voxels, with undefined values. We need to pass the range of
1528  // valid voxels into the check function, so it only looks at valid
1529  // voxels.
1530  V3i dataRes = FieldRes::dataResolution();
1531  V3i validSize;
1532  V3i blockAllocSize(blockSize());
1533 
1534  int bx = 0, by = 0, bz = 0;
1535  for (size_t i = 0; i < m_numBlocks; ++i, ++bx) {
1536  if (bx >= m_blockRes.x) {
1537  bx = 0;
1538  ++by;
1539  if (by >= m_blockRes.y) {
1540  by = 0;
1541  ++bz;
1542  }
1543  }
1544  validSize = blockAllocSize;
1545  if (bx == m_blockRes.x-1) {
1546  validSize.x = dataRes.x - bx * blockAllocSize.x;
1547  }
1548  if (by == m_blockRes.y-1) {
1549  validSize.y = dataRes.y - by * blockAllocSize.y;
1550  }
1551  if (bz == m_blockRes.z-1) {
1552  validSize.z = dataRes.z - bz * blockAllocSize.z;
1553  }
1554 
1555  if (m_blocks[i].isAllocated) {
1556  if (func.check(m_blocks[i], emptyValue, validSize, blockAllocSize)) {
1557  deallocBlock(m_blocks[i], emptyValue);
1558  numDeallocs++;
1559  }
1560  }
1561  }
1562  return numDeallocs;
1563 }
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i const dataResolution() const
Definition: Field.h:261
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
void deallocBlock(Block &block, const Data_T &emptyValue)
Deallocated the data of the given block and sets its empty value.
Definition: SparseField.h:1940
int blockSize() const
Returns the block size.
Definition: SparseField.h:1453
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
int SparseField< Data_T >::blockId ( int  blockI,
int  blockJ,
int  blockK 
) const
template<class Data_T >
void SparseField< Data_T >::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.

Note
The i,j,k coordinates are strictly positive, and refer to the coordinates of a voxel -after- the data window offset has been applied.
Bit shift should be ok, indices are always positive.

Definition at line 1860 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

Referenced by blockCoords(), SparseField< Data_T >::fastLValue(), SparseField< Data_T >::fastValue(), LinearSparseFieldInterp< Data_T >::sample(), and SparseField< Data_T >::voxelIsInAllocatedBlock().

1862 {
1863  assert(i >= 0);
1864  assert(j >= 0);
1865  assert(k >= 0);
1866  bi = i >> m_blockOrder;
1867  bj = j >> m_blockOrder;
1868  bk = k >> m_blockOrder;
1869 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
template<class Data_T >
void SparseField< Data_T >::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.

Note
The i,j,k coordinates are strictly positive, and refer to the coordinates of a voxel -after- the data window offset has been applied.
Bit shift should be ok, indices are always positive.

Definition at line 1875 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

Referenced by SparseField< Data_T >::fastLValue(), SparseField< Data_T >::fastValue(), and LinearSparseFieldInterp< Data_T >::sample().

1877 {
1878  assert(i >= 0);
1879  assert(j >= 0);
1880  assert(k >= 0);
1881  vi = i & ((1 << m_blockOrder) - 1);
1882  vj = j & ((1 << m_blockOrder) - 1);
1883  vk = k & ((1 << m_blockOrder) - 1);
1884 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
template<class Data_T>
void SparseField< Data_T >::applyDataWindowOffset ( int &  i,
int &  j,
int &  k 
) const
inline

Applies data window offset.

Definition at line 455 of file SparseField.h.

Referenced by SparseField< Data_T >::fastLValue(), SparseField< Data_T >::fastValue(), LinearSparseFieldInterp< Data_T >::sample(), and SparseField< Data_T >::voxelIsInAllocatedBlock().

456  {
457  i -= base::m_dataWindow.min.x;
458  j -= base::m_dataWindow.min.y;
459  k -= base::m_dataWindow.min.z;
460  }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
template<class Data_T>
bool SparseField< Data_T >::isDynamicLoad ( ) const
inline

Whether the field is dynamically loaded.

Definition at line 463 of file SparseField.h.

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

464  { return m_fileManager != NULL; }
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
template<class Data_T >
void SparseField< Data_T >::incBlockRef ( const int  blockId) const

Increments the block ref count for the given block.

Definition at line 1889 of file SparseField.h.

References SparseField< Data_T >::blockId(), SparseFileManager::incBlockRef(), SparseField< Data_T >::m_fileId, and SparseField< Data_T >::m_fileManager.

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

1890 {
1892 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
void incBlockRef(int fileId, int blockIdx)
Increments the usage reference count on the specified block, to prevent it from getting unloaded whil...
Definition: SparseFile.h:1242
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
template<class Data_T >
void SparseField< Data_T >::activateBlock ( const int  blockId) const

Activates a given block.

Definition at line 1897 of file SparseField.h.

References SparseFileManager::activateBlock(), SparseField< Data_T >::blockId(), SparseField< Data_T >::m_fileId, and SparseField< Data_T >::m_fileManager.

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

1898 {
1900 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
void activateBlock(int fileId, int blockIdx)
Called by SparseField when it&#39;s about to read from a block. This should not be called by the user...
Definition: SparseFile.h:1206
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
template<class Data_T >
void SparseField< Data_T >::decBlockRef ( const int  blockId) const

Decrements the block ref count for the given block.

Definition at line 1905 of file SparseField.h.

References SparseField< Data_T >::blockId(), SparseFileManager::decBlockRef(), SparseField< Data_T >::m_fileId, and SparseField< Data_T >::m_fileManager.

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

1906 {
1908 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
void decBlockRef(int fileId, int blockIdx)
Decrements the usage reference count on the specified block, after its value is no longer being used ...
Definition: SparseFile.h:1255
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
template<class Data_T >
size_t SparseField< Data_T >::numGrains ( ) const

Number of 'grains' to use with threaded access.

Definition at line 1913 of file SparseField.h.

References SparseField< Data_T >::m_numBlocks.

1914 {
1915  return m_numBlocks;
1916 }
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
template<class Data_T >
bool SparseField< Data_T >::getGrainBounds ( const size_t  idx,
Box3i vsBounds 
) const

Bounding box of the given 'grain'.

Returns
Whether the grain is contiguous in memory

Definition at line 1921 of file SparseField.h.

References clipBounds(), SparseField< Data_T >::end(), indexToCoord(), SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blockRes, and FieldRes::m_dataWindow.

1922 {
1923  // Block size
1924  const size_t blockSide = (1 << m_blockOrder);
1925  // Block coordinate
1926  const V3i bCoord = indexToCoord(idx, m_blockRes);
1927  // Block bbox
1928  const V3i start(bCoord * blockSide + base::m_dataWindow.min);
1929  const V3i end (start + Imath::V3i(blockSide - 1));
1930  // Bounds must be clipped against data window
1931  const Box3i unclipped(start, end);
1932  bounds = clipBounds(unclipped, base::m_dataWindow);
1933  // Whether it's a contiguous block
1934  return bounds == unclipped;
1935 }
Box3i clipBounds(const Box3i &bbox, const Box3i &bounds)
Definition: Field.h:1144
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
iterator end()
Iterator pointing one element past the last valid one.
Definition: SparseField.h:1784
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i indexToCoord(const size_t idx, const V3i &res)
Definition: Field.h:1186
template<class Data_T >
Data_T SparseField< Data_T >::value ( int  i,
int  j,
int  k 
) const
virtual

Read access to a voxel. The coordinates are in integer voxel space .

Note
Before the internal storage is accessed, the subclass must compute the data window coordinates by looking at Field::m_dataWindow.
Virtual functions are known not to play nice with threading. Therefor, concrete classes can implement (by convention) fastValue() as a non-virtual function.

Implements Field< Data_T >.

Definition at line 1568 of file SparseField.h.

References SparseField< Data_T >::fastValue().

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

1569 {
1570  return fastValue(i, j, k);
1571 }
Data_T fastValue(int i, int j, int k) const
Read access to voxel. Notice that this is non-virtual.
Definition: SparseField.h:1584
template<class Data_T >
long long int SparseField< Data_T >::memSize ( ) const
virtual

Returns the memory usage (in bytes)

Note
This needs to be re-implemented for any subclass that adds data members. Those classes should also call their superclass and add the combined memory use.

Reimplemented from FieldRes.

Definition at line 1678 of file SparseField.h.

References SparseField< Data_T >::blockSize(), SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blocks, and SparseField< Data_T >::m_numBlocks.

1679 {
1680  long long int blockSize = m_numBlocks * sizeof(Block);
1681  long long int dataSize = 0;
1682 
1683  for (size_t i = 0; i < m_numBlocks; ++i) {
1684  if (m_blocks[i].data) {
1685  dataSize += (1 << m_blockOrder << m_blockOrder << m_blockOrder) *
1686  sizeof(Data_T);
1687  }
1688  }
1689 
1690  return sizeof(*this) + dataSize + blockSize;
1691 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
int blockSize() const
Returns the block size.
Definition: SparseField.h:1453
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
size_t SparseField< Data_T >::voxelCount ( ) const
virtual

Counts the number of voxels. For most fields, this is just the volume of the data window, but sparse data structures can override this to return a better value.

Reimplemented from FieldRes.

Definition at line 1696 of file SparseField.h.

References SparseField< Data_T >::blockSize(), SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blocks, and SparseField< Data_T >::m_numBlocks.

1697 {
1698  size_t count = 0;
1699  const size_t blockSize = (1 << m_blockOrder << m_blockOrder << m_blockOrder);
1700 
1701  for (size_t i = 0; i < m_numBlocks; ++i) {
1702  if (m_blocks[i].isAllocated) {
1703  count += blockSize;
1704  }
1705  }
1706 
1707  return count;
1708 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
int blockSize() const
Returns the block size.
Definition: SparseField.h:1453
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
Data_T & SparseField< Data_T >::lvalue ( int  i,
int  j,
int  k 
)
virtual

Write access to a voxel. The coordinates are global coordinates.

Note
Before the internal storage is accessed, the subclass must compute the crop window coordinates by looking at Field::m_dataWindow.
This is named differently from the const value so that non-const objects still have a clear way of accessing data in a const way.
Virtual functions are known not to play nice with threading. Therefor, concrete classes can implement (by convention) fastLValue() as a non-virtual function.

Implements WritableField< Data_T >.

Definition at line 1576 of file SparseField.h.

References SparseField< Data_T >::fastLValue().

1577 {
1578  return fastLValue(i, j, k);
1579 }
Data_T & fastLValue(int i, int j, int k)
Write access to voxel. Notice that this is non-virtual.
Definition: SparseField.h:1623
template<class Data_T >
Data_T SparseField< Data_T >::fastValue ( int  i,
int  j,
int  k 
) const

Read access to voxel. Notice that this is non-virtual.

Definition at line 1584 of file SparseField.h.

References SparseFileManager::activateBlock(), SparseField< Data_T >::applyDataWindowOffset(), SparseField< Data_T >::blockId(), SparseFileManager::decBlockRef(), Sparse::SparseBlock< Data_T >::emptyValue, SparseField< Data_T >::getBlockCoord(), SparseField< Data_T >::getVoxelInBlock(), SparseFileManager::incBlockRef(), Sparse::SparseBlock< Data_T >::isAllocated, SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blocks, FieldRes::m_dataWindow, SparseField< Data_T >::m_fileId, SparseField< Data_T >::m_fileManager, and Sparse::SparseBlock< Data_T >::value().

Referenced by LinearSparseFieldInterp< Data_T >::sample(), and SparseField< Data_T >::value().

1585 {
1586  assert (i >= base::m_dataWindow.min.x);
1587  assert (i <= base::m_dataWindow.max.x);
1588  assert (j >= base::m_dataWindow.min.y);
1589  assert (j <= base::m_dataWindow.max.y);
1590  assert (k >= base::m_dataWindow.min.z);
1591  assert (k <= base::m_dataWindow.max.z);
1592  // Add crop window offset
1593  applyDataWindowOffset(i, j, k);
1594  // Find block coord
1595  int bi, bj, bk;
1596  getBlockCoord(i, j, k, bi, bj, bk);
1597  // Find coord in block
1598  int vi, vj, vk;
1599  getVoxelInBlock(i, j, k, vi, vj, vk);
1600  // Get the actual block
1601  int id = blockId(bi, bj, bk);
1602  const Block &block = m_blocks[id];
1603  // Check if block data is allocated
1604  if (block.isAllocated) {
1605  if (m_fileManager) {
1606  m_fileManager->incBlockRef<Data_T>(m_fileId, id);
1607  m_fileManager->activateBlock<Data_T>(m_fileId, id);
1608  Data_T tmpValue = block.value(vi, vj, vk, m_blockOrder);
1609  m_fileManager->decBlockRef<Data_T>(m_fileId, id);
1610  return tmpValue;
1611  } else {
1612  return block.value(vi, vj, vk, m_blockOrder);
1613  }
1614  } else {
1615  return block.emptyValue;
1616  }
1617 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
void activateBlock(int fileId, int blockIdx)
Called by SparseField when it&#39;s about to read from a block. This should not be called by the user...
Definition: SparseFile.h:1206
void applyDataWindowOffset(int &i, int &j, int &k) const
Applies data window offset.
Definition: SparseField.h:455
void incBlockRef(int fileId, int blockIdx)
Increments the usage reference count on the specified block, to prevent it from getting unloaded whil...
Definition: SparseFile.h:1242
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
void decBlockRef(int fileId, int blockIdx)
Decrements the usage reference count on the specified block, after its value is no longer being used ...
Definition: SparseFile.h:1255
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.
Definition: SparseField.h:1875
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.
Definition: SparseField.h:1860
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
Data_T & SparseField< Data_T >::fastLValue ( int  i,
int  j,
int  k 
)

Write access to voxel. Notice that this is non-virtual.

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

Definition at line 1623 of file SparseField.h.

References SparseField< Data_T >::applyDataWindowOffset(), SparseField< Data_T >::blockId(), SparseField< Data_T >::blockSize(), SparseField< Data_T >::getBlockCoord(), SparseField< Data_T >::getVoxelInBlock(), Sparse::SparseBlock< Data_T >::isAllocated, SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blocks, FieldRes::m_dataWindow, SparseField< Data_T >::m_dummy, SparseField< Data_T >::m_fileManager, Msg::print(), Sparse::SparseBlock< Data_T >::resize(), Msg::SevWarning, and Sparse::SparseBlock< Data_T >::value().

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

1624 {
1625  assert (i >= base::m_dataWindow.min.x);
1626  assert (i <= base::m_dataWindow.max.x);
1627  assert (j >= base::m_dataWindow.min.y);
1628  assert (j <= base::m_dataWindow.max.y);
1629  assert (k >= base::m_dataWindow.min.z);
1630  assert (k <= base::m_dataWindow.max.z);
1631 
1632  if (m_fileManager) {
1633  assert(false && "Called fastLValue() on a dynamic-read sparse field");
1634  Msg::print(Msg::SevWarning, "Called fastLValue() on a dynamic-read "
1635  "sparse field");
1636  return m_dummy;
1637  }
1638 
1639  // Add crop window offset
1640  applyDataWindowOffset(i, j, k);
1641  // Find block coord
1642  int bi, bj, bk;
1643  getBlockCoord(i, j, k, bi, bj, bk);
1644  // Find coord in block
1645  int vi, vj, vk;
1646  getVoxelInBlock(i, j, k, vi, vj, vk);
1647  // Get the actual block
1648  int id = blockId(bi, bj, bk);
1649  Block &block = m_blocks[id];
1650  // If block is allocated, return a reference to the data
1651  if (block.isAllocated) {
1652  return block.value(vi, vj, vk, m_blockOrder);
1653  } else {
1654  // ... Otherwise, allocate block
1655  size_t blockSize = 1 << m_blockOrder << m_blockOrder << m_blockOrder;
1656  block.resize(blockSize);
1657  return block.value(vi, vj, vk, m_blockOrder);
1658  }
1659 }
Data_T & value(int i, int j, int k, int blockOrder)
Gets the value of a given voxel.
Definition: SparseField.h:249
void applyDataWindowOffset(int &i, int &j, int &k) const
Applies data window offset.
Definition: SparseField.h:455
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity. ...
Definition: Log.cpp:66
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Data_T m_dummy
Dummy value used when needing to return but indicating a failed call.
Definition: SparseField.h:627
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.
Definition: SparseField.h:1875
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.
Definition: SparseField.h:1860
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
int blockSize() const
Returns the block size.
Definition: SparseField.h:1453
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
Data_T * SparseField< 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.

Definition at line 1664 of file SparseField.h.

References SparseField< Data_T >::blockId(), Sparse::SparseBlock< Data_T >::data, Sparse::SparseBlock< Data_T >::isAllocated, and SparseField< Data_T >::m_blocks.

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

1665 {
1666  int id = blockId(bi, bj, bk);
1667  const Block &block = m_blocks[id];
1668  if (block.isAllocated) {
1669  return block.data;
1670  } else {
1671  return NULL;
1672  }
1673 }
int blockId(int blockI, int blockJ, int blockK) const
Calculates the block number based on a block i,j,k index.
Definition: SparseField.h:1851
Data_T * data
Pointer to data. Null if block is unallocated.
Definition: SparseField.h:311
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T>
virtual FieldBase::Ptr SparseField< Data_T >::clone ( ) const
inlinevirtual

Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it.

Implements FieldBase.

Definition at line 517 of file SparseField.h.

518  { return Ptr(new SparseField(*this)); }
boost::intrusive_ptr< SparseField > Ptr
Definition: SparseField.h:357
SparseField()
Constructs an empty buffer.
Definition: SparseField.h:1274
template<class Data_T >
SparseField< Data_T >::const_iterator SparseField< Data_T >::cbegin ( ) const

Const iterator to first element. "cbegin" matches the tr1 c++ standard.

Definition at line 1714 of file SparseField.h.

References SparseField< Data_T >::cend(), FieldRes::dataResolution(), SparseField< Data_T >::m_blockOrder, and FieldRes::m_dataWindow.

1715 {
1716  if (FieldRes::dataResolution() == V3i(0))
1717  return cend();
1718  return const_iterator(*this, base::m_dataWindow, base::m_dataWindow.min,
1719  m_blockOrder);
1720 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i const dataResolution() const
Definition: Field.h:261
const_iterator cend() const
Const iterator pointing one element past the last valid one.
Definition: SparseField.h:1737
template<class Data_T >
SparseField< Data_T >::const_iterator SparseField< Data_T >::cbegin ( const Box3i subset) const

Const iterator to first element of specific subset.

Definition at line 1726 of file SparseField.h.

References SparseField< Data_T >::cend(), and SparseField< Data_T >::m_blockOrder.

1727 {
1728  if (subset.isEmpty())
1729  return cend(subset);
1730  return const_iterator(*this, subset, subset.min, m_blockOrder);
1731 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
const_iterator cend() const
Const iterator pointing one element past the last valid one.
Definition: SparseField.h:1737
template<class Data_T >
SparseField< Data_T >::const_iterator SparseField< Data_T >::cend ( ) const

Const iterator pointing one element past the last valid one.

Definition at line 1737 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder, and FieldRes::m_dataWindow.

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

1738 {
1739  return const_iterator(*this, base::m_dataWindow,
1740  V3i(base::m_dataWindow.min.x,
1741  base::m_dataWindow.min.y,
1742  base::m_dataWindow.max.z + 1),
1743  m_blockOrder);
1744 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71
template<class Data_T >
SparseField< Data_T >::const_iterator SparseField< Data_T >::cend ( const Box3i subset) const

Const iterator pointing one element past the last valid one (for a subset)

Definition at line 1750 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

1751 {
1752  return const_iterator(*this, subset,
1753  V3i(subset.min.x,
1754  subset.min.y,
1755  subset.max.z + 1), m_blockOrder);
1756 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Imath::V3i V3i
Definition: SpiMathLib.h:71
template<class Data_T >
SparseField< Data_T >::iterator SparseField< Data_T >::begin ( )

Iterator to first element.

Definition at line 1762 of file SparseField.h.

References FieldRes::dataResolution(), SparseField< Data_T >::end(), SparseField< Data_T >::m_blockOrder, and FieldRes::m_dataWindow.

1763 {
1764  if (FieldRes::dataResolution() == V3i(0))
1765  return end();
1766  return iterator(*this, base::m_dataWindow,
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
iterator end()
Iterator pointing one element past the last valid one.
Definition: SparseField.h:1784
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i const dataResolution() const
Definition: Field.h:261
template<class Data_T >
SparseField< Data_T >::iterator SparseField< Data_T >::begin ( const Box3i subset)

Iterator to first element of specific subset.

Definition at line 1773 of file SparseField.h.

References SparseField< Data_T >::end(), and SparseField< Data_T >::m_blockOrder.

1774 {
1775  if (subset.isEmpty())
1776  return end(subset);
1777  return iterator(*this, subset, subset.min, m_blockOrder);
1778 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
iterator end()
Iterator pointing one element past the last valid one.
Definition: SparseField.h:1784
template<class Data_T >
SparseField< Data_T >::iterator SparseField< Data_T >::end ( )

Iterator pointing one element past the last valid one.

Definition at line 1784 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder, and FieldRes::m_dataWindow.

Referenced by SparseField< Data_T >::begin(), SparseField< Data_T >::clear(), and SparseField< Data_T >::getGrainBounds().

1785 {
1786  return iterator(*this, base::m_dataWindow,
1787  V3i(base::m_dataWindow.min.x,
1788  base::m_dataWindow.min.y,
1789  base::m_dataWindow.max.z + 1), m_blockOrder);
1790 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71
template<class Data_T >
SparseField< Data_T >::iterator SparseField< Data_T >::end ( const Box3i subset)

Iterator pointing one element past the last valid one (for a subset)

Definition at line 1796 of file SparseField.h.

References SparseField< Data_T >::m_blockOrder.

1797 {
1798  return iterator(*this, subset,
1799  V3i(subset.min.x, subset.min.y, subset.max.z + 1),
1800  m_blockOrder);
1801 }
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Imath::V3i V3i
Definition: SpiMathLib.h:71
template<class Data_T >
SparseField< Data_T >::block_iterator SparseField< Data_T >::blockBegin ( ) const

Definition at line 1807 of file SparseField.h.

References SparseField< Data_T >::blockEnd(), FieldRes::dataResolution(), and SparseField< Data_T >::m_blockRes.

1808 {
1809  if (FieldRes::dataResolution() == V3i(0))
1810  return blockEnd();
1811  return block_iterator(*this, Box3i(V3i(0), m_blockRes - V3i(1)),
1812  V3i(0));
1813 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i const dataResolution() const
Definition: Field.h:261
block_iterator blockEnd() const
Const iterator pointing to element one past the last valid block.
Definition: SparseField.h:1819
template<class Data_T >
SparseField< Data_T >::block_iterator SparseField< Data_T >::blockEnd ( ) const

Const iterator pointing to element one past the last valid block.

Definition at line 1819 of file SparseField.h.

References SparseField< Data_T >::m_blockRes.

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

1820 {
1821  return block_iterator(*this, Box3i(V3i(0), m_blockRes - V3i(1)),
1822  V3i(0, 0, m_blockRes.z));
1823 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
Imath::V3i V3i
Definition: SpiMathLib.h:71
template<class Data_T >
void SparseField< Data_T >::addReference ( const std::string &  filename,
const std::string &  layerPath,
int  valuesPerBlock,
int  occupiedBlocks 
)

Internal function to create a Reference for the current field, for use in dynamic reading.

Definition at line 1365 of file SparseField.h.

References SparseFileManager::getNextId(), SparseField< Data_T >::m_fileId, SparseField< Data_T >::m_fileManager, SparseField< Data_T >::m_numBlocks, SparseFileManager::reference(), and SparseFileManager::singleton().

Referenced by SparseField< Data_T >::copySparseField(), and SparseFieldIO::readData().

1369 {
1371  m_fileId = m_fileManager->getNextId<Data_T>(filename, layerPath);
1372  // Set up the manager data
1373  SparseFile::Reference<Data_T> *reference =
1374  m_fileManager->reference<Data_T>(m_fileId);
1375  reference->valuesPerBlock = valuesPerBlock;
1376  reference->occupiedBlocks = occupiedBlocks;
1377  reference->setNumBlocks(m_numBlocks);
1378 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
int getNextId(const std::string filename, const std::string layerPath)
Returns the id of the next cache item. This is stored in the SparseField in order to reference its fi...
Definition: SparseFile.h:1135
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
SparseFile::Reference< Data_T > * reference(int index)
Returns a reference to the Reference object with the given index.
Definition: SparseFile.h:1197
static SparseFileManager & singleton()
Returns a reference to the singleton instance.
Definition: SparseFile.cpp:63
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
template<class Data_T >
void SparseField< Data_T >::setupReferenceBlocks ( )

Internal function to setup the Reference's block pointers, for use with dynamic reading.

Definition at line 1397 of file SparseField.h.

References SparseFile::Reference< Data_T >::blocks, SparseFile::Reference< Data_T >::fileBlockIndices, SparseField< Data_T >::m_blocks, SparseField< Data_T >::m_fileId, SparseField< Data_T >::m_fileManager, SparseField< Data_T >::m_numBlocks, and SparseFileManager::reference().

Referenced by SparseField< Data_T >::copySparseField(), and SparseFieldIO::readData().

1398 {
1399  if (!m_fileManager || m_fileId < 0) return;
1400 
1401  SparseFile::Reference<Data_T> *reference =
1402  m_fileManager->reference<Data_T>(m_fileId);
1403 
1404  std::vector<int>::iterator fb = reference->fileBlockIndices.begin();
1406  reference->blocks.begin();
1407  int nextBlockIdx = 0;
1408  for (size_t i = 0; i < m_numBlocks; ++i, ++fb, ++bp) {
1409  if (m_blocks[i].isAllocated) {
1410  *fb = nextBlockIdx;
1411  *bp = m_blocks + i;
1412  nextBlockIdx++;
1413  } else {
1414  *fb = -1;
1415  }
1416  }
1417 }
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
std::vector< int > fileBlockIndices
Index in file for each block.
Definition: SparseFile.h:119
BlockPtrs blocks
Pointers to each block. This is so we can go in and manipulate them as we please. ...
Definition: SparseFile.h:125
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
SparseFile::Reference< Data_T > * reference(int index)
Returns a reference to the Reference object with the given index.
Definition: SparseFile.h:1197
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T>
virtual void SparseField< Data_T >::sizeChanged ( )
inlineprotectedvirtual

Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.

Note
Make sure to call the base class version in subclasses!

Reimplemented from ResizableField< Data_T >.

Definition at line 587 of file SparseField.h.

588  {
589  // Call base class
591  setupBlocks();
592  }
virtual void sizeChanged()
Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.
Definition: Field.h:906
void setupBlocks()
Initializes the block structure. Will clear any existing data.
Definition: SparseField.h:1828
template<class Data_T >
void SparseField< Data_T >::setupBlocks ( )
protected

Initializes the block structure. Will clear any existing data.

Definition at line 1828 of file SparseField.h.

References SparseField< Data_T >::blockRes(), detail::ceil(), SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blockRes, SparseField< Data_T >::m_blocks, SparseField< Data_T >::m_blockXYSize, FieldRes::m_dataWindow, and SparseField< Data_T >::m_numBlocks.

Referenced by SparseField< Data_T >::clear(), SparseField< Data_T >::copySparseField(), SparseField< Data_T >::setBlockOrder(), and SparseField< Data_T >::SparseField().

1829 {
1830  // Do calculation in floating point so we can round up later
1831  V3f res(base::m_dataWindow.size() + V3i(1));
1832  V3f blockRes(res / (1 << m_blockOrder));
1833  blockRes.x = ceil(blockRes.x);
1834  blockRes.y = ceil(blockRes.y);
1835  blockRes.z = ceil(blockRes.z);
1836  V3i intBlockRes(static_cast<int>(blockRes.x),
1837  static_cast<int>(blockRes.y),
1838  static_cast<int>(blockRes.z));
1839  m_blockRes = intBlockRes;
1841  if (m_blocks) {
1842  delete[] m_blocks;
1843  }
1844  m_numBlocks = intBlockRes.x * intBlockRes.y * intBlockRes.z;
1845  m_blocks = new Block[m_numBlocks];
1846 }
V3i blockRes() const
Returns the resolution of the block array.
Definition: SparseField.h:1512
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
int m_blockXYSize
Block array res.x * res.y.
Definition: SparseField.h:614
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
Imath::V3i V3i
Definition: SpiMathLib.h:71
Imath::V3f V3f
Definition: SpiMathLib.h:73
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
FIELD3D_VEC3_T< T > ceil(const FIELD3D_VEC3_T< T > &v)
Ceil function for Vec3.
Definition: CoordSys.h:105
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
void SparseField< Data_T >::deallocBlock ( Block block,
const Data_T &  emptyValue 
)
protected

Deallocated the data of the given block and sets its empty value.

Block::clear() deallocates the data

Definition at line 1940 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::clear(), Sparse::SparseBlock< Data_T >::emptyValue, FIELD3D_NAMESPACE_HEADER_CLOSE, and Sparse::SparseBlock< Data_T >::isAllocated.

Referenced by SparseField< Data_T >::releaseBlocks(), and SparseField< Data_T >::setBlockEmptyValue().

1941 {
1942  block.isAllocated = false;
1944  block.clear();
1945  block.emptyValue = emptyValue;
1946 }
template<class Data_T >
void SparseField< Data_T >::copySparseField ( const SparseField< Data_T > &  o)
private

Copies internal data, including blocks, from another SparseField, used by copy constructor and operator=.

Definition at line 1328 of file SparseField.h.

References SparseField< Data_T >::addReference(), Sparse::SparseBlock< Data_T >::copy(), SparseField< Data_T >::copyBlockStates(), Sparse::SparseBlock< Data_T >::emptyValue, SparseFile::Reference< Data_T >::filename, Sparse::SparseBlock< Data_T >::isAllocated, SparseFile::Reference< Data_T >::layerPath, SparseField< Data_T >::m_blockOrder, SparseField< Data_T >::m_blockRes, SparseField< Data_T >::m_blocks, SparseField< Data_T >::m_blockXYSize, SparseField< Data_T >::m_fileId, SparseField< Data_T >::m_fileManager, SparseField< Data_T >::m_numBlocks, SparseFile::Reference< Data_T >::occupiedBlocks, SparseFileManager::reference(), SparseField< Data_T >::setupBlocks(), SparseField< Data_T >::setupReferenceBlocks(), and SparseFile::Reference< Data_T >::valuesPerBlock.

Referenced by SparseField< Data_T >::operator=(), and SparseField< Data_T >::SparseField().

1329 {
1331  if (o.m_fileManager) {
1332  // allocate m_blocks, sets m_blockRes, m_blockXYSize, m_blocks
1333  setupBlocks();
1335  SparseFile::Reference<Data_T> *oldReference =
1336  m_fileManager->reference<Data_T>(o.m_fileId);
1337  addReference(oldReference->filename, oldReference->layerPath,
1338  oldReference->valuesPerBlock,
1339  oldReference->occupiedBlocks);
1340  copyBlockStates(o);
1342  } else {
1343  // directly copy all values and blocks from the source, no extra setup
1344  m_blockRes = o.m_blockRes;
1346  if (m_blocks) {
1347  delete[] m_blocks;
1348  }
1350  m_blocks = new Block[m_numBlocks];
1351  for (size_t i = 0; i < m_numBlocks; ++i) {
1354  m_blocks[i].copy(o.m_blocks[i],
1356  }
1357  m_fileId = -1;
1358  m_fileManager = NULL;
1359  }
1360 }
void addReference(const std::string &filename, const std::string &layerPath, int valuesPerBlock, int occupiedBlocks)
Internal function to create a Reference for the current field, for use in dynamic reading...
Definition: SparseField.h:1365
V3i m_blockRes
Block array resolution.
Definition: SparseField.h:612
int m_fileId
File id. Used with m_fileManager if active. Otherwise -1.
Definition: SparseField.h:624
int m_blockXYSize
Block array res.x * res.y.
Definition: SparseField.h:614
void setupReferenceBlocks()
Internal function to setup the Reference&#39;s block pointers, for use with dynamic reading.
Definition: SparseField.h:1397
int m_blockOrder
Block order (size = 2^blockOrder)
Definition: SparseField.h:610
std::string layerPath
Definition: SparseFile.h:114
Data_T emptyValue
The value to use if the block isn&#39;t allocated. We allow setting this per block so that we for example...
Definition: SparseField.h:308
void copy(const SparseBlock &other, size_t n)
Copy data from another block.
Definition: SparseField.h:285
void setupBlocks()
Initializes the block structure. Will clear any existing data.
Definition: SparseField.h:1828
bool isAllocated
Whether the block is allocated or not.
Definition: SparseField.h:303
std::string filename
Definition: SparseFile.h:113
void copyBlockStates(const SparseField< Data_T > &o)
Internal function to copy empty values and allocated flags, without copying data, used when copying a...
Definition: SparseField.h:1383
Sparse::SparseBlock< Data_T > Block
Definition: SparseField.h:583
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
SparseFile::Reference< Data_T > * reference(int index)
Returns a reference to the Reference object with the given index.
Definition: SparseFile.h:1197
SparseFileManager * m_fileManager
Pointer to SparseFileManager. Used when doing dynamic reading. NULL if not in use.
Definition: SparseField.h:622
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616
template<class Data_T >
void SparseField< Data_T >::copyBlockStates ( const SparseField< Data_T > &  o)
private

Internal function to copy empty values and allocated flags, without copying data, used when copying a dynamically read field.

Definition at line 1383 of file SparseField.h.

References Sparse::SparseBlock< Data_T >::clear(), Sparse::SparseBlock< Data_T >::emptyValue, Sparse::SparseBlock< Data_T >::isAllocated, SparseField< Data_T >::m_blocks, and SparseField< Data_T >::m_numBlocks.

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

1384 {
1385  if (m_numBlocks != o.m_numBlocks) return;
1386 
1387  for (size_t i = 0; i < m_numBlocks; ++i) {
1390  m_blocks[i].clear();
1391  }
1392 }
Data_T emptyValue
The value to use if the block isn&#39;t allocated. We allow setting this per block so that we for example...
Definition: SparseField.h:308
bool isAllocated
Whether the block is allocated or not.
Definition: SparseField.h:303
void clear()
Remove data.
Definition: SparseField.h:273
size_t m_numBlocks
Number of blocks in field.
Definition: SparseField.h:618
Block * m_blocks
Array of blocks. Not using std::vector since SparseBlock is noncopyable.
Definition: SparseField.h:616

Friends And Related Function Documentation

template<class Data_T>
friend class SparseFieldIO
friend

Definition at line 578 of file SparseField.h.

Member Data Documentation

template<class Data_T>
SparseField< Data_T >::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 366 of file SparseField.h.

template<class Data_T>
SparseField< Data_T >::FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION

Definition at line 515 of file SparseField.h.

template<class Data_T>
int SparseField< Data_T >::m_blockXYSize
protected
template<class Data_T>
Data_T SparseField< Data_T >::m_dummy
protected

Dummy value used when needing to return but indicating a failed call.

Definition at line 627 of file SparseField.h.

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

template<class Data_T>
TemplatedFieldType<SparseField<Data_T> > SparseField< Data_T >::ms_classType
staticprivate

Definition at line 633 of file SparseField.h.


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