voxel_c Class Reference

This class handles one voxel space. More...

#include <voxel.h>

Inheritance diagram for voxel_c:

Inheritance graph
[legend]
Collaboration diagram for voxel_c:

Collaboration graph
[legend]

List of all members.

Public Types

enum  VoxelState { VX_EMPTY, VX_FILLED, VX_VARIABLE }
 this enumeration defines some values that are used for some of the voxel spaces. More...

Public Member Functions

void skipRecalcBoundingBox (bool skipit)
 enable or diable the update of the bounding box after each operation.
 voxel_c (unsigned int x, unsigned int y, unsigned int z, const gridType_c *gt, voxel_type init=0)
 Creates a new voxel space.
 voxel_c (xmlParser_c &pars, const gridType_c *gt)
 Load a voxel space from xml node.
 voxel_c (const voxel_c &orig)
 Copy constructor using reference.
 voxel_c (const voxel_c *orig)
 Copy constructor using pointer.
virtual ~voxel_c ()
 Destructor.
void copy (const voxel_c *orig)
 make this voxelspace be identical to the one given.
unsigned int getX (void) const
 Return x-size of the voxel space.
unsigned int getY (void) const
 Return y-size of the voxel space.
unsigned int getZ (void) const
 Return z-size of the voxel space.
const gridType_cgetGridType (void) const
 get the gridtype of this voxel space
unsigned int getDiagonal (void) const
 Returns the squared diagonal of the space.
unsigned int getBiggestDimension (void) const
 Returns the value of the biggest out of getX, getY or getZ.
unsigned int getXYZ (void) const
 Get the number of voxels, which is getX()*getY()*getZ().
int getIndex (unsigned int x, unsigned int y, unsigned int z) const
 This function returns the index for a given triple of x, y and z.
bool indexToXYZ (unsigned int index, unsigned int *x, unsigned int *y, unsigned int *z) const
 The inverse of getIndex.
voxel_type get (unsigned int x, unsigned int y, unsigned int z) const
 Get the value of the voxel at position $(x; y; z)$.
voxel_type get2 (int x, int y, int z) const
 same as get but returns VX_EMPTY for each voxel outside the space
voxel_type get (unsigned int p) const
 Get voxel by index.
bool neighbour (unsigned int p, voxel_type val) const
 returns true, if a neighbour of the given voxel has the given value
virtual bool getNeighbor (unsigned int idx, unsigned int typ, int x, int y, int z, int *xn, int *yn, int *zn) const =0
 returns the coordinates for a neighbour to the given voxel
void set (unsigned int x, unsigned int y, unsigned int z, voxel_type val)
 the x, y, z variant of the set function.
void set (unsigned int p, voxel_type val)
 The 1-dimensional variant of the set function.
void setAll (voxel_type val)
 Set all the voxels to the given value.
unsigned int count (voxel_type val) const
 counts the number of voxels that have the given value
virtual void transformPoint (int *x, int *y, int *z, unsigned int trans) const =0
 this function transforms the given point by the given transformation around the origin
void translate (int dx, int dy, int dz, voxel_type filler)
 shift the space around.
virtual 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.
unsigned int boundX1 (void) const
 Get the coordinate of the Bounding Box.
unsigned int boundX2 (void) const
 Get the coordinate of the Bounding Box.
unsigned int boundY1 (void) const
 Get the coordinate of the Bounding Box.
unsigned int boundY2 (void) const
 Get the coordinate of the Bounding Box.
unsigned int boundZ1 (void) const
 Get the coordinate of the Bounding Box.
unsigned int boundZ2 (void) const
 Get the coordinate of the Bounding Box.
bool getBoundingBox (unsigned char trans, int *x1, int *y1, int *z1, int *x2=0, int *y2=0, int *z2=0) const
 get the bounding box of a rotated voxel space
bool operator== (const voxel_c &op) const
 Comparison of two voxel spaces.
virtual bool identicalInBB (const voxel_c *op, bool includeColors=true) const
 Comparison of two voxel spaces.
bool identicalWithRots (const voxel_c *op, bool includeMirror, bool includeColors) const
 comparison of 2 voxel spaces.
unsigned char getMirrorTransform (const voxel_c *op) const
 this function returns the transformation, that transforms this voxel space into the as parameter given one
void resize (unsigned int nsx, unsigned int nsy, unsigned int nsz, voxel_type filler)
 resizes the voxelspace.
