3Depict
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | List of all members
Voxels< T > Class Template Reference

Template class that stores 3D voxel data. More...

#include <drawables.h>

Inheritance diagram for Voxels< T >:
Inheritance graph
[legend]

Public Member Functions

 Voxels ()
 Constructor. More...
 
 ~Voxels ()
 Destructor. More...
 
void swap (Voxels< T > &v)
 Swap object contents with other voxel object. More...
 
void clone (Voxels< T > &newClone) const
 Clone this into another object. More...
 
void setPoint (const Point3D &pt, const T &val)
 Set the value of a point in the dataset. More...
 
getPointData (const Point3D &pt) const
 Retrieve the value of a datapoint, this is rounded to the nearest voxel. More...
 
void getIndex (size_t &x, size_t &y, size_t &z, const Point3D &p) const
 Retrieve the XYZ voxel location associated with a given position. More...
 
void getIndexWithUpper (size_t &x, size_t &y, size_t &z, const Point3D &p) const
 Retrieve the XYZ voxel location associated with a given position,. More...
 
Point3D getPoint (size_t x, size_t y, size_t z) const
 Get the position associated with an XYZ voxel. More...
 
getData (size_t x, size_t y, size_t z) const
 Retrieve the value of a specific voxel. More...
 
getData (size_t *array) const
 
getData (size_t i) const
 Retrieve value of the nth voxel. More...
 
void setEntry (size_t n, const T &val)
 
void setData (size_t x, size_t y, size_t z, const T &val)
 Retrieve a reference to the data ata given position. More...
 
void setData (size_t n, const T &val)
 Set the value of nth point in the dataset. More...
 
void getInterpolatedData (const Point3D &pt, T &v) const
 
void isotropicGaussianSmooth (float stdev, float windowRatio)
 
void laplaceOfGaussian (float stdev, float windowRatio)
 
void getInterpSlice (size_t normal, float offset, T *p, size_t interpMode=VOX_INTERP_NONE) const
 
void getSlice (size_t normal, size_t offset, T *p) const
 
void getSize (size_t &x, size_t &y, size_t &z) const
 Get the size of the data field. More...
 
size_t getSize () const
 
size_t resize (size_t newX, size_t newY, size_t newZ, const Point3D &newMinBound=Point3D(0.0f, 0.0f, 0.0f), const Point3D &newMaxBound=Point3D(1.0f, 1.0f, 1.0f))
 Resize the data field. More...
 
size_t resize (const Voxels< T > &v)
 
size_t resizeKeepData (size_t newX, size_t newY, size_t newZ, unsigned int direction=CLIP_LOWER_SOUTH_WEST, const Point3D &newMinBound=Point3D(0.0f, 0.0f, 0.0f), const Point3D &newMaxBound=Point3D(1.0f, 1.0f, 1.0f), const T &fill=T(0), bool doFill=false)
 Resize the data field, maintaining data as best as possible. More...
 
size_t deprecatedGetEdgeUniqueIndex (size_t x, size_t y, size_t z, unsigned int edge) const
 DEPRECATED FUNCTION : Get a unique integer that corresponds to the edge index for the voxel; where edges are shared between voxels. More...
 
size_t getCellUniqueEdgeIndex (size_t x, size_t y, size_t z, unsigned int edge) const
 Get a unique integer that corresponds to an edge index for the voxel; where edges are shared between voxels. More...
 
void getEdgeEnds (size_t edgeIndex, Point3D &a, Point3D &b) const
 Convert the edge index (as generated by getEdgeUniqueIndex) into a cenre position. More...
 
void getEdgeCell (size_t edgeUniqId, size_t &x, size_t &y, size_t &z, size_t &axis) const
 Convert edge index (only as generted by getCellUniqueEdgeIndex) into a cell & axis value. More...
 
void getEdgeEndApproxVals (size_t edgeUniqId, T &a, T &b) const
 Return the values that are associated with the edge ends, as returned by getEdgeEnds. More...
 
void rebin (Voxels< T > &dest, size_t rate, size_t clipMode=CLIP_NONE) const
 Rebin the data by a given rate. More...
 
getSum (const T &initialVal=T(0.0)) const
 Get the total value of the data field. More...
 
size_t count (const T &minIntensity) const
 count the number of cells with at least this intensity More...
 
void fill (const T &val)
 Fill all voxels with a given value. More...
 
Point3D getMinBounds () const
 Get the bounding box vertex (min/max) More...
 
Point3D getMaxBounds () const
 
void getAxisBounds (size_t axis, float &minV, float &maxV) const
 
