Density Class Reference

Voxel density handling class. How many points per cell. More...

#include <Density.H>

Inheritance diagram for Density:

DensityFlagged List of all members.

Public Types

enum  NeighborEnum {
  LEFT, RIGHT, FRONT, BACK,
  BELOW, ABOVE, NUM_NEIGHBORS = 6
}
 Which neightbor cell/voxel are we talking about. In order then are x-axis less, x more, y less, y more, z less, z more. More...

Public Member Functions

 Density ()
 Contructor that does almost nothing. FIX: Can we get rid of this?
 Density (const size_t width, const size_t height, const size_t depth, const float minX, const float maxX, const float minY, const float maxY, const float minZ, const float maxZ)
 Create a voxel space of widht,height, and depth number of cells.
 Density (const std::string &filename, bool &ok)
 Load a vol file from disk.
void resize (const size_t width, const size_t height, const size_t depth, const float minX, const float maxX, const float minY, const float maxY, const float minZ, const float maxZ)
 Change the volumes size. Dumps all counts. Does not shrink memory footprint if smaller.
void rescale (const float minX, const float maxX, const float minY, const float maxY, const float minZ, const float maxZ)
 Change the volume range/scale. Does not destroy the data. Just where we think it lives.
bool addPoint (const float x, const float y, const float z)
void addPoints (const size_t index, const size_t count)
 Add points to a cell at index.
void printCellCounts () const
 Print to stdout the cell number and the count.
size_t getWidth () const
 num of cells wide
size_t getHeight () const
 num of cells tall
size_t getDepth () const
 num of cell front to back
size_t getSize () const
 How many voxels in this density space?
size_t getCountInside () const
 How many points so far have been added that actually fall in the voxels' volumes.
size_t getCountOutside () const
 How many points failed to get added with addPoint().
size_t getCell (const float x, const float y, const float z) const
 Which cell number a point in space goes to.
bool isValidCell (const size_t i) const
size_t getCellX (const float x) const
size_t getCellY (const float y) const
size_t getCellZ (const float z) const
void getCellXYZ (const size_t index, size_t &cx, size_t &cy, size_t &cz) const
size_t getCellFromWHD (const size_t xIndex, const size_t yIndex, const size_t zIndex) const
size_t getCellNeighbor (const size_t i, NeighborEnum which) const
 returns badValue if the neighbor is outside of the volume
void getCellCenter (const size_t cellNum, float &x, float &y, float &z) const
 Given a cell index number, what is the location of the center?
size_t getCellCount (size_t i) const
 How many points have been added to a cell?
float getDX () const
 How wide is one cell.
float getDY () const
 How heigh is one cell.
float getDZ () const
 How deep is one cell.
bool writeVolScale (const std::string &filename) const
 Write out a vol formatted file for SIM Voleon in uchar format.
size_t scaleValue (const size_t value, const PackType p, const size_t bitsPerVoxel) const
 Compress data based on PackType.
bool writeVol (const std::string &filename, const size_t bitsPerPixel, const PackType p) const
 Write out a Voleon style voxel 3D cell file.
bool writeVol (const std::string &filename, const size_t bitsPerVoxel, const PackType p, const float scaleX, const float scaleY, const float scaleZ, const float rotX=0.f, const float rotY=0.f, const float rotZ=0.f) const
 Write out a Voleon style voxel 3D cell file.
unsigned char scaleCount (const size_t i, const size_t min, const size_t max) const
 Return a number scaled between 0 and 255.
bool buildCDF (std::vector< float > &cdfpercent) const
 fill two vectors with the count and the percent. Both will be of size getMaxCount()
size_t getMaxCount () const
 What is the maximum count in one cell across the whole count vector?
size_t getMinCount () const
 What is the minimum count in one cell across the whole count vector?

Static Public Member Functions

static size_t badValue ()
 This is the value for an unknown or bad entry. Should be a huge number that we would never encounter.

Private Member Functions

void invalidateCache ()
void computeMinMax () const

Private Attributes

bool stale
 set to true when max and min have to be recomputed
size_t maxCache
size_t minCache
size_t width
 width in number of cells
size_t height
 height in number of cells
size_t depth
 depth in number of cells
float dx
 Cell size.
float dy
 Cell size.
