KrisLibrary
1.0.0
|
A 3D array over a sparse, axis aligned 3D volume. Has a similar interface as VolumeGrid, but uses a hash grid data structure to achieve better performance in large grids with infinite domain. More...
#include <SparseVolumeGrid.h>
Classes | |
class | Block |
Public Member Functions | |
SparseVolumeGrid (Real blockRes) | |
SparseVolumeGrid (const Vector3 &blockRes) | |
bool | IsEmpty () const |
void | Clear () |
int | AddChannel (const std::string &name) |
int | GetChannel (const std::string &name) const |
size_t | GetNumChannels () const |
void | SetBlockSize (int m, int n, int p) |
void | SetBlockSize (const IntTriple &size) |
IntTriple | GetBlockSize () const |
void | SetBlockRes (const Vector3 &blockRes) |
void | SetBlockRes (Real blockRes) |
Vector3 | GetBlockRes () const |
void | SetDefaultValue (Real _defaultValue) |
void | SetDefaultValue (const Vector &_defaultValue) |
void | MakeSimilar (const SparseVolumeGrid &grid) |
Copies the block shape parameters from grid. | |
bool | IsSimilar (const SparseVolumeGrid &grid) const |
Returns true if this shares the same block shape parameters as grid. | |
void | GetCell (int i, int j, int k, AABB3D &cell) const |
void | GetCellCenter (int i, int j, int k, Vector3 ¢er) const |
Vector3 | GetCellSize () const |
void | GetIndex (const Vector3 &pt, int &i, int &j, int &k) const |
void | GetIndexAndParams (const Vector3 &pt, IntTriple &index, Vector3 ¶ms) const |
void | GetIndexRange (const AABB3D &range, IntTriple &imin, IntTriple &imax) const |
void | GetCell (const IntTriple &index, AABB3D &cell) const |
void | GetCenter (const IntTriple &index, Vector3 ¢er) const |
void | GetIndex (const Vector3 &pt, IntTriple &index) const |
void | SetValue (int i, int j, int k, Real value, int channel=0) |
Sets the value of the grid at a given cell, creating a new block if necessary. | |
void | SetValue (const Vector3 &pt, Real value, int channel=0) |
Sets the value of the grid at a given point, creating a new block if necessary. | |
void | SetValue (int i, int j, int k, const Vector &values) |
Sets all the values of the grid at a given cell, creating a new block if necessary. | |
void | SetValue (const Vector3 &pt, const Vector &values) |
Sets all the values of the grid at a given point, creating a new block if necessary. | |
Real | GetValue (int i, int j, int k, int channel=0) const |
Gets the value of the grid at a given cell. | |
Real | GetValue (const Vector3 &pt, int channel=0) const |
Gets the value of the grid at a given point (no interpolation is performed) | |
void | GetValue (int i, int j, int k, Vector &values) const |
Gets all the values of the grid at a given cell. | |
void | GetValue (const Vector3 &pt, Vector &values) const |
Gets all the values of the grid at a given point. | |
void | GetBlock (int i, int j, int k, IntTriple &blockIndex) const |
Returns the index of the block for cell (i,j,k) | |
void | GetBlock (const Vector3 &pt, IntTriple &blockIndex) const |
Returns the index of the block at pt (unlike GetIndex, which gives a cell in the hypothetical infinite grid) | |
void | GetBlockRange (const AABB3D &range, IntTriple &blockMin, IntTriple &blockMax) const |
Returns the min/max indices of blocks (unlike GetIndexRange, which gives a range of cell sin the hypothetical infinite grid) | |
Block * | BlockPtr (const IntTriple &blockIndex) const |
Retrieves the block given an index, or NULL if the block doesn't exist. | |
Block * | GetMakeBlock (const IntTriple &blockIndex) |
bool | MakeBlock (const IntTriple &blockIndex) |
bool | EraseBlock (const IntTriple &blockIndex) |
Erases a block block at the given hash index. Returns true if a block was deleted, false if no block existed there. | |
void | AddBlocks (const SparseVolumeGrid &grid) |
For a similar grid, makes default blocks with the same block pattern as grid. | |
void | SubdivideBlock (const IntTriple &block) |
Subdivides a given block. | |
void | GetSamples (MultiVolumeGrid &range) const |
void | GetSamples (Meshing::VolumeGrid &range, int channel=0) const |
void | GetSamples_Trilinear (MultiVolumeGrid &range) const |
Samples the grid along a dense volume grid (using trilinear interpolation at cell centers) | |
void | GetSamples_Trilinear (Meshing::VolumeGrid &range, int channel=0) const |
void | GetSamples_Average (MultiVolumeGrid &range) const |
Samples the grid along a dense volume grid (using averaging over cells) | |
void | GetSamples_Average (Meshing::VolumeGrid &range, int channel=0) const |
void | SetSamples (const MultiVolumeGrid &range) |
Sets entries of the grid to be equal to those of a dense volume grid. | |
void | SetSamples (const Meshing::VolumeGrid &range, int channel=0) |
Real | TrilinearInterpolate (const Vector3 &pt, int channel=0) const |
Computes the trilinear interpolation of the field at pt, assuming values are sampled exactly at cell centers. | |
void | TrilinearInterpolate (const Vector3 &pt, Vector &values) const |
Real | Average (const AABB3D &range, int channel=0) const |
Average value of the range. Each cell's value is weighted by the volume overlap with range. | |
void | Average (const AABB3D &range, Vector &values) const |
void | Gradient (const Vector3 &pt, Vector3 &grad, int channel=0) const |
void | Add (const SparseVolumeGrid &grid) |
void | Subtract (const SparseVolumeGrid &grid) |
void | Multiply (const SparseVolumeGrid &grid) |
void | Max (const SparseVolumeGrid &grid) |
void | Min (const SparseVolumeGrid &grid) |
void | Add (Real val, int channel=0) |
void | Multiply (Real val, int channel=0) |
void | Max (Real val, int channel=0) |
void | Min (Real val, int channel=0) |
void | ExtractMesh (float isosurface, Meshing::TriMesh &mesh) |
Generates a mesh for the level set at the given level set (usually 0), using the marching cubes algorithm. | |
Public Attributes | |
GridHash3D | hash |
int | blockIDCounter |
IntTriple | blockSize |
std::vector< std::string > | channelNames |
Vector3 | cellRes |
Vector | defaultValue |
A 3D array over a sparse, axis aligned 3D volume. Has a similar interface as VolumeGrid, but uses a hash grid data structure to achieve better performance in large grids with infinite domain.
A spatial hash is used to store blocks of dense volumes. Each volume is by default 8x8x8, but this can be configured using blockSize.
SparseVolumeGrid::Block * SparseVolumeGrid::GetMakeBlock | ( | const IntTriple & | blockIndex | ) |
If block exists at the given index, returns BlockPtr(). Otherwise, calls MakeBlock() on it and returns the pointer. Faster than "MakeBlock(b); return BlockPtr(b);".
void Geometry::SparseVolumeGrid::GetSamples | ( | MultiVolumeGrid & | range | ) | const |
Samples the grid along a dense volume grid (using basic extraction at cell centers). The grid bbox and values must be sized appropriately.
Returns the trilinear interpolated gradient. If any element of pt is on a cell boundary the gradient is estimated using centered differencing
bool SparseVolumeGrid::MakeBlock | ( | const IntTriple & | blockIndex | ) |
Creates an empty block (filled with the default value) at the given hash index. Returns true if a new block was made, false if the block already existed