Field3D
Sparse::CheckMaxAbs< Data_T > Struct Template Reference

Checks if all the absolute values in the SparseBlock are greater than some number. Useful for making narrow band levelsets 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. More...
 
 CheckMaxAbs (Data_T maxValue)
 Constructor. Takes max value. More...
 

Private Attributes

Data_T m_maxValue
 

Detailed Description

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

Checks if all the absolute values in the SparseBlock are greater than some number. Useful for making narrow band levelsets Used by SparseField::releaseBlocks().

Definition at line 798 of file SparseField.h.

Constructor & Destructor Documentation

template<typename Data_T >
Sparse::CheckMaxAbs< Data_T >::CheckMaxAbs ( Data_T  maxValue)
inline

Constructor. Takes max value.

Definition at line 801 of file SparseField.h.

802  : m_maxValue(maxValue)
803  { }

Member Function Documentation

template<typename Data_T >
bool Sparse::CheckMaxAbs< 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
blockReference to the block to check
retEmptyValueIf the block is to be removed, store the "empty value" that replaces it in this variable
validSizeNumber of voxels per dim within field data window
blockSizeNumber of voxels actually allocated per dim
Returns
Whether or not the supplied block can be released.

Definition at line 812 of file SparseField.h.

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

814  {
815  // Store first value
816  Data_T first = block.data[0];
817  // Iterate over rest
818  bool allGreater = true;
819  size_t len = blockSize.x * blockSize.y * blockSize.z;
820 
821  if (validSize == blockSize) {
822  // interior block so look at all voxels
823  for (size_t i = 0; i < len; i++) {
824  if (isAnyLess<Data_T>(block.data[i], m_maxValue)) {
825  allGreater = false;
826  break;
827  }
828  }
829  } else {
830  // only look at valid voxels
831  int x=0, y=0, z=0;
832  for (size_t i = 0; i < len; i++, x++) {
833  if (x >= blockSize.x) {
834  x = 0;
835  ++y;
836  if (y >= blockSize.y) {
837  y = 0;
838  ++z;
839  }
840  }
841  if (x >= validSize.x || y >= validSize.y || z >= validSize.z) {
842  continue;
843  }
844  if (isAnyLess<Data_T>(block.data[i], m_maxValue)) {
845  allGreater = false;
846  break;
847  }
848  }
849  } // end of interior block test
850 
851  if (allGreater) {
852  retEmptyValue = first;
853  return true;
854  } else {
855  return false;
856  }
857  }

Member Data Documentation

template<typename Data_T >
Data_T Sparse::CheckMaxAbs< Data_T >::m_maxValue
private

Definition at line 859 of file SparseField.h.


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