float dz
 Cell size.
float xR [2]
 min,max x Range of the voxel bounding box
float yR [2]
 min,max y Range of the voxel bounding box
float zR [2]
 min,max z Range of the voxel bounding box
std::vector< size_t > counts
 number of points in each voxel
size_t totalPointsInside
 Does not include points that were outside!
size_t totalPointsOutside
 How many points have failed to add since they were outside the volume.

Detailed Description

Voxel density handling class. How many points per cell.

What do we can this space representation?


Member Enumeration Documentation

enum Density::NeighborEnum
 

Which neightbor cell/voxel are we talking about. In order then are x-axis less, x more, y less, y more, z less, z more.

Enumerator:
LEFT 
RIGHT 
FRONT 
BACK 
BELOW 
ABOVE 
NUM_NEIGHBORS 


Constructor & Destructor Documentation

Density::Density  ) 
 

Contructor that does almost nothing. FIX: Can we get rid of this?

Bug:
Do not want this constructor to exist! If just this is called, life is bad! Does not setup anything really.

Density::Density const size_t  width,
const size_t  height,
const size_t  depth,
const float  minX,
const float  maxX,
const float  minY,
const float  maxY,
const float  minZ,
const float  maxZ
 

Create a voxel space of widht,height, and depth number of cells.

Parameters:
width Number of cells wide/x
height Number of cells deep/y
depth Number of cells tall/z
minX,maxX 3D space x range of voxel volume.
minY,maxY 3D space x range of voxel volume.
minZ,maxZ 3D space x range of voxel volume.

Density::Density const std::string &  filename,
bool &  ok
 

Load a vol file from disk.

Parameters:
filename File to load from
ok Set to true if the file was read ok
Do not use the Density structure ok was false.


Member Function Documentation

bool Density::addPoint const float  x,
const float  y,
const float  z
 

Add a point into the voxel structure. Figures out which cell for you

Returns:
true if inside the bounding box, false if outside and unrecorded

void Density::addPoints const size_t  index,
const size_t  count
[inline]
 

Add points to a cell at index.

static size_t Density::badValue  )  [inline, static]
 

This is the value for an unknown or bad entry. Should be a huge number that we would never encounter.

bool Density::buildCDF std::vector< float > &  cdfpercent  )  const
 

fill two vectors with the count and the percent. Both will be of size getMaxCount()

Parameters:
cdfpercent How many cells have have the value of the index or smaller?
Returns:
false if there was some trouble

void Density::computeMinMax  )  const [private]
 

size_t Density::getCell const float  x,
const float  y,
const float  z
const
 

Which cell number a point in space goes to.

Returns:
Cell number or badValue if x,y,z is not in the volume

void Density::getCellCenter const size_t  cellNum,
float &  x,
float &  y,
float &  z
const
 

Given a cell index number, what is the location of the center?

size_t Density::getCellCount size_t  i  )  const [inline]
 

How many points have been added to a cell?

size_t Density::getCellFromWHD const size_t  xIndex,
const size_t  yIndex,
const size_t  zIndex
const
 

size_t Density::getCellNeighbor const size_t  i,
NeighborEnum  which
const
 

returns badValue if the neighbor is outside of the volume

size_t Density::getCellX const float  x  )  const [inline]
 

void Density::getCellXYZ const size_t  index,
size_t &  cx,
size_t &  cy,
size_t &  cz
const
 

size_t Density::getCellY const float  y  )  const [inline]
 

size_t Density::getCellZ const float  z  )  const [inline]
 

size_t Density::getCountInside  )  const [inline]
 

How many points so far have been added that actually fall in the voxels' volumes.

size_t Density::getCountOutside  )  const [inline]
 

How many points failed to get added with addPoint().

This will be zero for volumes loaded from files.

size_t Density::getDepth  )  const [inline]
 

num of cell front to back

float Density::getDX  )  const [inline]
 

How wide is one cell.

float Density::getDY  )  const [inline]
 

How heigh is one cell.

float Density::getDZ  )  const [inline]
 

How deep is one cell.

size_t Density::getHeight  )  const [inline]
 

num of cells tall

size_t Density::getMaxCount  )  const
 

What is the maximum count in one cell across the whole count vector?

