iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
imstk::UniformSpatialGrid< CellData > Class Template Reference

Class for handling data in 3D grid. More...

#include <imstkUniformSpatialGrid.h>

Public Member Functions

 UniformSpatialGrid ()
 Construct a default grid ([0, 1]^3) with cell size of 1.
 
 UniformSpatialGrid (const Vec3d &lowerCorner, const Vec3d &upperCorner, double cellSize)
 Construct a grid with given corners and cell size. More...
 
void initialize (const Vec3d &lowerCorner, const Vec3d &upperCorner, const double cellSize)
 Initialize the grid data. More...
 
std::array< unsigned int, 3 > getResolution () const
 Get number of grid cell in 3 dimensions: (num_cell_x, num_cell_y, num_cell_z)
 
unsigned int getNumTotalCells () const
 Get number of total cells in the grid.
 
template<int d>
bool isValidCellIndex (const int idx) const
 Check if cell index in dimension d is valid (d = 0/1/2 => x/y/z dimension)
 
bool isValidCellIndices (const int i, const int j, const int k) const
 Check if 3D cell indices are valid.
 
template<class IndexType >
std::array< IndexType, 3 > getCell3DIndices (const Vec3d &ppos) const
 Get the 3D index (cell_x, cell_y, cell_z) of the cell containing the given positions.
 
std::vector< CellData > & getAllCellData ()
 Get all cell data.
 
const std::vector< CellData > & getAllCellData () const
 Get all cell data.
 
CellData & getCellData (const Vec3d &ppos)
 Get data in a cell. More...
 
const CellData & getCellData (const Vec3d &ppos) const
 Get data in a cell. More...
 
CellData & getCellData (size_t linearizedIdx)
 Get data in a cell. More...
 
const CellData & getCellData (size_t linearizedIdx) const
 Get data in a cell. More...
 
template<class IndexType >
CellData & getCellData (const std::array< IndexType, 3 > &cellIdx)
 Get data in a cell. More...
 
template<class IndexType >
const CellData & getCellData (const std::array< IndexType, 3 > &cellIdx) const
 Get data in a cell. More...
 
template<class IndexType >
CellData & getCellData (const IndexType i, const IndexType j, const IndexType k)
 Get data in a cell. More...
 
template<class IndexType >
const CellData & getCellData (const IndexType i, const IndexType j, const IndexType k) const
 Get data in a cell. More...
 
template<class Function >
void loopAllCellData (Function &&func)
 Apply a function to all cell data.
 
template<class IndexType >
IndexType getCellLinearizedIndex (const IndexType i, const IndexType j, const IndexType k) const
 Get linearized index from cell 3D indices: index in 3D (cell_x, cell_y, cell_z) => index in 1D. More...
 
template<class IndexType >
IndexType getCellLinearizedIndex (const Vec3d &ppos) const
 Get linearized index of cell containing the given position. More...
 

Detailed Description

template<class CellData>
class imstk::UniformSpatialGrid< CellData >

Class for handling data in 3D grid.

Parameters
RealThe floating point type for computation (must be float or double
CellDataThe data type that each cell will hold an instance of it

Definition at line 22 of file imstkUniformSpatialGrid.h.

Constructor & Destructor Documentation

◆ UniformSpatialGrid()

template<class CellData>
imstk::UniformSpatialGrid< CellData >::UniformSpatialGrid ( const Vec3d &  lowerCorner,
const Vec3d &  upperCorner,
double  cellSize 
)
inline

Construct a grid with given corners and cell size.

Parameters
lowerCornerThe lower corner of the grid
upperCornerThe upper corner of the grid
cellSizeThe length of grid cell

Definition at line 37 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

Member Function Documentation

◆ getCellData() [1/8]

template<class CellData>
CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const Vec3d &  ppos)
inline

Get data in a cell.

Parameters
Aposition in space

Definition at line 125 of file imstkUniformSpatialGrid.h.

◆ getCellData() [2/8]

template<class CellData>
const CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const Vec3d &  ppos) const
inline

Get data in a cell.

Parameters
Aposition in space

Definition at line 134 of file imstkUniformSpatialGrid.h.

◆ getCellData() [3/8]

template<class CellData>
CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( size_t  linearizedIdx)
inline

Get data in a cell.

Parameters
Alinearized index of cell

Definition at line 141 of file imstkUniformSpatialGrid.h.

◆ getCellData() [4/8]

template<class CellData>
const CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( size_t  linearizedIdx) const
inline

Get data in a cell.

Parameters
Alinearized index of cell

Definition at line 151 of file imstkUniformSpatialGrid.h.

◆ getCellData() [5/8]

template<class CellData>
template<class IndexType >
CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const std::array< IndexType, 3 > &  cellIdx)
inline

Get data in a cell.

Parameters
3Dindex of a cell

Definition at line 162 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

◆ getCellData() [6/8]

template<class CellData>
template<class IndexType >
const CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const std::array< IndexType, 3 > &  cellIdx) const
inline

Get data in a cell.

Parameters
3Dindex of a cell

Definition at line 172 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

◆ getCellData() [7/8]

template<class CellData>
template<class IndexType >
CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const IndexType  i,
const IndexType  j,
const IndexType  k 
)
inline

Get data in a cell.

Parameters
3Dindex of a cell

Definition at line 182 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

◆ getCellData() [8/8]

template<class CellData>
template<class IndexType >
const CellData& imstk::UniformSpatialGrid< CellData >::getCellData ( const IndexType  i,
const IndexType  j,
const IndexType  k 
) const
inline

Get data in a cell.

Parameters
3Dindex of a cell

Definition at line 192 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

◆ getCellLinearizedIndex() [1/2]

template<class CellData>
template<class IndexType >
IndexType imstk::UniformSpatialGrid< CellData >::getCellLinearizedIndex ( const IndexType  i,
const IndexType  j,
const IndexType  k 
) const
inline

Get linearized index from cell 3D indices: index in 3D (cell_x, cell_y, cell_z) => index in 1D.

Parameters
3Dindex of a cell

Definition at line 214 of file imstkUniformSpatialGrid.h.

Here is the caller graph for this function:

◆ getCellLinearizedIndex() [2/2]

template<class CellData>
template<class IndexType >
IndexType imstk::UniformSpatialGrid< CellData >::getCellLinearizedIndex ( const Vec3d &  ppos) const
inline

Get linearized index of cell containing the given position.

Parameters
Aposition in space

Definition at line 226 of file imstkUniformSpatialGrid.h.

Here is the call graph for this function:

◆ initialize()

template<class CellData>
void imstk::UniformSpatialGrid< CellData >::initialize ( const Vec3d &  lowerCorner,
const Vec3d &  upperCorner,
const double  cellSize 
)
inline

Initialize the grid data.

Parameters
lowerCornerThe lower corner of the grid
upperCornerThe upper corner of the grid
cellSizethe edge length of grid cell

Definition at line 48 of file imstkUniformSpatialGrid.h.

Here is the caller graph for this function:

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