The functions and elements of a VoxelGrid. More...
#include <VoxelGrid.h>
Public Member Functions | |
VoxelGrid (const float _lengthX, const float _lengthY, const float _lengthZ, const int _baseRes) | |
Constructor for Voxel Grid. | |
~VoxelGrid () | |
Destructor for Voxel Grid. | |
ngl::Vec3 | array3DIndexesFromCoordinate (float _i, float _j, float _k) const |
get 3D array indexes from coordinate | |
int | arrayIndexFromCoordinate (float _i, float _j, float _k) const |
Get the array index of the m_voxels vector where the coordinate is located. | |
Voxel * | at (float _i, float _j, float _k) |
Get voxel of the m_voxels vector with 3D parameters. Returns a pointer to the boundary voxel if requested voxel is out-of-bounds. | |
void | createLineGrids () |
This function creates the line grids that make up the outer walls of the voxel grid domain. | |
void | createVAO () |
This is an exact copy of the createVAO function in NGL. Creates a vertex array object for the line grids. | |
void | drawLineGrids () |
draws the line grids | |
Voxel * | freeSlip (float _i, float _j, float _k) |
This function returns a pointer to the voxel when the boundary condition is free-slip. | |
float | getBaseRes () const |
Gets the base resolution of the grid. | |
BOUNDARYCONDITION | getBoundaryCondition () const |
Gets the boundary condition. | |
float | getH () const |
Gets the master voxel width of the grid in the x direction. | |
float | getHX () const |
Gets the voxel width of the grid in the x direction. | |
float | getHY () const |
Gets the voxel width of the grid in the y direction. | |
float | getHZ () const |
Gets the voxel width of the grid in the y direction. | |
float | getLengthX () const |
Gets the length of the grid in the x direction. | |
float | getLengthY () const |
Gets the length of the grid in the y direction. | |
float | getLengthZ () const |
Gets the length of the grid in the z direction. | |
ngl::VertexArrayObject * | getLineGridVAO () |
Gets the scale of the grid. | |
int | getPrecisionX () const |
Gets the precision of the grid in the x direction. | |
int | getPrecisionY () const |
Gets the precision of the grid in the y direction. | |
int | getPrecisionZ () const |
Gets the precision of the grid in the z direction. | |
std::vector< Voxel > * | getVoxels () |
Gets the voxels std vector. | |
void | calcValues () |
calculate precision values and voxel widths | |
void | initVoxels () |
intialize the voxels | |
Voxel * | outflow (float _i, float _j, float _k) |
This function returns a pointer to the voxel when the boundary condition is outflow. | |
Voxel * | noSlip (float _i, float _j, float _k) |
This function returns a pointer to the voxel when the boundary condition is no-slip. | |
void | setBaseRes (int _res) |
Sets the base resolution of the voxel grid. | |
void | setBoundaryCondition (const BOUNDARYCONDITION _condition) |
Sets the boundary condition. | |
void | setH (float _val) |
a slot to change the width of the voxels | |
void | setLengthX (float _length) |
Sets the x length of the voxel grid. | |
void | setLengthY (float _length) |
Sets the y length of the voxel grid. | |
void | setLengthZ (float _length) |
Sets the y length of the voxel grid. | |
void | setPrecisionX (int _precision) |
a slot to change the x precision of the voxel grid | |
void | setPrecisionY (int _precision) |
a slot to change the y precision of the voxel grid | |
void | setPrecisionZ (int _precision) |
a slot to change the z precision of the voxel grid | |
Private Attributes | |
int | m_baseRes |
The base resolution of the grid. | |
BOUNDARYCONDITION | m_boundaryCondition |
The boundary condition. | |
std::vector< ngl::vertData > | m_data |
The data (verticies, normals, and uv's) of the line grids. | |
Voxel | m_boundaryVoxel |
An empty voxel for use in function "at()". | |
float | m_h |
The master width of the voxel cell. | |
float | m_hX |
The width of the voxel cell in the x direction. | |
float | m_hY |
The width of the voxel cell in the y direction. | |
float | m_hZ |
The width of the voxel cell in the z direction. | |
float | m_lengthX |
The length of the grid in the x direction. | |
float | m_lengthY |
The length of the grid in the y direction. | |
float | m_lengthZ |
The length of the grid in the z direction. | |
int | m_precisionX |
The precision of the grid in the x direction. | |
int | m_precisionY |
The precision of the grid in the y direction. | |
int | m_precisionZ |
The precision of the grid in the z direction. | |
ngl::VertexArrayObject * | m_lineGridVAO |
The vertex array object of the line grids. | |
std::vector< Voxel > | m_voxels |
The voxels of the grid. |
The functions and elements of a VoxelGrid.
VoxelGrid::VoxelGrid | ( | const float | _lengthX, |
const float | _lengthY, | ||
const float | _lengthZ, | ||
const int | _baseRes | ||
) |
Constructor for Voxel Grid.
[in] | _lengthX | the length of the grid in the x direction. |
[in] | _lengthY | the length of the grid in the y direction. |
[in] | _lengthZ | the length of the grid in the z direction. |
[in] | _baseRes | the base resolution of the grid. |
1. Create the line grid vertex array object.
2. Initialize the member variables.
3. Calculate the precision and voxel width values.
4. Initialize the boundary voxel values.
5. Initialize the m_voxels vector.
6. Create the line grids by initializing the line grid data.
Destructor for Voxel Grid.
1. De-allocate the memory.
ngl::Vec3 VoxelGrid::array3DIndexesFromCoordinate | ( | float | _i, |
float | _j, | ||
float | _k | ||
) | const |
get 3D array indexes from coordinate
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. Calculate the indexes from a coordinate and return a 3D vector.
int VoxelGrid::arrayIndexFromCoordinate | ( | float | _i, |
float | _j, | ||
float | _k | ||
) | const |
Get the array index of the m_voxels vector where the coordinate is located.
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. Calculate the indexes from a coordinate and return the index of the 1D m_voxel vector.
Voxel * VoxelGrid::at | ( | float | _i, |
float | _j, | ||
float | _k | ||
) |
Get voxel of the m_voxels vector with 3D parameters. Returns a pointer to the boundary voxel if requested voxel is out-of-bounds.
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. Return a pointer to the voxel in m_voxels at the location of the 3D indexes. Returns a pointer to m_boundaryVoxel if the requested voxel is out of bounds. The values of m_boundaryVoxel are set based on the boundary condition.
void VoxelGrid::calcValues | ( | ) |
calculate precision values and voxel widths
1. Calculate the voxel width and precision values.
void VoxelGrid::createLineGrids | ( | ) |
This function creates the line grids that make up the outer walls of the voxel grid domain.
1. Initializes the line grid data based on the x, y, and z grid domain lengths.
void VoxelGrid::createVAO | ( | ) |
This is an exact copy of the createVAO function in NGL. Creates a vertex array object for the line grids.
1. This function creates the line grid vertex array objects. It is an exact copy of the createVAO function in NGL written by Jon Macey.
void VoxelGrid::drawLineGrids | ( | ) |
draws the line grids
1. Bind and draw the line grid vertex array object.
Voxel * VoxelGrid::freeSlip | ( | float | _i, |
float | _j, | ||
float | _k | ||
) |
This function returns a pointer to the voxel when the boundary condition is free-slip.
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. If the requested voxel is inside the voxel grid domain, a pointer to the voxel is returned. If the requested voxel is out of bounds, a pointer to m_boundaryVoxel is returned. Before m_boundaryVoxel is returned, the values in m_boundaryVoxel are set to reflect the free-slip boundary condition.
float VoxelGrid::getBaseRes | ( | ) | const [inline] |
Gets the base resolution of the grid.
BOUNDARYCONDITION VoxelGrid::getBoundaryCondition | ( | ) | const [inline] |
Gets the boundary condition.
float VoxelGrid::getH | ( | ) | const [inline] |
Gets the master voxel width of the grid in the x direction.
float VoxelGrid::getHX | ( | ) | const [inline] |
Gets the voxel width of the grid in the x direction.
float VoxelGrid::getHY | ( | ) | const [inline] |
Gets the voxel width of the grid in the y direction.
float VoxelGrid::getHZ | ( | ) | const [inline] |
Gets the voxel width of the grid in the y direction.
float VoxelGrid::getLengthX | ( | ) | const [inline] |
Gets the length of the grid in the x direction.
float VoxelGrid::getLengthY | ( | ) | const [inline] |
Gets the length of the grid in the y direction.
float VoxelGrid::getLengthZ | ( | ) | const [inline] |
Gets the length of the grid in the z direction.
ngl::VertexArrayObject* VoxelGrid::getLineGridVAO | ( | ) | [inline] |
Gets the scale of the grid.
int VoxelGrid::getPrecisionX | ( | ) | const [inline] |
Gets the precision of the grid in the x direction.
int VoxelGrid::getPrecisionY | ( | ) | const [inline] |
Gets the precision of the grid in the y direction.
int VoxelGrid::getPrecisionZ | ( | ) | const [inline] |
Gets the precision of the grid in the z direction.
std::vector<Voxel>* VoxelGrid::getVoxels | ( | ) | [inline] |
Gets the voxels std vector.
void VoxelGrid::initVoxels | ( | ) |
intialize the voxels
1. Initialize the m_voxels vector by pushing empty voxels into the vector. The total number of voxels is dependent on the precision values.
Voxel * VoxelGrid::noSlip | ( | float | _i, |
float | _j, | ||
float | _k | ||
) |
This function returns a pointer to the voxel when the boundary condition is no-slip.
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. If the requested voxel is inside the voxel grid domain, a pointer to the voxel is returned. If the requested voxel is out of bounds, a pointer to m_boundaryVoxel is returned. Before m_boundaryVoxel is returned, the values are set to reflect the no-slip boundary condition.
Voxel * VoxelGrid::outflow | ( | float | _i, |
float | _j, | ||
float | _k | ||
) |
This function returns a pointer to the voxel when the boundary condition is outflow.
[in] | _i | the index of the voxel grid in the x direction |
[in] | _j | the index of the voxel grid in the y direction |
[in] | _k | the index of the voxel grid in the z direction |
1. If the requested voxel is inside the voxel grid domain, a pointer to the voxel is returned. If the requested voxel is out of bounds, a pointer to m_boundaryVoxel is returned. Before m_boundaryVoxel is returned, the values are set to reflect the outflow boundary condition.
void VoxelGrid::setBaseRes | ( | int | _res | ) | [inline] |
Sets the base resolution of the voxel grid.
[in] | _length | the value to be set to the base resolution of the voxel grid |
void VoxelGrid::setBoundaryCondition | ( | const BOUNDARYCONDITION | _condition | ) | [inline] |
Sets the boundary condition.
[in] | _condition | the value to be set to the m_boundaryCondition variable |
void VoxelGrid::setH | ( | float | _val | ) | [inline] |
a slot to change the width of the voxels
[in] | _val | the value to be set to the width of the voxels |
void VoxelGrid::setLengthX | ( | float | _length | ) | [inline] |
Sets the x length of the voxel grid.
[in] | _length | the value to be set to the x length of the voxel grid |
void VoxelGrid::setLengthY | ( | float | _length | ) | [inline] |
Sets the y length of the voxel grid.
[in] | _length | the value to be set to the y length of the voxel grid |
void VoxelGrid::setLengthZ | ( | float | _length | ) | [inline] |
Sets the y length of the voxel grid.
[in] | _length | the value to be set to the z length of the voxel grid |
void VoxelGrid::setPrecisionX | ( | int | _precision | ) | [inline] |
a slot to change the x precision of the voxel grid
[in] | _precision | the value to be set to the x precision of the voxel grid |
void VoxelGrid::setPrecisionY | ( | int | _precision | ) | [inline] |
a slot to change the y precision of the voxel grid
[in] | _precision | the value to be set to the y precision of the voxel grid |
void VoxelGrid::setPrecisionZ | ( | int | _precision | ) | [inline] |
a slot to change the z precision of the voxel grid
[in] | _precision | the value to be set to the z precision of the voxel grid |