Field3D
|
Checks if all the values in the SparseBlock are equal. Used by SparseField::releaseBlocks(). More...
#include <SparseField.h>
Public Member Functions | |
bool | check (const SparseBlock< Data_T > &block, Data_T &retEmptyValue, const V3i &validSize, const V3i &blockSize) |
Checks whether a given block can be released. It's safe to assume that the block is allocated if this functor is called. |
Checks if all the values in the SparseBlock are equal. Used by SparseField::releaseBlocks().
Definition at line 455 of file SparseField.h.
bool Sparse::CheckAllEqual< Data_T >::check | ( | const SparseBlock< Data_T > & | block, |
Data_T & | retEmptyValue, | ||
const V3i & | validSize, | ||
const V3i & | blockSize | ||
) | [inline] |
Checks whether a given block can be released. It's safe to assume that the block is allocated if this functor is called.
block | Reference to the block to check |
retEmptyValue | If the block is to be removed, store the "empty value" that replaces it in this variable |
validSize | Number of voxels per dim within field data window |
blockSize | Number of voxels actually allocated per dim |
Definition at line 465 of file SparseField.h.
References Sparse::SparseBlock< Data_T >::data.
{ // Store first value Data_T first = block.data[0]; // Iterate over rest bool match = true; if (validSize == blockSize) { // interior block so look at all voxels for (typename std::vector<Data_T>::const_iterator i = block.data.begin(); i != block.data.end(); ++i) { if (*i != first) { match = false; break; } } } else { // only look at valid voxels int x=0, y=0, z=0; for (typename std::vector<Data_T>::const_iterator i = block.data.begin(); i != block.data.end(); ++i, ++x) { if (x >= blockSize.x) { x = 0; ++y; if (y >= blockSize.y) { y = 0; ++z; } } if (x >= validSize.x || y >= validSize.y || z >= validSize.z) { continue; } if (*i != first) { match = false; break; } } } // end of interior block test if (match) { retEmptyValue = first; return true; } else { return false; } }