size_t Density::getMinCount  )  const
 

What is the minimum count in one cell across the whole count vector?

size_t Density::getSize  )  const [inline]
 

How many voxels in this density space?

size_t Density::getWidth  )  const [inline]
 

num of cells wide

void Density::invalidateCache  )  [inline, private]
 

Call this on anytime the counts change. This is only called when the object changes, so NOT const!

bool Density::isValidCell const size_t  i  )  const [inline]
 

void Density::printCellCounts  )  const
 

Print to stdout the cell number and the count.

void Density::rescale const float  minX,
const float  maxX,
const float  minY,
const float  maxY,
const float  minZ,
const float  maxZ
 

Change the volume range/scale. Does not destroy the data. Just where we think it lives.

Parameters:
minX,maxX 3D space x range of voxel volume.
minY,maxY 3D space x range of voxel volume.
minZ,maxZ 3D space x range of voxel volume.

void Density::resize const size_t  width,
const size_t  height,
const size_t  depth,
const float  minX,
const float  maxX,
const float  minY,
const float  maxY,
const float  minZ,
const float  maxZ
 

Change the volumes size. Dumps all counts. Does not shrink memory footprint if smaller.

Parameters:
width Number of cells wide/x
height Number of cells deep/y
depth Number of cells tall/z
minX,maxX 3D space x range of voxel volume.
minY,maxY 3D space x range of voxel volume.
minZ,maxZ 3D space x range of voxel volume.

unsigned char Density::scaleCount const size_t  i,
const size_t  min,
const size_t  max
const
 

Return a number scaled between 0 and 255.

size_t Density::scaleValue const size_t  value,
const PackType  p,
const size_t  bitsPerVoxel
const
 

Compress data based on PackType.

bool Density::writeVol const std::string &  filename,
const size_t  bitsPerVoxel,
const PackType  p,
const float  scaleX,
const float  scaleY,
const float  scaleZ,
const float  rotX = 0.f,
const float  rotY = 0.f,
const float  rotZ = 0.f
const
 

Write out a Voleon style voxel 3D cell file.

Returns:
true if success or false if there was some trouble The user/caller defines the scale... since I don't understand scaling.
Bug:
What does index_bits do?
Parameters:
filename File to write out to
bitsPerVoxel Can be 8, 16, or 32
p PackType 0=SCALE, 1=CLIP, 2=WRAP
scaleX Scale the x axis by using the vol header
scaleY Scale the y axis by using the vol header
scaleZ Scale the z axis by using the vol header
rotX Rotate around x axis using the vol header
rotY Rotate around y axis using the vol header
rotZ Rotate around z axis using the vol header

bool Density::writeVol const std::string &  filename,
const size_t  bitsPerPixel,
const PackType  p
const
 

Write out a Voleon style voxel 3D cell file.

Returns:
true if success or false if there was some trouble Uses the x,y, and z ranges to set the Scale[XYZ] fields of the header
Bug:
What does index_bits do?

bool Density::writeVolScale const std::string &  filename  )  const
 

Write out a vol formatted file for SIM Voleon in uchar format.

Returns:
true on success or false if there was an error This write scales the data between min/max


Member Data Documentation

std::vector<size_t> Density::counts [private]
 

number of points in each voxel

size_t Density::depth [private]
 

depth in number of cells

float Density::dx [private]
 

Cell size.

float Density::dy [private]
 

Cell size.

float Density::dz [private]
 

Cell size.

size_t Density::height [private]
 

height in number of cells

size_t Density::maxCache [mutable, private]
 

size_t Density::minCache [mutable, private]
 

bool Density::stale [mutable, private]
 

set to true when max and min have to be recomputed

size_t Density::totalPointsInside [private]
 

Does not include points that were outside!

size_t Density::totalPointsOutside [private]
 

How many points have failed to add since they were outside the volume.

size_t Density::width [private]
 

width in number of cells

float Density::xR[2] [private]
 

min,max x Range of the voxel bounding box

float Density::yR[2] [private]
 

min,max y Range of the voxel bounding box

float Density::zR[2] [private]
 

min,max z Range of the voxel bounding box


The documentation for this class was generated from the following files:
Generated on Thu Mar 2 17:55:26 2006 for density by  doxygen 1.4.6