virtual void resizeInclude (int &px, int &py, int &pz)=0
 resizes and translates the space so that the the given voxel can be included the function returns the new coordinate of the point.
virtual void scale (unsigned int amount, bool grid=false)
 scale the space, making x by x by x cubes out of single cubes
virtual bool scaleDown (unsigned char by, bool action)
 Scale down voxel space by a certain amount.
bool connected (char type, bool inverse, voxel_type value, bool outsideZ=true) const
 checks the voxelspace for connectedness.
void fillHoles (char type)
 fills in all empty voxels that are completely surrounded by non empty voxels,
virtual bool transform (unsigned int nr)=0
 all possible orientations of one piece can be generated.
symmetries_t selfSymmetries (void) const
 This function returns the self symmetries of this voxel space.
unsigned char normalizeTransformation (unsigned char trans) const
 this function returns the smallest transformation number that results in an identical shape for this voxel space
unsigned int countState (int state) const
 Counts how many voxels there are of a certain state.
void save (xmlWriter_c &xml) const
 used to save to XML
int getHx (void) const
 Get the hotspot.
int getHy (void) const
 Get the hotspot.
int getHz (void) const
 Get the hotspot.
void setHotspot (int x, int y, int z)
 Set the hotspot.
virtual void initHotspot (void)
 Initialized the hotspot to a valid position.
bool getHotspot (unsigned char trans, int *x, int *y, int *z) const
 this function returns the hotspot of the rotated space.
const std::string & getName (void) const
 function to get the name
void setName (const std::string &n)
 Set the name for this voxel space.
int getWeight (void) const
 get the weight of this space
void setWeight (int w)
 set the weight of this space
virtual bool validCoordinate (int x, int y, int z) const =0
 Return if a given coordinate is valid to use.
bool unionintersect (const voxel_c *va, int xa, int ya, int za, const voxel_c *vb, int xb, int yb, int zb)
virtual bool onGrid (int x, int y, int z) const =0
 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 (double bevel, double offset) const
 this function returns a polyhedron mesh of this shape.
virtual bool meshParamsValid (double, double) 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, int, int, int, double, double, 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
int getState (unsigned int x, unsigned int y, unsigned int z) const
 Functions to get the voxel state or color of a single voxel.
int getState2 (int x, int y, int z) const
int getState (unsigned int i) const
unsigned int getColor (unsigned int x, unsigned int y, unsigned int z) const
unsigned int getColor2 (int x, int y, int z) const
unsigned int getColor (unsigned int i) const
bool isEmpty (unsigned int x, unsigned int y, unsigned int z) const
 Functions to ask, if a voxel has a certain state.
bool isEmpty2 (int x, int y, int z) const
bool isEmpty (unsigned int i) const
bool isFilled (unsigned int x, unsigned int y, unsigned int z) const
bool isFilled2 (int x, int y, int z) const
bool isFilled (unsigned int i) const
bool isVariable (unsigned int x, unsigned int y, unsigned int z) const
bool isVariable2 (int x, int y, int z) const
bool isVariable (unsigned int i) const
void setState (unsigned int x, unsigned int y, unsigned int z, int state)
 Functions to set the state or color of a certain voxel.
void setColor (unsigned int x, unsigned int y, unsigned int z, unsigned int color)
void setState (unsigned int i, int state)
void setColor (unsigned int i, unsigned int color)

Protected Member Functions

void recalcBoundingBox (void)
 updates the bounding box to fit the current shape inside the space.

Protected Attributes

const gridType_cgt
 each voxel needs to know the parameters for its space grid
unsigned int sx
 The x size of the space.
unsigned int sy
 The y size of the space.
unsigned int sz
 The z size of the space.
unsigned int voxels
 The number of voxel inside the space.
voxel_typespace
 The space.
unsigned int bx1
 lower x-coordinate of the Bounding Box
unsigned int bx2
 upper x-coordinate of the Bounding Box
unsigned int by1
 lower y-coordinate of the Bounding Box
unsigned int by2
 upper y-coordinate of the Bounding Box
unsigned int bz1
 lower z-coordinate of the Bounding Box
unsigned int bz2
 upper z-coordinate of the Bounding Box
bool doRecalc
 bounding box recalculation is only done when this is true
symmetries_t symmetries
 the self symmetries of this voxel space.
int hx
 x-coordinate of The Hot Spot
int hy
 y-coordinate of The Hot Spot