Point3D getPitch () const
 ! Get the spacing for a unit cell More...
 
void setBounds (const Point3D &pMin, const Point3D &pMax)
 Set the bounding size. More...
 
void getBounds (Point3D &pMin, Point3D &pMax) const
 Get the bounding size. More...
 
void getBounds (BoundCube &bc) const
 
size_t init (size_t nX, size_t nY, size_t nZ, const BoundCube &bound)
 Initialise the voxel storage. More...
 
size_t init (size_t nX, size_t nY, size_t nZ)
 Initialise the voxel storage. More...
 
size_t loadFile (const char *cpFilename, size_t nX, size_t nY, size_t nZ, bool silent=false)
 Load the voxels from file. More...
 
size_t writeFile (const char *cpFilename) const
 Write the voxel objects in column major written out to file. More...
 
size_t convolve (const Voxels< T > &templateVec, Voxels< T > &result, size_t boundMode=BOUND_CLIP) const
 Run convolution over this data, placing the correlation data into "result". More...
 
size_t separableConvolve (const Voxels< T > &templateVec, Voxels< T > &result, size_t boundMode=BOUND_CLIP)
 Similar to convolve, but faster – only works with separable kernels. More...
 
void thresholdForPosition (std::vector< Point3D > &p, const T &thresh, bool lowerEq=false) const
 Find the positions of the voxels that are above or below a given value. More...
 
void binarise (Voxels< T > &result, const T &thresh, const T &onThresh, const T &offThresh) const
 Binarise the data into a result vector. More...
 
void clear ()
 Empty the data. More...
 
min () const
 Find minimum in dataset. More...
 
max () const
 Find maximum in dataset. More...
 
void minMax (T &min, T &max) const
 Find both min and max in dataset in the same loop. More...
 
int countPoints (const std::vector< Point3D > &points, bool noWrap=true, bool doErase=false)
 Generate a dataset that consists of the counts of points in a given voxel. More...
 
trapezIntegral () const
 Integrate the datataset via the trapezoidal method. More...
 
void calculateDensity ()
 Convert voxel intensity into voxel density. More...
 
float getBinVolume () const
 
void operator/= (const Voxels< T > &v)
 Element wise division. More...
 
void operator/= (const T &v)
 
bool operator== (const Voxels< T > &v) const
 
size_t size () const
 

Static Public Member Functions

static size_t sizeofType ()
 Return the sizeof value for the T type. More...
 

Detailed Description

template<class T>
class Voxels< T >

Template class that stores 3D voxel data.

To instantiate this class, objects must have basic mathematical operators, such as * + - and =

Constructor & Destructor Documentation

◆ Voxels()

template<class T >
Voxels< T >::Voxels ( )

Constructor.

◆ ~Voxels()

template<class T >
Voxels< T >::~Voxels ( )

Destructor.

Member Function Documentation

◆ binarise()

template<class T>
void Voxels< T >::binarise ( Voxels< T > &  result,
const T &  thresh,
const T &  onThresh,
const T &  offThresh 
) const

Binarise the data into a result vector.

◆ calculateDensity()

template<class T >
void Voxels< T >::calculateDensity ( )

Convert voxel intensity into voxel density.

Referenced by VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ clear()

template<class T>
void Voxels< T >::clear ( )
inline

Empty the data.

Referenced by VoxelStreamData::clear(), VoxeliseFilter::clearCache(), and VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ clone()

template<class T>
void Voxels< T >::clone ( Voxels< T > &  newClone) const

Clone this into another object.

Referenced by VisController::updateScene().

Here is the caller graph for this function:

◆ convolve()

template<class T>
size_t Voxels< T >::convolve ( const Voxels< T > &  templateVec,
Voxels< T > &  result,
size_t  boundMode = BOUND_CLIP 
) const

Run convolution over this data, placing the correlation data into "result".

Datasets MUST have the same pitch (spacing) for the result to be defined template type must have a T(0.0) constructor that intialises it to some "zero"

◆ count()

template<class T>
size_t Voxels< T >::count ( const T &  minIntensity) const

count the number of cells with at least this intensity

◆ countPoints()

template<class T >
int Voxels< T >::countPoints ( const std::vector< Point3D > &  points,
bool  noWrap = true,
bool  doErase = false 
)

Generate a dataset that consists of the counts of points in a given voxel.

Ensure that the voxel scaling factors are set by calling ::setBounds() with the appropriate parameters for your data. Disabling nowrap allows you to "saturate" your data field in the case of dense regions, rather than let wrap-around errors occur

