24#ifndef  _SO_VOLUME_HISTOGRAM_ 
   25#define  _SO_VOLUME_HISTOGRAM_ 
   28#pragma warning( push ) 
   29#pragma warning(disable:4251) 
   30#pragma warning(disable:4127) 
   33#include <Inventor/SbDataType.h> 
   34#include <Inventor/SbLinear.h> 
   35#include <Inventor/helpers/SbDataTypeMacros.h> 
   37#include <Inventor/STL/limits> 
   38#include <Inventor/STL/vector> 
  101  { m_undefinedValue=undefinedValue; }
 
 
  108  { 
return m_undefinedValue; };
 
 
  201  void set(
const std::vector<int64_t> & histo);
 
  206  void set(
const std::vector<int64_t>& histo, 
const std::vector<double>& values);
 
  211  template<
typename T> 
inline size_t getEntry(T value) 
const;
 
  243    const double undefinedValue,
 
  274    const double undefinedValue,
 
  284  static void initClass();
 
  285  static void exitClass();
 
  291  template<
typename T> 
inline size_t getEntryInternal(T value) 
const;
 
  298  template<
typename T> 
inline size_t getEntryCaster(T value) 
const;
 
  301  unsigned int computeNumSignificantBits() 
const;
 
  303  std::vector<int64_t> m_histo;  
 
  308  unsigned int m_numSignificantBits; 
 
  313  double m_undefinedValue;   
 
  316  template <
typename T>
 
 
  340template<
typename T> 
size_t 
  341SoVolumeHistogram::getEntryInternal(T value)
 const 
  344  assert(
sizeof(T) <= 4);
 
  348  if ( std::numeric_limits<T>::is_signed )
 
  349    offset = (
sizeof(T) >= 2) ? 0x8000 : 0x80;
 
  351  if ( 
sizeof(T) == 4 )
 
  352    factor = (size_t)0x10000;
 
  354  size_t entry = (size_t)(value/int64_t(factor)+int64_t(offset));
 
  360template<
typename T> 
size_t 
  361SoVolumeHistogram::getEntryCaster(T value)
 const 
  363  return getEntryInternal(T(value));
 
  367template<
typename T> 
size_t 
  375    ret = getEntryInternal<unsigned short>((
unsigned short)value);
 
  378    ret = getEntryInternal<uint32_t>((uint32_t)value);
 
  381    ret = getEntryInternal<signed char>((
signed char)value);
 
  384    ret = getEntryInternal<signed short>((
signed short)value);
 
  387    ret = getEntryInternal<int32_t>((int32_t)value);
 
  390    ret = getEntryInternal<float>((
float)value);
 
  393    ret = getEntryInternal<unsigned char>((
unsigned char)value);
 
  396    ret = getEntryInternal<double>((
double)value);
 
 
  407template<> 
inline size_t 
  408SoVolumeHistogram::getEntryInternal<float>(
float value)
 const 
  411  if ( m_rangeMax == m_rangeMin )
 
  413  double factorDouble = 0.0f;
 
  414  factorDouble = 0xffff / (m_rangeMax - m_rangeMin);
 
  415  size_t entry = (size_t)((value-m_rangeMin)*factorDouble);
 
  421template<> 
inline size_t 
  422SoVolumeHistogram::getEntryInternal<double>(
double value)
 const 
  425  if ( m_rangeMax == m_rangeMin )
 
  427  double factorDouble = 0.0f;
 
  428  factorDouble = 0xffff / (m_rangeMax - m_rangeMin);
 
  429  size_t entry = (size_t)((value-m_rangeMin)*factorDouble);
 
  435#pragma warning( pop ) 
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a>  3D box class.
 
Class encoding a data type.
 
SbBool isInteger() const
Returns true if the type is an integer type.
 
@ UNSIGNED_INT32
unsigned int (32bits)
 
@ UNSIGNED_BYTE
unsigned byte
 
@ SIGNED_SHORT
signed short
 
@ UNSIGNED_SHORT
unsigned short
 
@ SIGNED_INT32
signed int (32bits)
 
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a>  2D vector class ...
 
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a>  Arithmetic funct...
 
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a>  Abstract base cl...
 
void set(const std::vector< int64_t > &histo)
Set the histogram.
 
void addValues(SoBufferObject *values, const int numValues)
Add to the histogram a 1D array of values.
 
void setUndefinedValue(const double undefinedValue)
Setup the undefined value to ignore when computing the histogram.
 
static void computeMinMaxWithUndefined(SoBufferObject *valuesBuffer, const double undefinedValue, const SbDataType &dataType, const SbVec3i32 &arrayDim, const SbBox3i32 &range, double &min, double &max)
Compute min max.
 
double getMaxValueD() const
Returns the max value of the dataset for floating data types.
 
static void computeMinMax(void *valuesBuffer, const SbDataType &dataType, const SbVec3i32 &arrayDim, SbVec2d &minMax)
Compute min max.
 
static void computeMinMax(SoBufferObject *valuesBuffer, const SbDataType &dataType, const SbVec3i32 &arrayDim, const SbBox3i32 &range, double &min, double &max)
Compute min max.
 
size_t getEntry(T value) const
Returns the histogram entry corresponding to the value.
 
size_t getHistoSize() const
Returns the size of the histogram.
 
double getMax() const
Returns the max value of the dataset according to the specified data type.
 
int64_t getNumValues(size_t entry)
Returns the histogram value corresponding to the entry.
 
int64_t getMaxValue() const
Returns the max value of the dataset for integer data types.
 
double getValueD(size_t entry)
Returns the value corresponding to the entry for floating data types.
 
int64_t getValue(size_t entry)
Returns the value corresponding to the entry for integer data types.
 
void addValues(SoBufferObject *values, const SbVec3i32 &arrayDim, const SbBox3i32 &range)
Add to the histogram the values in the specified range inside the given array.
 
~SoVolumeHistogram()
Destructor.
 
int64_t * getHistogram()
Returns a 64 bit integer pointer to the histogram data, the size of the histogram array is getHistoSi...
 
void set(const std::vector< int64_t > &histo, const std::vector< double > &values)
Set the histogram.
 
int getNumSignificantBits() const
Returns the number of significant bits for the dataset, only relevant for integer data types.
 
static void computeMinMaxWithUndefined(void *valuesBuffer, const double undefinedValue, const SbDataType &dataType, const SbVec3i32 &arrayDim, SbVec2d &minMax)
Compute min max.
 
double getUndefinedValue() const
return the current undefined value.
 
double getMinValueD() const
Returns the min value of the dataset for floating data types.
 
SoVolumeHistogram(const SbDataType &dataType)
Constructor.
 
int64_t getMinValue() const
Returns the min value of the dataset for integer data types.
 
void setInputValueRange(double rangeMin, double rangeMax)
For floating data type, specifies the range the histogram has to be computed in.
 
double getMin() const
Returns the max value of the dataset according to the specified data type.
 
T Clamp(T a, T minV, T maxV)
Clamps value to given range [minV, maxV].