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

562  : m_maxValue(maxValue)
563  { }

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

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

574  {
575  // Store first value
576  Data_T first = block.data[0];
577  // Iterate over rest
578  bool allGreater = true;
579  if (validSize == blockSize) {
580  // interior block so look at all voxels
581  for (typename std::vector<Data_T>::const_iterator i = block.data.begin();
582  i != block.data.end(); ++i) {
583  if (isAnyLess<Data_T>(*i, m_maxValue)) {
584  allGreater = false;
585  break;
586  }
587  }
588  } else {
589  // only look at valid voxels
590  int x=0, y=0, z=0;
591  for (typename std::vector<Data_T>::const_iterator i = block.data.begin();
592  i != block.data.end(); ++i, ++x) {
593  if (x >= blockSize.x) {
594  x = 0;
595  ++y;
596  if (y >= blockSize.y) {
597  y = 0;
598  ++z;
599  }
600  }
601  if (x >= validSize.x || y >= validSize.y || z >= validSize.z) {
602  continue;
603  }
604  if (isAnyLess<Data_T>(*i, m_maxValue)) {
605  allGreater = false;
606  break;
607  }
608  }
609  } // end of interior block test
610 
611  if (allGreater) {
612  retEmptyValue = first;
613  return true;
614  } else {
615  return false;
616  }
617  }

Member Data Documentation

◆ m_maxValue

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

Definition at line 619 of file SparseField.h.


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