◆ deprecatedGetEdgeUniqueIndex()

template<class T >
size_t Voxels< T >::deprecatedGetEdgeUniqueIndex ( size_t  x,
size_t  y,
size_t  z,
unsigned int  edge 
) const

DEPRECATED FUNCTION : Get a unique integer that corresponds to the edge index for the voxel; where edges are shared between voxels.

Each voxel has 12 edges. These are shared (except voxels that on zero or positive boundary). Return a unique index that corresponds to a specified edge (0->11). Index CANNOT be inverted to yield cell

Referenced by marchingCubes().

Here is the caller graph for this function:

◆ fill()

template<class T>
void Voxels< T >::fill ( const T &  val)

Fill all voxels with a given value.

Referenced by Voxels< float >::countPoints(), marchingCubes(), and VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ getAxisBounds()

template<class T >
void Voxels< T >::getAxisBounds ( size_t  axis,
float &  minV,
float &  maxV 
) const

Referenced by VoxeliseFilter::getRefreshUseMask().

Here is the caller graph for this function:

◆ getBinVolume()

template<class T >
float Voxels< T >::getBinVolume ( ) const

◆ getBounds() [1/2]

template<class T>
void Voxels< T >::getBounds ( Point3D pMin,
Point3D pMax 
) const
inline

Get the bounding size.

Referenced by VoxeliseFilter::getRefreshUseMask(), marchingCubes(), and VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ getBounds() [2/2]

template<class T>
void Voxels< T >::getBounds ( BoundCube bc) const
inline

◆ getCellUniqueEdgeIndex()

template<class T >
size_t Voxels< T >::getCellUniqueEdgeIndex ( size_t  x,
size_t  y,
size_t  z,
unsigned int  edge 
) const

Get a unique integer that corresponds to an edge index for the voxel; where edges are shared between voxels.

Each voxel has 12 edges. These are shared (except voxels that on zero or positive boundary). Return a NON-unique index that corresponds to a specified edge (0->11) Index can be inverted to yield cell

◆ getData() [1/3]

template<class T >
T Voxels< T >::getData ( size_t  x,
size_t  y,
size_t  z 
) const
inline

◆ getData() [2/3]

template<class T>
T Voxels< T >::getData ( size_t *  array) const
inline

◆ getData() [3/3]

template<class T>
T Voxels< T >::getData ( size_t  i) const
inline

Retrieve value of the nth voxel.

◆ getEdgeCell()

template<class T >
void Voxels< T >::getEdgeCell ( size_t  edgeUniqId,
size_t &  x,
size_t &  y,
size_t &  z,
size_t &  axis 
) const

Convert edge index (only as generted by getCellUniqueEdgeIndex) into a cell & axis value.

Referenced by Voxels< float >::getEdgeEnds().

Here is the caller graph for this function:

◆ getEdgeEndApproxVals()

template<class T>
void Voxels< T >::getEdgeEndApproxVals ( size_t  edgeUniqId,
T &  a,
T &  b 
) const

Return the values that are associated with the edge ends, as returned by getEdgeEnds.

Referenced by marchingCubes().

Here is the caller graph for this function:

◆ getEdgeEnds()

template<class T >
void Voxels< T >::getEdgeEnds ( size_t  edgeIndex,
Point3D a,
Point3D b 
) const

Convert the edge index (as generated by getEdgeUniqueIndex) into a cenre position.

Referenced by Voxels< float >::getEdgeEndApproxVals(), and marchingCubes().

Here is the caller graph for this function:

◆ getIndex()

template<class T >
void Voxels< T >::getIndex ( size_t &  x,
size_t &  y,
size_t &  z,
const Point3D p 
) const

Retrieve the XYZ voxel location associated with a given position.

Referenced by Voxels< float >::getEdgeEndApproxVals(), Voxels< float >::getIndexWithUpper(), and Voxels< float >::getInterpolatedData().

Here is the caller graph for this function:

◆ getIndexWithUpper()

template<class T >
void Voxels< T >::getIndexWithUpper ( size_t &  x,
size_t &  y,
size_t &  z,
const Point3D p 
) const

Retrieve the XYZ voxel location associated with a given position,.

Referenced by countPoints().

Here is the caller graph for this function:

◆ getInterpolatedData()

template<class T>
void Voxels< T >::getInterpolatedData ( const Point3D pt,
T &  v 
) const

Referenced by VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ getInterpSlice()

template<class T>
void Voxels< T >::getInterpSlice ( size_t  normal,
float  offset,
T *  p,
size_t  interpMode = VOX_INTERP_NONE 
) const

