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>

List of all members.

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.
 CheckMaxAbs (Data_T maxValue)
 Constructor. Takes max value.

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

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.

    : m_maxValue(maxValue)
  { }

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

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

  {
    // Store first value
    Data_T first = block.data[0];
    // Iterate over rest
    bool allGreater = 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 (isAnyLess<Data_T>(*i, m_maxValue)) {
          allGreater = 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 (isAnyLess<Data_T>(*i, m_maxValue)) {
          allGreater = false;
          break;
        }
      }
    } // end of interior block test

    if (allGreater) {
      retEmptyValue = first;
      return true;
    } else {
      return false;
    }
  }

Member Data Documentation

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

Definition at line 619 of file SparseField.h.

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


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