VoxelCube Class Reference

A cube of voxels, some of which may be transparent. More...

#include <VoxelCube.h>

Collaboration diagram for VoxelCube:

Collaboration graph
[legend]
List of all members.

Public Methods

void draw (bool bTranslateToCenter)
 Draw our voxels as cubes, with glutSolidCube. More...

double getMinimumFarPlane (Vertex COP, Vertex lookatPoint) const
 We don't want our far plane to clip the back of our VoxelCube. This method gives you the minimum far plane that won't clip.

bool isTransparent (int x, int y, int z) const
 Returns whether a particular voxel has been carved (and is therefore transparent). More...

bool isTransparent (const VoxelPos &p) const
 Returns whether a particular voxel has been carved (and is therefore transparent).

int getVoxelsPerSide () const
 If you cube this number, you get the total number of voxels in the VoxelCube.

void fillItemBufferArray (Viewpoint &image)
 Draws the cube to an item buffer, and converts that into an array of integers. The caller must allocate the array, and its size must be width x height.

std::vector< Vertex > calculateVoxelCorners (int x, int y, int z) const
 Get the 8 corners of a given voxel. More...

Rect< double > getBoundingRect (std::vector< Vertex > &vertices, const double modelMatrix[16], const double projMatrix[16], const int viewport[4]) const
 Gets the projected bounding-rectangle for a set of vertices.

unsigned int PosToIdentifier (int x, int y, int z) const
 Gets the item-buffer identifier for a given voxel.

unsigned int PosToIndex (int x, int y, int z) const
 We have a one-d array of voxels. This maps a 3d coordinate to a position in our voxel array.

Vertex getCenter () const
 Gets the position of the center of the voxel cube.

double getVoxelSize () const
 Returns the size (width or height, it's all symmetrical) of each voxel.

unsigned int GetEdgeID (unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo)
 Helper method for marching cubes. More...

void setFinalColor (SurfaceVoxelList::iterator i, RgbByte &color)
 Adds a voxel to our final list of colored voxels, and assigns it a color. More...

void setVoxelsPerSide (int vps)
 Set the number of voxels on each side, meaning that the total # voxels would be vps^3. More...

void exposeSurroundingVoxels (SurfaceVoxelList::iterator i)
 When a voxel disappears, some of its neighbors may be made visible. This exposes any solid, previously unexposed, neighboring voxels. More...

void VoxelCube::setTransparent (SurfaceVoxelList::iterator i)
 Set a specified voxel cube to be transparent. Note that you MUST also remove the corresponding voxel from the surface voxel list, after calling this method.

void setCenter (Vertex new_center)
void setVoxelSize (double voxel_size)
 This sets the width of every voxel to voxel_size.

void makeMesh (float isoLevel, QEM::ProgMesh &mesh)
 Make a polygonal mesh out of our voxel grid. More...


Public Attributes

SurfaceVoxelList svl

Detailed Description

A cube of voxels, some of which may be transparent.

In addition to drawing the opaque voxels, this class can return an item buffer for an arbitrary perspective.

Definition at line 137 of file VoxelCube.h.


Member Function Documentation

std::vector< Vertex > VoxelCube::calculateVoxelCorners int    xpos,
int    ypos,
int    zpos
const
 

Get the 8 corners of a given voxel.

Returns:
vector of eight 3d coordinates of this voxel's corners.

Definition at line 30 of file VoxelCube.cpp.

void VoxelCube::draw bool    bTranslateToCenter
 

Draw our voxels as cubes, with glutSolidCube.

If our list of colored voxels has been filled in, then we draw that; otherwise, we draw our list of uncolored voxels.

Definition at line 622 of file VoxelCube.cpp.

void VoxelCube::exposeSurroundingVoxels SurfaceVoxelList::iterator    i
 

When a voxel disappears, some of its neighbors may be made visible. This exposes any solid, previously unexposed, neighboring voxels.

Voxels that surround the given voxel, that are not already marked transparent (in "solids") will be added to the surface voxel list (svl).

Definition at line 80 of file VoxelCube.cpp.

Referenced by Scanner::carveVoxels().

unsigned int VoxelCube::GetEdgeID unsigned int    nX,
unsigned int    nY,
unsigned int    nZ,
unsigned int    nEdgeNo
 

Helper method for marching cubes.

This code was adapted from code by Raghavendra Chandrashekara, available at...

http://astronomy.swin.edu.au/~pbourke/modelling/polygonise/rchandra/

Definition at line 371 of file VoxelCube.cpp.

Referenced by makeMesh().

bool VoxelCube::isTransparent int    x,
int    y,
int    z
const
 

Returns whether a particular voxel has been carved (and is therefore transparent).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 744 of file VoxelCube.cpp.

Referenced by Scanner::carveVoxels(), exposeSurroundingVoxels(), isTransparent(), and makeMesh().

void VoxelCube::makeMesh float    isoLevel,
QEM::ProgMesh   mesh
 

Make a polygonal mesh out of our voxel grid.

This code was adapted from code by Raghavendra Chandrashekara, available at...

http://astronomy.swin.edu.au/~pbourke/modelling/polygonise/rchandra/

Definition at line 437 of file VoxelCube.cpp.

Referenced by Scanner::carveVoxels().

void VoxelCube::setFinalColor SurfaceVoxelList::iterator    i,
RgbByte &    color
 

Adds a voxel to our final list of colored voxels, and assigns it a color.

This method can only be called once for each surface voxel (calling it twice for a voxel would mean that there'd be two identically-positioned-voxels in the svl -- a bad idea.

Note:
this method is kind of a hack.

Definition at line 122 of file VoxelCube.cpp.

Referenced by Scanner::carveVoxels().

void VoxelCube::setVoxelsPerSide int    vps
 

Set the number of voxels on each side, meaning that the total # voxels would be vps^3.

Todo:
We are currently limited to 255x255x255, because we can only read back 24bpp from the item buffer. It would be very nice to have a 32-bit item buffer someday.

Definition at line 757 of file VoxelCube.cpp.

Referenced by CChildView::openFile().


The documentation for this class was generated from the following files:
Generated on Tue May 21 03:35:15 2002 for Archimedes by doxygen1.2.15