Referenced by VoxeliseFilter::getRefreshUseMask().

Here is the caller graph for this function:

◆ getMaxBounds()

template<class T >
Point3D Voxels< T >::getMaxBounds ( ) const

◆ getMinBounds()

template<class T >
Point3D Voxels< T >::getMinBounds ( ) const

Get the bounding box vertex (min/max)

Referenced by DrawField3D::draw(), DrawField3D::getBoundingBox(), DrawIsoSurface::getBoundingBox(), Voxels< float >::getEdgeEnds(), and marchingCubes().

Here is the caller graph for this function:

◆ getPitch()

template<class T >
Point3D Voxels< T >::getPitch ( ) const

! Get the spacing for a unit cell

Referenced by DrawField3D::draw(), Voxels< float >::getEdgeEnds(), Voxels< float >::getInterpolatedData(), marchingCubes(), and VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ getPoint()

template<class T >
Point3D Voxels< T >::getPoint ( size_t  x,
size_t  y,
size_t  z 
) const

Get the position associated with an XYZ voxel.

Referenced by DrawField3D::draw(), Voxels< float >::getEdgeEnds(), marchingCubes(), Voxels< float >::thresholdForPosition(), and vtk_write_legacy().

Here is the caller graph for this function:

◆ getPointData()

template<class T >
T Voxels< T >::getPointData ( const Point3D pt) const

Retrieve the value of a datapoint, this is rounded to the nearest voxel.

Referenced by Voxels< float >::getEdgeEndApproxVals().

Here is the caller graph for this function:

◆ getSize() [1/2]

template<class T >
void Voxels< T >::getSize ( size_t &  x,
size_t &  y,
size_t &  z 
) const

◆ getSize() [2/2]

template<class T>
size_t Voxels< T >::getSize ( ) const
inline

◆ getSlice()

template<class T>
void Voxels< T >::getSlice ( size_t  normal,
size_t  offset,
T *  p 
) const

Referenced by Voxels< float >::getInterpSlice().

Here is the caller graph for this function:

◆ getSum()

template<class T>
T Voxels< T >::getSum ( const T &  initialVal = T(0.0)) const

Get the total value of the data field.

An "initial value" is provided to provide the definition of a zero value

◆ init() [1/2]

template<class T >
size_t Voxels< T >::init ( size_t  nX,
size_t  nY,
size_t  nZ,
const BoundCube bound 
)

Initialise the voxel storage.

Referenced by Voxels< float >::init(), and VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ init() [2/2]

template<class T >
size_t Voxels< T >::init ( size_t  nX,
size_t  nY,
size_t  nZ 
)

Initialise the voxel storage.

◆ isotropicGaussianSmooth()

template<class T >
void Voxels< T >::isotropicGaussianSmooth ( float  stdev,
float  windowRatio 
)

Referenced by VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ laplaceOfGaussian()

template<class T >
void Voxels< T >::laplaceOfGaussian ( float  stdev,
float  windowRatio 
)

Referenced by VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ loadFile()

template<class T >
size_t Voxels< T >::loadFile ( const char *  cpFilename,
size_t  nX,
size_t  nY,
size_t  nZ,
bool  silent = false 
)

Load the voxels from file.

Format is flat size_ts in column major return codes: 1: File open error 2: Data size error

◆ max()

template<class T >
T Voxels< T >::max ( ) const

Find maximum in dataset.

Referenced by VoxeliseFilter::getRefreshUseMask(), and DrawField3D::setColourMinMax().

Here is the caller graph for this function:

◆ min()

template<class T >
T Voxels< T >::min ( ) const

Find minimum in dataset.

Referenced by VoxeliseFilter::getRefreshUseMask(), and DrawField3D::setColourMinMax().

Here is the caller graph for this function:

◆ minMax()

template<class T>
void Voxels< T >::minMax ( T &  min,
T &  max 
) const

Find both min and max in dataset in the same loop.

Referenced by VoxeliseFilter::refresh().

Here is the caller graph for this function:

◆ operator/=() [1/2]

template<class T>
void Voxels< T >::operator/= ( const Voxels< T > &  v)

Element wise division.

◆ operator/=() [2/2]

template<class T>
void Voxels< T >::operator/= ( const T &  v)

◆ operator==()

template<class T>
bool Voxels< T >::operator== ( const Voxels< T > &  v) const

◆ rebin()

template<class T>
void Voxels< T >::rebin ( Voxels< T > &  dest,
size_t  rate,
size_t  clipMode = CLIP_NONE 
) const

Rebin the data by a given rate.

