voxel_2_c Class Reference

Voxel class for the sphere grid. More...

#include <voxel_2.h>

Inheritance diagram for voxel_2_c:

Inheritance graph
[legend]
Collaboration diagram for voxel_2_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 voxel_2_c (unsigned int x, unsigned int y, unsigned int z, const gridType_c *gt, voxel_type init=0)
 voxel_2_c (xmlParser_c &pars, const gridType_c *gt)
 voxel_2_c (const voxel_c &orig)
 voxel_2_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 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
void initHotspot (void)
 Initialized the hotspot to a valid position.
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.
virtual 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 Polyhedron * getMesh (float sphere_rad, float connection_rad, float round, float offset, int recursion, float inner_rad, float hole_diam) const
virtual Polyhedron * getDrawingMesh (void) const
 returns the drawing mesh.
virtual Polyhedron * getWireframeMesh (void) const
 returns the drawing mesh for wrireframe mode.
virtual void getConnectionFace (int x, int y, int z, int n, double bevel, double offset, std::vector< float > &) 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 *, float *, float *) const

Private Member Functions

virtual Polyhedron * getMeshInternal (float sphere_rad, float connection_rad, float round, float offset, int recursion, float inner_rad, float hole_diam, bool fast) const
void operator= (const voxel_2_c &)


Detailed Description

Voxel class for the sphere grid.

The sphere grid is something special. It is the only grid where transformations can fail.

The grid is done by placing the spheres in a 3-dimensional checker board pattern. That results in a regular placement of spheres.

The other possible embedding would be the hexagonal planes, but this embedding is much more irregular.

The sphere grid is a lot of transformations but depending on the actual shape only some of them are actually doable, others would result in spheres ending up outside the grid positions. Those transformations will not be done.

An other irregularity is the neighbor function, which only returns first grade neighbors (face touching in the other grids). The other neighbors don't make sense.


Constructor & Destructor Documentation

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

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

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

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


Member Function Documentation

void voxel_2_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(), and voxel_c::getZ().

void voxel_2_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 bt_assert.

Polyhedron * voxel_2_c::getDrawingMesh ( void   )  const [virtual]

returns the drawing mesh.

ATTENTION for the sake of speed this mesh will not be a proper halfedge mesh, most edges will be open, meaning they don't have a pair, which is invalid and makes some functions not work, but it is ok for drawing

Reimplemented from voxel_c.

References getMeshInternal().

Referenced by getWireframeMesh().

Polyhedron * voxel_2_c::getMesh ( float  sphere_rad,
float  connection_rad,
float  round,
float  offset,
int  recursion,
float  inner_rad,
float  hole_diam 
) const [virtual]

References getMeshInternal().

Referenced by stlExporter_2_c::getMesh().

Polyhedron * voxel_2_c::getMeshInternal ( float  sphere_rad,
float  connection_rad,
float  round,
float  offset,
int  recursion,
float  inner_rad,
float  hole_diam,
bool  fast 
) const [private, virtual]

bool voxel_2_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.

Referenced by getMeshInternal().

Polyhedron * voxel_2_c::getWireframeMesh ( void   )  const [virtual]

returns the drawing mesh for wrireframe mode.

Reimplemented from voxel_c.

References getDrawingMesh().

void voxel_2_c::initHotspot ( void   )  [virtual]

Initialized the hotspot to a valid position.

in some voxelspaces the hotspot needs to be in special places to stay valid after all possible transformations this function sets the hotspot so, that is has this property. As many spaces do not have this requirement there is a default implementation that puts the hotspot at 0;0;0 if you need something special, overwrite this function

Reimplemented from voxel_c.

References voxel_c::getX(), voxel_c::getY(), voxel_c::getZ(), voxel_c::isEmpty(), and voxel_c::setHotspot().

void voxel_2_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::bz1, voxel_c::resize(), voxel_c::sx, voxel_c::sy, voxel_c::sz, and voxel_c::translate().

bool voxel_2_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_2_c::operator= ( const voxel_2_c  )  [private]

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

Reimplemented from voxel_c.

void voxel_2_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().

bool voxel_2_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_2_c::symmetryKnown().

void voxel_2_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_2_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.

Referenced by getMeshInternal().


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