3Depict
|
Template class that stores 3D voxel data. More...
#include <drawables.h>
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... | |
T | 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... | |
T | getData (size_t x, size_t y, size_t z) const |
Retrieve the value of a specific voxel. More... | |
T | getData (size_t *array) const |
T | 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... | |
T | 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... | |
T | min () const |
Find minimum in dataset. More... | |
T | 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... | |
T | 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... | |
Template class that stores 3D voxel data.
To instantiate this class, objects must have basic mathematical operators, such as * + - and =
void Voxels< T >::binarise | ( | Voxels< T > & | result, |
const T & | thresh, | ||
const T & | onThresh, | ||
const T & | offThresh | ||
) | const |
Binarise the data into a result vector.
void Voxels< T >::calculateDensity | ( | ) |
Convert voxel intensity into voxel density.
Referenced by VoxeliseFilter::refresh().
|
inline |
Empty the data.
Referenced by VoxelStreamData::clear(), VoxeliseFilter::clearCache(), and VoxeliseFilter::refresh().
Clone this into another object.
Referenced by VisController::updateScene().
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"
size_t Voxels< T >::count | ( | const T & | minIntensity | ) | const |
count the number of cells with at least this intensity
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
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().
void Voxels< T >::fill | ( | const T & | val | ) |
Fill all voxels with a given value.
Referenced by Voxels< float >::countPoints(), marchingCubes(), and VoxeliseFilter::refresh().
void Voxels< T >::getAxisBounds | ( | size_t | axis, |
float & | minV, | ||
float & | maxV | ||
) | const |
float Voxels< T >::getBinVolume | ( | ) | const |
Get the bounding size.
Referenced by VoxeliseFilter::getRefreshUseMask(), marchingCubes(), and VoxeliseFilter::refresh().
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
|
inline |
Retrieve the value of a specific voxel.
Referenced by Voxels< float >::binarise(), countPoints(), DrawField3D::draw(), Voxels< float >::getInterpolatedData(), VoxeliseFilter::getRefreshUseMask(), Voxels< float >::getSlice(), marchingCubes(), Voxels< float >::resizeKeepData(), sumVoxels(), Voxels< float >::thresholdForPosition(), and vtk_write_legacy().
|
inline |
|
inline |
Retrieve value of the nth voxel.
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().
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().
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().
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().
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().
void Voxels< T >::getInterpSlice | ( | size_t | normal, |
float | offset, | ||
T * | p, | ||
size_t | interpMode = VOX_INTERP_NONE |
||
) | const |
Referenced by DrawField3D::draw(), DrawField3D::getBoundingBox(), DrawIsoSurface::getBoundingBox(), Voxels< float >::getEdgeEnds(), and marchingCubes().
Get the bounding box vertex (min/max)
Referenced by DrawField3D::draw(), DrawField3D::getBoundingBox(), DrawIsoSurface::getBoundingBox(), Voxels< float >::getEdgeEnds(), and marchingCubes().
! Get the spacing for a unit cell
Referenced by DrawField3D::draw(), Voxels< float >::getEdgeEnds(), Voxels< float >::getInterpolatedData(), marchingCubes(), and VoxeliseFilter::refresh().
Get the position associated with an XYZ voxel.
Referenced by DrawField3D::draw(), Voxels< float >::getEdgeEnds(), marchingCubes(), Voxels< float >::thresholdForPosition(), and vtk_write_legacy().
Retrieve the value of a datapoint, this is rounded to the nearest voxel.
Referenced by Voxels< float >::getEdgeEndApproxVals().
void Voxels< T >::getSize | ( | size_t & | x, |
size_t & | y, | ||
size_t & | z | ||
) | const |
Get the size of the data field.
Referenced by countPoints(), DrawField3D::draw(), VoxelStreamData::getNumBasicObjects(), VoxeliseFilter::getRefreshUseMask(), marchingCubes(), VoxeliseFilter::refresh(), sumVoxels(), and vtk_write_legacy().
|
inline |
void Voxels< T >::getSlice | ( | size_t | normal, |
size_t | offset, | ||
T * | p | ||
) | const |
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
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().
size_t Voxels< T >::init | ( | size_t | nX, |
size_t | nY, | ||
size_t | nZ | ||
) |
Initialise the voxel storage.
void Voxels< T >::isotropicGaussianSmooth | ( | float | stdev, |
float | windowRatio | ||
) |
void Voxels< T >::laplaceOfGaussian | ( | float | stdev, |
float | windowRatio | ||
) |
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
T Voxels< T >::max | ( | ) | const |
Find maximum in dataset.
Referenced by VoxeliseFilter::getRefreshUseMask(), and DrawField3D::setColourMinMax().
T Voxels< T >::min | ( | ) | const |
Find minimum in dataset.
Referenced by VoxeliseFilter::getRefreshUseMask(), and DrawField3D::setColourMinMax().
void Voxels< T >::minMax | ( | T & | min, |
T & | max | ||
) | const |
Find both min and max in dataset in the same loop.
Referenced by VoxeliseFilter::refresh().
void Voxels< T >::operator/= | ( | const T & | v | ) |
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.
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().
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.
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"
Set the bounding size.
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().
|
inline |
Set the value of nth point in the dataset.
|
inline |
Set the value of a point in the dataset.
|
inline |
Referenced by Voxels< float >::calculateDensity(), Voxels< float >::getBinVolume(), sumVoxels(), and vtk_write_legacy().
|
inlinestatic |
Return the sizeof value for the T type.
Maybe there is a better way to do this, I don't know
Swap object contents with other voxel object.
Referenced by VisController::updateScene().
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
T Voxels< T >::trapezIntegral | ( | ) | const |
Integrate the datataset via the trapezoidal method.
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().