This will perform a quick and dirty rebin operation, where groups of datablocks are binned into a single cell. Number of blocks binned is rate^3. Field must be larger than rate in all directions. Currently only CLIP_NONE is supported.

◆ resize() [1/2]

template<class T >
size_t Voxels< T >::resize ( size_t  newX,
size_t  newY,
size_t  newZ,
const Point3D newMinBound = Point3D(0.0f,0.0f,0.0f),
const Point3D newMaxBound = Point3D(1.0f,1.0f,1.0f) 
)

Resize the data field.

This will destroy any data that was already in place If the data needs to be preserved use "resizeKeepData" Data will not be initialised

Referenced by Voxels< float >::binarise(), Voxels< float >::loadFile(), marchingCubes(), Voxels< float >::resize(), Voxels< float >::resizeKeepData(), and vtk_write_legacy().

Here is the caller graph for this function:

◆ resize() [2/2]

template<class T>
size_t Voxels< T >::resize ( const Voxels< T > &  v)

◆ resizeKeepData()

template<class T>
size_t Voxels< T >::resizeKeepData ( size_t  newX,
size_t  newY,
size_t  newZ,
unsigned int  direction = CLIP_LOWER_SOUTH_WEST,
const Point3D newMinBound = Point3D(0.0f,0.0f,0.0f),
const Point3D newMaxBound = Point3D(1.0f,1.0f,1.0f),
const T &  fill = T(0),
bool  doFill = false 
)

Resize the data field, maintaining data as best as possible.

This will preserve data by resizing as much as possible about the origin. If the bounds are extended, the "fill" value is used by default iff doFill is set to true.

◆ separableConvolve()

template<class T>
size_t Voxels< T >::separableConvolve ( const Voxels< T > &  templateVec,
Voxels< T > &  result,
size_t  boundMode = BOUND_CLIP 
)

Similar to convolve, but faster – only works with separable kernels.

Datasets MUST have the same pitch (spacing) for the result to be defined template type must have a T(0.0) constructor that intialises it to some "zero"

◆ setBounds()

template<class T >
void Voxels< T >::setBounds ( const Point3D pMin,
const Point3D pMax 
)

Set the bounding size.

◆ setData() [1/2]

template<class T>
void Voxels< T >::setData ( size_t  x,
size_t  y,
size_t  z,
const T &  val 
)

Retrieve a reference to the data ata given position.

Set the value of a point in the dataset

Referenced by Voxels< float >::binarise(), countPoints(), marchingCubes(), Voxels< float >::resizeKeepData(), and vtk_write_legacy().

Here is the caller graph for this function:

◆ setData() [2/2]

template<class T>
void Voxels< T >::setData ( size_t  n,
const T &  val 
)
inline

Set the value of nth point in the dataset.

◆ setEntry()

template<class T>
void Voxels< T >::setEntry ( size_t  n,
const T &  val 
)
inline

◆ setPoint()

template<class T>
void Voxels< T >::setPoint ( const Point3D pt,
const T &  val 
)

Set the value of a point in the dataset.

◆ size()

template<class T>
size_t Voxels< T >::size ( ) const
inline

Referenced by Voxels< float >::calculateDensity(), Voxels< float >::getBinVolume(), sumVoxels(), and vtk_write_legacy().

Here is the caller graph for this function:

◆ sizeofType()

template<class T>
static size_t Voxels< T >::sizeofType ( )
inlinestatic

Return the sizeof value for the T type.

Maybe there is a better way to do this, I don't know

◆ swap()

template<class T>
void Voxels< T >::swap ( Voxels< T > &  v)

Swap object contents with other voxel object.

Referenced by VisController::updateScene().

Here is the caller graph for this function:

◆ thresholdForPosition()

template<class T>
void Voxels< T >::thresholdForPosition ( std::vector< Point3D > &  p,
const T &  thresh,
bool  lowerEq = false 
) const

Find the positions of the voxels that are above or below a given value.

Returns the positions of the voxels' centroids for voxels that have, by default, a value greater than that of thresh. This behaviour can by reversed to "lesser than" by setting lowerEq to false

◆ trapezIntegral()

template<class T >
T Voxels< T >::trapezIntegral ( ) const

Integrate the datataset via the trapezoidal method.

◆ writeFile()

template<class T >
size_t Voxels< T >::writeFile ( const char *  cpFilename) const

Write the voxel objects in column major written out to file.

Format is flat objects ("T"s) in column major format. Returns nonzero on failure

Referenced by MainWindowFrame::OnFileExportFilterVideo().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: