Public Member Functions | Private Attributes
VoxelGrid Class Reference

The functions and elements of a VoxelGrid. More...

#include <VoxelGrid.h>

List of all members.

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.
Voxelat (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
VoxelfreeSlip (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
Voxeloutflow (float _i, float _j, float _k)
 This function returns a pointer to the voxel when the boundary condition is outflow.
VoxelnoSlip (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< Voxelm_voxels
 The voxels of the grid.

Detailed Description

The functions and elements of a VoxelGrid.


Constructor & Destructor Documentation

VoxelGrid::VoxelGrid ( const float  _lengthX,
const float  _lengthY,
const float  _lengthZ,
const int  _baseRes 
)

Constructor for Voxel Grid.

Parameters:
[in]_lengthXthe length of the grid in the x direction.
[in]_lengthYthe length of the grid in the y direction.
[in]_lengthZthe length of the grid in the z direction.
[in]_baseResthe 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.


Member Function Documentation

ngl::Vec3 VoxelGrid::array3DIndexesFromCoordinate ( float  _i,
float  _j,
float  _k 
) const

get 3D array indexes from coordinate

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
a vector of the 3D indicies of the voxel where the coordinate is located.

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.

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
the index of m_voxels where the coordinate is located.

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.

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
A pointer to the voxel in m_voxels. Returns a pointer to a boundary voxel if it is out-of-bounds.

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.

calculate precision values and voxel widths

1. Calculate the voxel width and precision values.

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.

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.

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.

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
A pointer to the voxel in m_voxels. Returns a pointer to a boundary voxel if it is out-of-bounds.

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.

Returns:
the m_baseRes variable
BOUNDARYCONDITION VoxelGrid::getBoundaryCondition ( ) const [inline]

Gets the boundary condition.

Returns:
the m_boundaryCondition variable
float VoxelGrid::getH ( ) const [inline]

Gets the master voxel width of the grid in the x direction.

Returns:
the m_h variable
float VoxelGrid::getHX ( ) const [inline]

Gets the voxel width of the grid in the x direction.

Returns:
the m_hX variable
float VoxelGrid::getHY ( ) const [inline]

Gets the voxel width of the grid in the y direction.

Returns:
the m_hY variable
float VoxelGrid::getHZ ( ) const [inline]

Gets the voxel width of the grid in the y direction.

Returns:
the m_hZ variable
float VoxelGrid::getLengthX ( ) const [inline]

Gets the length of the grid in the x direction.

Returns:
the m_lengthX variable
float VoxelGrid::getLengthY ( ) const [inline]

Gets the length of the grid in the y direction.

Returns:
the m_lengthY variable
float VoxelGrid::getLengthZ ( ) const [inline]

Gets the length of the grid in the z direction.

Returns:
the m_lengthZ variable
ngl::VertexArrayObject* VoxelGrid::getLineGridVAO ( ) [inline]

Gets the scale of the grid.

Returns:
the m_scale variable
int VoxelGrid::getPrecisionX ( ) const [inline]

Gets the precision of the grid in the x direction.

Returns:
the m_precisionX variable
int VoxelGrid::getPrecisionY ( ) const [inline]

Gets the precision of the grid in the y direction.

Returns:
the m_precisionY variable
int VoxelGrid::getPrecisionZ ( ) const [inline]

Gets the precision of the grid in the z direction.

Returns:
the m_precisionZ variable
std::vector<Voxel>* VoxelGrid::getVoxels ( ) [inline]

Gets the voxels std vector.

Returns:
the m_voxels std vector

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.

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
A pointer to the voxel in m_voxels. Returns a pointer to a boundary voxel if it is out-of-bounds.

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.

Parameters:
[in]_ithe index of the voxel grid in the x direction
[in]_jthe index of the voxel grid in the y direction
[in]_kthe index of the voxel grid in the z direction
Returns:
A pointer to the voxel in m_voxels. Returns a pointer to a boundary voxel if it is out-of-bounds.

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.

Parameters:
[in]_lengththe value to be set to the base resolution of the voxel grid
void VoxelGrid::setBoundaryCondition ( const BOUNDARYCONDITION  _condition) [inline]

Sets the boundary condition.

Parameters:
[in]_conditionthe value to be set to the m_boundaryCondition variable
void VoxelGrid::setH ( float  _val) [inline]

a slot to change the width of the voxels

Parameters:
[in]_valthe value to be set to the width of the voxels
void VoxelGrid::setLengthX ( float  _length) [inline]

Sets the x length of the voxel grid.

Parameters:
[in]_lengththe 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.

Parameters:
[in]_lengththe 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.

Parameters:
[in]_lengththe 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

Parameters:
[in]_precisionthe 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

Parameters:
[in]_precisionthe 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

Parameters:
[in]_precisionthe value to be set to the z precision of the voxel grid

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables