Sparse::CheckAllEqual< Data_T > Struct Template Reference

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.

## Detailed Description

template<typename Data_T>
struct Sparse::CheckAllEqual< Data_T >

Checks if all the values in the SparseBlock are equal. Used by SparseField::releaseBlocks().

Definition at line 710 of file SparseField.h.

## Member Function Documentation

## check()

template<typename Data_T>

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.

Parameters

  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

Returns
  Whether or not the supplied block can be released.

Definition at line 720 of file SparseField.h.

{
// Store first value
Data_T first = block.data[0];
// Iterate over rest
bool match = true;
size_t len = blockSize.x * blockSize.y * blockSize.z;
if (validSize == blockSize) {
// interior block so look at all voxels
for (size_t i = 0; i < len; i++) {
if (block.data[i] != first) {
match = false;
break;
}
}
} else {
// only look at valid voxels
int x=0, y=0, z=0;
for (size_t i = 0; i < len; 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 (block.data[i] != first) {
match = false;
break;
}
}
} // end of interior block test
if (match) {
retEmptyValue = first;
return true;
} else {
return false;
}
}
Sparse::CheckAllEqual
Checks if all the values in the SparseBlock are equal. Used by SparseField::releaseBlocks().
Definition SparseField.h:711

References Sparse::SparseBlock< Data_T >::data, and match().

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

- export/SparseField.h