int hz
 z-coordinate of The Hot Spot
std::string name
 The name of the shape.
int weight
 Weight of the shape.
int * BbHsCache
 A cache for hotspot and bounding box coordinates of the rotated voxel.

Private Member Functions

void unionFind (int *tree, char type, bool inverse, voxel_type value, bool outsideZ) const
 This function is used by conneced and fill holes.
virtual Polyhedron * getMeshInternal (double bevel, double offset, bool fast) const
void operator= (const voxel_c &)
enum  VoxelAction { ACT_FIXED, ACT_VARIABLE, ACT_DECOLOR }
 Defined possible actions for the actionOnSpace function. More...
void actionOnSpace (VoxelAction action, bool inside)
 Change the state of some or all voxels.


Detailed Description

This class handles one voxel space.

For the transformation of a voxel space all the grid types use transformation matrices that are in the corresponding tabs_x directory in the file rotmatrix.inc.

A voxel space is a 3 dimensional representation of a space using some kind of regular units to fill the space. This is only an abstract base class that provides functionality common to all other voxel spaces. To have a real voxel space (e.g. made out of unit cubes) you need to inherit from this class and provide functions for rotation and other things.

Each voxel has 2 information: its state and its color. State is one of the VoxelState enums values. And color can right now be one of 64 possible values

These tables contain all rotation matrices for all orientations of the grid. More in Transformations and Symmetries in BurrTools

The base class of the voxel space is not suitable for any grid because it misses functions. The derived classes implement those missing functions.

The glasses for the tetrahedral-octahedral and for the rhombic grid are derrived from the cube grid (voxel_0_c) because they just superimpose another larger grid onto the standard cube grid to achieve their goals


Member Enumeration Documentation

Defined possible actions for the actionOnSpace function.

Enumerator:
ACT_FIXED  Make voxel fixed.
ACT_VARIABLE  Make voxels variable.
ACT_DECOLOR  Set color to neutral.

this enumeration defines some values that are used for some of the voxel spaces.

generally there will be 2 types of usage for voxelspace some single-piece and one multi-piece. The single piece will use this enumeration to define a puzzle piece or a solution shape the multi-piece will use the values of the voxels to distinguish between different pieces

Enumerator:
VX_EMPTY  This is used for empty voxels.
VX_FILLED  This value is used for filled foxels.
VX_VARIABLE  This value is used for voxels with variable content.


Constructor & Destructor Documentation

voxel_c::voxel_c ( unsigned int  x,
unsigned int  y,
unsigned int  z,
const gridType_c gt,
voxel_type  init = 0 
)

Creates a new voxel space.

Its of given size and initializes all values to init.

References BbHsCache, bt_assert, bx1, bx2, by1, by2, bz1, bz2, doRecalc, symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gt, space, symmetries, symmetryInvalid, and voxels.

voxel_c::voxel_c ( xmlParser_c pars,
const gridType_c gt 
)

voxel_c::voxel_c ( const voxel_c orig  ) 

Copy constructor using reference.

Transformation allows to have a rotated version of this voxel space

References BbHsCache, bt_assert, bx1, bx2, by1, by2, bz1, bz2, doRecalc, symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gt, space, symmetries, symmetryInvalid, and voxels.

voxel_c::voxel_c ( const voxel_c orig  ) 

Copy constructor using pointer.

Transformation allows to have a rotated version of this voxel space

References BbHsCache, bt_assert, bx1, bx2, by1, by2, bz1, bz2, doRecalc, symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gt, space, symmetries, symmetryInvalid, and voxels.

voxel_c::~voxel_c (  )  [virtual]

Destructor.

Free the space

References BbHsCache, and space.


Member Function Documentation

void voxel_c::actionOnSpace ( VoxelAction  action,
bool  inside 
)

Change the state of some or all voxels.

What is done is defined with the enumeration fixed sets voxels to the fixed state, variable sets voxels to variable and decolour removes colours from voxels inside defines where to carry out the action, on inside cubes or on outside cubes inside cubes do have 6 non-empty cubes as neighbours

References ACT_DECOLOR, ACT_FIXED, ACT_VARIABLE, getNeighbor(), getState(), getState2(), getX(), getY(), getZ(), setColor(), setState(), VX_EMPTY, VX_FILLED, and VX_VARIABLE.

unsigned int voxel_c::boundX1 ( void   )  const [inline]

unsigned int voxel_c::boundX2 ( void   )  const [inline]

