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 811 of file SparseField.h.

Constructor & Destructor Documentation

◆ CheckMaxAbs()

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

Constructor. Takes max value.

Definition at line 814 of file SparseField.h.

815  : m_maxValue(maxValue)
816  { }

Member Function Documentation

◆ check()

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 825 of file SparseField.h.

827  {
828  // Store first value
829  Data_T first = block.data[0];
830  // Iterate over rest
831  bool allGreater = true;
832  size_t len = blockSize.x * blockSize.y * blockSize.z;
833 
834  if (validSize == blockSize) {
835  // interior block so look at all voxels
836  for (size_t i = 0; i < len; i++) {
837  if (isAnyLess<Data_T>(block.data[i], m_maxValue)) {
838  allGreater = false;
839  break;
840  }
841  }
842  } else {
843  // only look at valid voxels
844  int x=0, y=0, z=0;
845  for (size_t i = 0; i < len; i++, x++) {
846  if (x >= blockSize.x) {
847  x = 0;
848  ++y;
849  if (y >= blockSize.y) {
850  y = 0;
851  ++z;
852  }
853  }
854  if (x >= validSize.x || y >= validSize.y || z >= validSize.z) {
855  continue;
856  }
857  if (isAnyLess<Data_T>(block.data[i], m_maxValue)) {
858  allGreater = false;
859  break;
860  }
861  }
862  } // end of interior block test
863 
864  if (allGreater) {
865  retEmptyValue = first;
866  return true;
867  } else {
868  return false;
869  }
870  }

References Sparse::SparseBlock< Data_T >::data, and Sparse::CheckMaxAbs< Data_T >::m_maxValue.

Member Data Documentation

◆ m_maxValue

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

Definition at line 872 of file SparseField.h.

Referenced by Sparse::CheckMaxAbs< Data_T >::check().


The documentation for this struct was generated from the following file:
Sparse::CheckMaxAbs::m_maxValue
Data_T m_maxValue
Definition: SparseField.h:872