voxel_1_c Class Reference

Voxel class for the triangle grid. More...

#include <voxel_1.h>

Inheritance diagram for voxel_1_c:

Inheritance graph
[legend]
Collaboration diagram for voxel_1_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 voxel_1_c (unsigned int x, unsigned int y, unsigned int z, const gridType_c *gt, voxel_type init=0)
 voxel_1_c (xmlParser_c &pars, const gridType_c *gt)
 voxel_1_c (const voxel_c &orig)
 voxel_1_c (const voxel_c *orig)
void transformPoint (int *x, int *y, int *z, unsigned int trans) const
 this function transforms the given point by the given transformation around the origin
bool transform (unsigned int nr)
 all possible orientations of one piece can be generated.
void minimizePiece (void)
 changes the size of the voxel space to the smallest size so that all voxels whose value is not 0 can be contained.
bool identicalInBB (const voxel_c *op, bool includeColors=true) const
 Comparison of two voxel spaces.
bool getNeighbor (unsigned int idx, unsigned int typ, int x, int y, int z, int *xn, int *yn, int *zn) const
 returns the coordinates for a neighbour to the given voxel
virtual void scale (unsigned int amount, bool grid)
 scale the space, making x by x by x cubes out of single cubes
void resizeInclude (int &px, int &py, int &pz)
 resizes and translates the space so that the the given voxel can be included the function returns the new coordinate of the point.
bool validCoordinate (int x, int y, int z) const
 Return if a given coordinate is valid to use.
bool onGrid (int x, int y, int z) const
 this function is used to find out if the given position is of the same voxel type as the voxel at position 0.
virtual bool meshParamsValid (double bevel, double offset) const
virtual void getConnectionFace (int x, int y, int z, int n, double bevel, double offset, std::vector< float > &faceCorners) const
 this function must return a polygon that is the connecting face to the neighbor n for the voxel at position x, y, z The function is used by the default implementation of getMesh to generate the default basis mesh it is also used by the 3D cursor drawing code
virtual void calculateSize (float *x, float *y, float *z) const
 calculate the size, that the returned mesh has
virtual void recalcSpaceCoordinates (float *x, float *y, float *) const

Private Member Functions

void operator= (const voxel_1_c &)


Detailed Description

Voxel class for the triangle grid.

This grid is a bit more irregular then the others. It has in a way (depending on how you look at it) either 2 different axes, or 4 axes, of which one is different.

The grid is a stack of planes of tightly packed triangles. The grid in each plane is identical. But on the plane you have 2 different triangles: one halve points up the other halve points down.

This means that you can move along the z-axis (the stacking direction) in one voxel steps, but in teh other directions only in 2 voxel steps.


Constructor & Destructor Documentation

voxel_1_c::voxel_1_c ( unsigned int  x,
unsigned int  y,
unsigned int  z,
const gridType_c gt,
voxel_type  init = 0 
) [inline]

voxel_1_c::voxel_1_c ( xmlParser_c pars,
const gridType_c gt 
) [inline]

voxel_1_c::voxel_1_c ( const voxel_c orig  )  [inline]

voxel_1_c::voxel_1_c ( const voxel_c orig  )  [inline]


Member Function Documentation

void voxel_1_c::calculateSize ( float *  x,
float *  y,
float *  z 
) const [virtual]

calculate the size, that the returned mesh has

Reimplemented from voxel_c.

References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), and HEIGHT.

void voxel_1_c::getConnectionFace ( int  ,
int  ,
int  ,
int  ,
double  ,
double  ,
std::vector< float > &   
) const [virtual]

this function must return a polygon that is the connecting face to the neighbor n for the voxel at position x, y, z The function is used by the default implementation of getMesh to generate the default basis mesh it is also used by the 3D cursor drawing code

Reimplemented from voxel_c.

References HEIGHT.

bool voxel_1_c::getNeighbor ( unsigned int  idx,
unsigned int  typ,
int  x,
int  y,
int  z,
int *  xn,
int *  yn,
int *  zn 
) const [virtual]

returns the coordinates for a neighbour to the given voxel

idx is the index if the neighbour, if you want the next neighbour, give the next number typ is what kind of neighbour you want, face (0), edge (1) or corner (2) x, y, z coordinate for the source xn, yn, zn, coordinate for the neighbour return true, when a valid neighbour with that index exists

This function is different for different grids. There is no default implementation, so each grid has to define its own version of this function