unsigned int voxel_c::boundY1 ( void   )  const [inline]

unsigned int voxel_c::boundY2 ( void   )  const [inline]

unsigned int voxel_c::boundZ1 ( void   )  const [inline]

unsigned int voxel_c::boundZ2 ( void   )  const [inline]

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

calculate the size, that the returned mesh has

Reimplemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

bool voxel_c::connected ( char  type,
bool  inverse,
voxel_type  value,
bool  outsideZ = true 
) const

checks the voxelspace for connectedness.

It is checked if there is no group of voxels, that is disconnected from the rest of the voxels. There are several different types of connectedness: face, edge, corner. Meaning the voxels are at least connected via a common face, edge or corner

there are also 2 modes: normal mode checks all the voxel that are equal to value and inverse mode checks all the voxels that are not equal to value this is useful for pieces or a result shape that contain voxels of different value but all these values belong to the same piece

normally the outside is one node and voxels that are on the edge of the shape may be merged with the outside, this can be suppressed for the z-axis by setting outsideZ to false

References getIndex(), sx, sy, sz, unionFind(), validCoordinate(), and voxels.

void voxel_c::copy ( const voxel_c orig  ) 

make this voxelspace be identical to the one given.

except for the name field everything is copied

References bx1, bx2, by1, by2, bz1, bz2, getXYZ(), name, space, sx, sy, symmetries, sz, voxels, and weight.

unsigned int voxel_c::count ( voxel_type  val  )  const

counts the number of voxels that have the given value

References getXYZ().

Referenced by countState(), and voxel_3_c::scale().

unsigned int voxel_c::countState ( int  state  )  const

Counts how many voxels there are of a certain state.

Color markings are ignored with this function, only the state is considered

References count(), and getXYZ().

Referenced by assembler_1_c::createMatrix(), assembler_0_c::createMatrix(), stlExporter_2_c::getMesh(), stlExporter_0_c::getMesh(), and assembler_1_c::prepare().

void voxel_c::fillHoles ( char  type  ) 

fills in all empty voxels that are completely surrounded by non empty voxels,

References getIndex(), sx, sy, sz, unionFind(), validCoordinate(), voxels, and VX_FILLED.

voxel_type voxel_c::get ( unsigned int  p  )  const [inline]

Get voxel by index.

Sometimes the position of the voxel is not important but just the value and we need to be sure to traverse the whole space. Instead of using 3 nested loops for x, y and z we can go over the 1-dimensional array using a loop up to getXYZ() and this function for access

References bt_assert, space, and voxels.

voxel_type voxel_c::get ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

Get the value of the voxel at position $(x; y; z)$.

References getIndex(), and space.

Referenced by assembly_c::createSpace(), doConvert(), identicalInBB(), and print().

voxel_type voxel_c::get2 ( int  x,
int  y,
int  z 
) const [inline]

same as get but returns VX_EMPTY for each voxel outside the space

References getIndex(), space, sx, sy, sz, and VX_EMPTY.

Referenced by getColor2(), getState2(), voxel_4_c::scale(), and voxel_0_c::scaleDown().

unsigned int voxel_c::getBiggestDimension ( void   )  const [inline]

Returns the value of the biggest out of getX, getY or getZ.

References sx, sy, and sz.

bool voxel_c::getBoundingBox ( unsigned char  trans,
int *  x1,
int *  y1,
int *  z1,
int *  x2 = 0,
int *  y2 = 0,
int *  z2 = 0 
) const

get the bounding box of a rotated voxel space

If the return pointers are 0 the value is not returned

References BbHsCache, BBHSCACHE_NOT_DEF, BBHSCACHE_UNINIT, boundX1(), boundX2(), boundY1(), boundY2(), boundZ1(), boundZ2(), bt_assert, gridType_c::getVoxel(), gt, and transform().

Referenced by assembly_c::transform().

unsigned int voxel_c::getColor ( unsigned int  i  )  const [inline]

unsigned int voxel_c::getColor ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

unsigned int voxel_c::getColor2 ( int  x,
int  y,
int  z 
) const [inline]

References get2().

Referenced by assembly_c::smallerRotationExists().