Implements voxel_c.

bool voxel_1_c::identicalInBB ( const voxel_c op,
bool  includeColors = true 
) const [virtual]

Comparison of two voxel spaces.

2 voxel spaces are identical, if their bounding boxes have the same size and the voxels within there boxes is identical

if includeColors is true, the colours are included in the comparison, meaning when the colours differ the shapes are not equal, otherwise only the states are compared

There are special conditions to take care in different grid (e.g alignment along a bigger grid) so this function can be overloaded. The default implementation simply treats all voxels equal

Reimplemented from voxel_c.

References voxel_c::boundX1(), voxel_c::boundY1(), voxel_c::bx1, voxel_c::by1, and voxel_c::identicalInBB().

bool voxel_1_c::meshParamsValid ( double  bevel,
double  offset 
) const [virtual]

Reimplemented from voxel_c.

void voxel_1_c::minimizePiece ( void   )  [virtual]

changes the size of the voxel space to the smallest size so that all voxels whose value is not 0 can be contained.

as in some grids there are special conditions to consider when doing this operation the function can be overloaded. This default implementation will minimize to the bounding box.

Reimplemented from voxel_c.

References voxel_c::bx1, voxel_c::by1, voxel_c::resize(), voxel_c::sx, voxel_c::sy, voxel_c::sz, and voxel_c::translate().

bool voxel_1_c::onGrid ( int  x,
int  y,
int  z 
) const [virtual]

this function is used to find out if the given position is of the same voxel type as the voxel at position 0.

This is used to find out if a piece can be placed at a certain position in a voxel grid

Implements voxel_c.

void voxel_1_c::operator= ( const voxel_1_c  )  [private]

void voxel_1_c::recalcSpaceCoordinates ( float *  x,
float *  y,
float *   
) const [virtual]

Reimplemented from voxel_c.

References HEIGHT.

void voxel_1_c::resizeInclude ( int &  px,
int &  py,
int &  pz 
) [virtual]

resizes and translates the space so that the the given voxel can be included the function returns the new coordinate of the point.

Each grid has to implement it's own version because there are different kinds of supergrids that are imposed on the normal grid

Implements voxel_c.

References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::resize(), and voxel_c::translate().

void voxel_1_c::scale ( unsigned int  amount,
bool  grid 
) [virtual]

scale the space, making x by x by x cubes out of single cubes

This must be done differently by all grids. The default implementation doesn't do anything. It's just there to allow grids without scaling as not all grid have such a possibility (e.g. spheres can't be scaled) if grid is true (not all functions need to support this) the result it not filled, but rather a grid with only the outer edges filled

Reimplemented from voxel_c.

References voxel_c::hx, voxel_c::hy, voxel_c::hz, voxel_c::isEmpty2(), voxel_c::recalcBoundingBox(), voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::sz, voxel_c::voxels, and voxel_c::VX_EMPTY.

bool voxel_1_c::transform ( unsigned int  nr  )  [virtual]

all possible orientations of one piece can be generated.

using this function by iterating nr from 0 to NUM_TRANSFORMATIONS (24 for cubes) excluding because in some spacegrids there might be transformations that do not exist with certain shapes, this function returns a bool showing if the transformation action has succeeded

This must be implmented by all grids separately

Implements voxel_c.

References bt_assert, voxel_c::hx, voxel_c::hy, voxel_c::hz, voxel_c::isEmpty(), voxel_c::recalcBoundingBox(), rotationMatrices, voxel_c::space, voxel_c::sx, voxel_c::sy, voxel_c::symmetries, symmetryInvalid, voxel_c::sz, voxel_c::voxels, and voxel_c::VX_EMPTY.

Referenced by symmetries_1_c::symmetryKnown().

void voxel_1_c::transformPoint ( int *  x,
int *  y,
int *  z,
unsigned int  trans 
) const [virtual]

this function transforms the given point by the given transformation around the origin

Implements voxel_c.

References bt_assert, and rotationMatrices.

bool voxel_1_c::validCoordinate ( int  x,
int  y,
int  z 
) const [virtual]

Return if a given coordinate is valid to use.

In some voxel spaces not all possible coordinates are valid. For example in the sphere grid only the coordinates with (x+y+z) % 2 == 0 are valid This function does that calculation

Implements voxel_c.


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

Generated on Sun Oct 10 10:03:15 2010 for BurrTools by  doxygen 1.5.8