virtual void voxel_c::getConnectionFace ( int  ,
int  ,
int  ,
int  ,
double  ,
double  ,
std::vector< float > &   
) const [inline, 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 in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

Referenced by getMeshInternal().

unsigned int voxel_c::getDiagonal ( void   )  const [inline]

Returns the squared diagonal of the space.

References sx, sy, and sz.

Polyhedron * voxel_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 in voxel_2_c.

References getMeshInternal().

const gridType_c* voxel_c::getGridType ( void   )  const [inline]

get the gridtype of this voxel space

References gt.

Referenced by puzzle_c::addShape(), voxelTable_c::addSpace(), voxelTable_c::getSpace(), and symmetries_0_c::symmetryKnown().

bool voxel_c::getHotspot ( unsigned char  trans,
int *  x,
int *  y,
int *  z 
) const

this function returns the hotspot of the rotated space.

References BbHsCache, BBHSCACHE_NOT_DEF, BBHSCACHE_UNINIT, bt_assert, getHx(), getHy(), getHz(), gridType_c::getVoxel(), gt, and transform().

Referenced by assembly_c::transform().

int voxel_c::getHx ( void   )  const [inline]

int voxel_c::getHy ( void   )  const [inline]

int voxel_c::getHz ( void   )  const [inline]

int voxel_c::getIndex ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

This function returns the index for a given triple of x, y and z.

References bt_assert, sx, sy, and sz.

Referenced by connected(), fillHoles(), get(), get2(), voxel_2_c::getMeshInternal(), getMeshInternal(), assembler_1_c::prepare(), assembler_0_c::prepare(), set(), and unionFind().

Polyhedron * voxel_c::getMesh ( double  bevel,
double  offset 
) const [virtual]

this function returns a polyhedron mesh of this shape.

The mesh is then further used for STL export and the displaying of this shape in the GUI The Polyhedron is allocated using new, so you have to delete it, when you no longer need it

References getMeshInternal().

Referenced by stlExporter_0_c::getMesh().

Polyhedron * voxel_c::getMeshInternal ( double  bevel,
double  offset,
bool  fast 
) const [private, virtual]

unsigned char voxel_c::getMirrorTransform ( const voxel_c op  )  const

this function returns the transformation, that transforms this voxel space into the as parameter given one

the returned transformation always contains a mirroring

if no transformation can be found, return 0

References symmetries_c::getNumTransformations(), symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gridType_c::getVoxel(), gt, identicalInBB(), and transform().

Referenced by assembler_1_c::prepare(), and assembler_0_c::prepare().

const std::string& voxel_c::getName ( void   )  const [inline]

function to get the name

References name.

Referenced by doConvert().

virtual bool voxel_c::getNeighbor ( unsigned int  idx,
unsigned int  typ,
int  x,
int  y,
int  z,
int *  xn,
int *  yn,
int *  zn 
) const [pure 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

Implemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

Referenced by actionOnSpace(), getMeshInternal(), and unionFind().

int voxel_c::getState ( unsigned int  i  )  const [inline]

int voxel_c::getState ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

int voxel_c::getState2 ( int  x,
int  y,
int  z 
) const [inline]

int voxel_c::getWeight ( void   )  const [inline]

get the weight of this space

References weight.

Referenced by movementAnalysator_c::movementAnalysator_c().

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

returns the drawing mesh for wrireframe mode.

Reimplemented in voxel_2_c.

References getMeshInternal().

unsigned int voxel_c::getX ( void   )  const [inline]

unsigned int voxel_c::getXYZ ( void   )  const [inline]

Get the number of voxels, which is getX()*getY()*getZ().

References voxels.

Referenced by BOOST_AUTO_TEST_CASE(), copy(), count(), countState(), minimizePiece(), assembler_1_c::prepare(), assembler_0_c::prepare(), save(), and voxel_c().

unsigned int voxel_c::getY ( void   )  const [inline]

unsigned int voxel_c::getZ ( void   )  const [inline]

bool voxel_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 in voxel_1_c, voxel_3_c, and voxel_4_c.

References bx1, bx2, by1, by2, bz1, bz2, get(), and getState().

Referenced by getMirrorTransform(), voxelTable_c::getSpace(), voxel_1_c::identicalInBB(), identicalWithRots(), symmetries_2_c::symmetryKnown(), symmetries_1_c::symmetryKnown(), and symmetries_0_c::symmetryKnown().

bool voxel_c::identicalWithRots ( const voxel_c op,
bool  includeMirror,
bool  includeColors 
) const

comparison of 2 voxel spaces.

2 spaces are identical, if one of the rotations is identical to the other voxel space you can specify, if you want to include the colours in the comparison, or just want to compare the shape naturally this function is relatively slow

if includeMirror is true, the function checks against all transformations including the mirrored shape, if it is false, mirrored transformations are excluded

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

References symmetries_c::getNumTransformations(), symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gridType_c::getVoxel(), gt, identicalInBB(), and transform().

Referenced by loadPuzzlerSolver3D().

bool voxel_c::indexToXYZ ( unsigned int  index,
unsigned int *  x,
unsigned int *  y,
unsigned int *  z 
) const

The inverse of getIndex.

For a given index the x, y and z coordinates inside this voxel space is returned

References sx, sy, and sz.

void voxel_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 in voxel_2_c.

References setHotspot().

Referenced by assembly_c::createSpace().

bool voxel_c::isEmpty ( unsigned int  i  )  const [inline]

References getState(), and VX_EMPTY.

bool voxel_c::isEmpty ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

bool voxel_c::isEmpty2 ( int  x,
int  y,
int  z 
) const [inline]

bool voxel_c::isFilled ( unsigned int  i  )  const [inline]

References getState(), and VX_FILLED.

bool voxel_c::isFilled ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

References getState(), and VX_FILLED.

Referenced by isNotchable().

bool voxel_c::isFilled2 ( int  x,
int  y,
int  z 
) const [inline]

bool voxel_c::isVariable ( unsigned int  i  )  const [inline]

References getState(), and VX_VARIABLE.

bool voxel_c::isVariable ( unsigned int  x,
unsigned int  y,
unsigned int  z 
) const [inline]

bool voxel_c::isVariable2 ( int  x,
int  y,
int  z 
) const [inline]

References getState2(), and VX_VARIABLE.

virtual bool voxel_c::meshParamsValid ( double  ,
double   
) const [inline, virtual]

Reimplemented in voxel_0_c, voxel_1_c, voxel_3_c, and voxel_4_c.

Referenced by stlExporter_0_c::getMesh().

void voxel_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 in voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

References getState(), getX(), getXYZ(), getY(), getZ(), resize(), translate(), and VX_EMPTY.

bool voxel_c::neighbour ( unsigned int  p,
voxel_type  val 
) const

returns true, if a neighbour of the given voxel has the given value

References bt_assert, space, sx, sy, and sz.

unsigned char voxel_c::normalizeTransformation ( unsigned char  trans  )  const [inline]

this function returns the smallest transformation number that results in an identical shape for this voxel space

References gridType_c::getSymmetries(), gt, symmetries_c::minimizeTransformation(), and selfSymmetries().

Referenced by assembly_c::transform().

virtual bool voxel_c::onGrid ( int  x,
int  y,
int  z 
) const [pure 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

Implemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

Referenced by assembler_1_c::canPlace(), assembler_0_c::canPlace(), and assembly_c::smallerRotationExists().

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

bool voxel_c::operator== ( const voxel_c op  )  const

Comparison of two voxel spaces.

two voxel spaces are equal if and only if: their sizes are the same and all their voxel values are identical

References space, sx, sy, sz, and voxels.

void voxel_c::recalcBoundingBox ( void   )  [protected]

updates the bounding box to fit the current shape inside the space.

This function does nothing, when doRecalc is false see skipRecalcBoundingBox. This is useful when a lot of operations are done on the space and only at the end the bounding box needs to be recalculated.

As a side effect the function sets all color values of empty voxels to 0.

When the space is empty the bounding box is set to all 0.

The bounding box and hotspot cache is cleared by this function

References BbHsCache, BBHSCACHE_UNINIT, bx1, bx2, by1, by2, bz1, bz2, doRecalc, symmetries_c::getNumTransformationsMirror(), gridType_c::getSymmetries(), gt, space, sx, sy, sz, and VX_EMPTY.

Referenced by resize(), voxel_4_c::scale(), voxel_3_c::scale(), voxel_1_c::scale(), voxel_0_c::scale(), voxel_0_c::scaleDown(), set(), setAll(), skipRecalcBoundingBox(), voxel_2_c::transform(), voxel_1_c::transform(), and translate().

virtual void voxel_c::recalcSpaceCoordinates ( float *  ,
float *  ,
float *   
) const [inline, virtual]

Reimplemented in voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

void voxel_c::resize ( unsigned int  nsx,
unsigned int  nsy,
unsigned int  nsz,
voxel_type  filler 
)

virtual void voxel_c::resizeInclude ( int &  px,
int &  py,
int &  pz 
) [pure 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

Implemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

void voxel_c::save ( xmlWriter_c xml  )  const

void voxel_c::scale ( unsigned int  amount,
bool  grid = false 
) [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 in voxel_0_c, voxel_1_c, voxel_3_c, and voxel_4_c.

bool voxel_c::scaleDown ( unsigned char  by,
bool  action 
) [virtual]

Scale down voxel space by a certain amount.

for the minimize scale function applied to all shapes we need to first check, if all shapes can be scaled down by a certain factor and then do it. If action is true, then the shape is really scaled, otherwise you only get the fact if it is scalable by the given amount

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)

Reimplemented in voxel_0_c, voxel_3_c, and voxel_4_c.

symmetries_t voxel_c::selfSymmetries ( void   )  const

This function returns the self symmetries of this voxel space.

Self symmetries are a list of transformations that transform the voxel space into an identical shape.

References symmetries_c::calculateSymmetry(), gridType_c::getSymmetries(), gt, isSymmetryInvalid, and symmetries.

Referenced by voxelTable_c::addSpace(), normalizeTransformation(), assembler_1_c::prepare(), assembler_0_c::prepare(), and assembly_c::smallerRotationExists().

void voxel_c::set ( unsigned int  p,
voxel_type  val 
) [inline]

The 1-dimensional variant of the set function.

References bt_assert, recalcBoundingBox(), space, symmetries, symmetryInvalid, and voxels.

void voxel_c::set ( unsigned int  x,
unsigned int  y,
unsigned int  z,
voxel_type  val 
) [inline]

the x, y, z variant of the set function.

References getIndex(), recalcBoundingBox(), space, symmetries, and symmetryInvalid.

Referenced by assembly_c::createSpace(), and doConvert().

void voxel_c::setAll ( voxel_type  val  )  [inline]

Set all the voxels to the given value.

References recalcBoundingBox(), space, symmetries, symmetryInvalid, and voxels.

void voxel_c::setColor ( unsigned int  i,
unsigned int  color 
) [inline]

References bt_assert.

void voxel_c::setColor ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  color 
) [inline]

References bt_assert.

Referenced by actionOnSpace(), and voxel_c().

void voxel_c::setHotspot ( int  x,
int  y,
int  z 
)

void voxel_c::setName ( const std::string &  n  )  [inline]

Set the name for this voxel space.

if you give 0 or an empty string the name will be removed

References name.

Referenced by doConvert(), and loadPuzzlerSolver3D().

void voxel_c::setState ( unsigned int  i,
int  state 
) [inline]

void voxel_c::setState ( unsigned int  x,
unsigned int  y,
unsigned int  z,
int  state 
) [inline]

Functions to set the state or color of a certain voxel.

The position is either given as a coordinate or as an index

Referenced by actionOnSpace(), loadPuzzlerSolver3D(), and voxel_c().

void voxel_c::setWeight ( int  w  )  [inline]

set the weight of this space

References weight.

void voxel_c::skipRecalcBoundingBox ( bool  skipit  )  [inline]

enable or diable the update of the bounding box after each operation.

Sometimes, when more complex operations are performed it is useful to not update the bounding box every time but rather finish all operations first and then update the box after all is finished. This can be done here call this function with skipit = true at the start of such a block of operations and at the end call it with skipit = false

References doRecalc, and recalcBoundingBox().

Referenced by assembly_c::createSpace(), doConvert(), and voxel_c().

virtual bool voxel_c::transform ( unsigned int  nr  )  [pure 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

Implemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

Referenced by voxelTable_c::addSpace(), assembly_c::createSpace(), getBoundingBox(), getHotspot(), getMirrorTransform(), voxelTable_c::getSpace(), movementCache_c::getTransformedShape(), identicalWithRots(), assembler_1_c::prepare(), assembler_0_c::prepare(), and symmetries_0_c::symmetryKnown().

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

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

Implemented in voxel_0_c, voxel_1_c, and voxel_2_c.

Referenced by assembly_c::transform().

void voxel_c::translate ( int  dx,
int  dy,
int  dz,
voxel_type  filler 
)

shift the space around.

Voxels that go over the edge get lost. The size is not changed the new empty space gets filled with the filler value

References hx, hy, hz, recalcBoundingBox(), space, sx, sy, and sz.

Referenced by voxel_4_c::minimizePiece(), voxel_3_c::minimizePiece(), voxel_2_c::minimizePiece(), voxel_1_c::minimizePiece(), minimizePiece(), voxel_4_c::resizeInclude(), voxel_3_c::resizeInclude(), voxel_2_c::resizeInclude(), voxel_1_c::resizeInclude(), and voxel_0_c::resizeInclude().

void voxel_c::unionFind ( int *  tree,
char  type,
bool  inverse,
voxel_type  value,
bool  outsideZ 
) const [private]

This function is used by conneced and fill holes.

Union Find Details

It finds out what groups of voxel spaces touch one another Type: defines in which way the voxels touch (faces, edges, corners) Inverse: defines whether to work on the voxlels defines by value or the other voxels value: which voxels to work on outsiudeZ: how to tread the Z direction outside: as empty for 3D pieces or as non existent for 2D pieces

References getIndex(), getNeighbor(), sx, sy, sz, validCoordinate(), and voxels.

Referenced by connected(), and fillHoles().

bool voxel_c::unionintersect ( const voxel_c va,
int  xa,
int  ya,
int  za,
const voxel_c vb,
int  xb,
int  yb,
int  zb 
)

References bx1, bx2, by1, by2, bz1, bz2, getState2(), resize(), sx, sy, sz, VX_EMPTY, and VX_FILLED.

virtual bool voxel_c::validCoordinate ( int  x,
int  y,
int  z 
) const [pure 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

Implemented in voxel_0_c, voxel_1_c, voxel_2_c, voxel_3_c, and voxel_4_c.

Referenced by connected(), doConvert(), fillHoles(), and unionFind().


Member Data Documentation

int* voxel_c::BbHsCache [protected]

A cache for hotspot and bounding box coordinates of the rotated voxel.

calculating the hotspot and bounding box can be expensive and as this information is required extremely often for the assembly transformation we will cache this information

the cache is simple, for each transformation it contains 3+6=9 values if the first value is BBHSCACHE_UNINIT then the information for that transformation is not yet available and needs to be calculated the first 3 values are the hot spot position and the following 6 the bounding box for the given transformation

Referenced by getBoundingBox(), getHotspot(), recalcBoundingBox(), setHotspot(), voxel_c(), and ~voxel_c().

unsigned int voxel_c::bx1 [protected]

unsigned int voxel_c::bx2 [protected]

unsigned int voxel_c::by1 [protected]

unsigned int voxel_c::by2 [protected]

unsigned int voxel_c::bz1 [protected]

unsigned int voxel_c::bz2 [protected]

bool voxel_c::doRecalc [protected]

bounding box recalculation is only done when this is true

Referenced by recalcBoundingBox(), skipRecalcBoundingBox(), and voxel_c().

const gridType_c* voxel_c::gt [protected]

int voxel_c::hx [protected]

int voxel_c::hy [protected]

int voxel_c::hz [protected]

std::string voxel_c::name [protected]

The name of the shape.

Referenced by copy(), getName(), save(), setName(), and voxel_c().

voxel_type* voxel_c::space [protected]

The space.

It's dynamically allocated on construction and deleted on destruction. The position of a voxel inside this 1-dimensional structure is $ x + sx*(y + sy*z) $

Referenced by copy(), get(), get2(), neighbour(), operator==(), recalcBoundingBox(), resize(), voxel_4_c::scale(), voxel_3_c::scale(), voxel_1_c::scale(), voxel_0_c::scale(), voxel_0_c::scaleDown(), set(), setAll(), voxel_2_c::transform(), voxel_1_c::transform(), voxel_0_c::transform(), translate(), voxel_c(), and ~voxel_c().

unsigned int voxel_c::sx [protected]

unsigned int voxel_c::sy [protected]

symmetries_t voxel_c::symmetries [mutable, protected]

the self symmetries of this voxel space.

The value may be invalid, meaning that the self symmetries of the space are unknown and need to be calculated

Referenced by copy(), selfSymmetries(), set(), setAll(), voxel_2_c::transform(), voxel_1_c::transform(), voxel_0_c::transform(), and voxel_c().

unsigned int voxel_c::sz [protected]

unsigned int voxel_c::voxels [protected]

int voxel_c::weight [protected]

Weight of the shape.

This weight is used by the disassembler to decide which piece of groups to move and which to keep still

Referenced by copy(), getWeight(), save(), setWeight(), and voxel_c().


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

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