#include <voxel.h>


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
| 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. | |
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_c * | getGridType (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 . | |
| 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) |
| 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. | |
| 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_c * | gt |
| 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_type * | space |
| 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. | |
| void | operator= (const voxel_c &) |
| enum voxel_c::VoxelState |
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
| enum voxel_c::VoxelAction |
| 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.
| voxel_c::voxel_c | ( | xmlParser_c & | pars, | |
| const gridType_c * | gt | |||
| ) |
Load a voxel space from xml node.
| voxel_c::voxel_c | ( | const voxel_c & | orig | ) |
Copy constructor using reference.
Transformation allows to have a rotated version of this voxel space
| voxel_c::voxel_c | ( | const voxel_c * | orig | ) |
Copy constructor using pointer.
Transformation allows to have a rotated version of this voxel space
| voxel_c::~voxel_c | ( | ) | [virtual] |
Destructor.
Free the space
| 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
| 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
| 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
| unsigned int voxel_c::getX | ( | void | ) | const [inline] |
Return x-size of the voxel space.
| unsigned int voxel_c::getY | ( | void | ) | const [inline] |
Return y-size of the voxel space.
| unsigned int voxel_c::getZ | ( | void | ) | const [inline] |
Return z-size of the voxel space.
| const gridType_c* voxel_c::getGridType | ( | void | ) | const [inline] |
get the gridtype of this voxel space
| unsigned int voxel_c::getDiagonal | ( | void | ) | const [inline] |
Returns the squared diagonal of the space.
| unsigned int voxel_c::getBiggestDimension | ( | void | ) | const [inline] |
Returns the value of the biggest out of getX, getY or getZ.
| unsigned int voxel_c::getXYZ | ( | void | ) | const [inline] |
Get the number of voxels, which is getX()*getY()*getZ().
| 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.
| 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
| voxel_type voxel_c::get | ( | unsigned int | x, | |
| unsigned int | y, | |||
| unsigned int | z | |||
| ) | const [inline] |
Get the value of the voxel at position
.
| 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
| 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
| bool voxel_c::neighbour | ( | unsigned int | p, | |
| voxel_type | val | |||
| ) | const |
returns true, if a neighbour of the given voxel has the given value
| 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.
| 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.
| void voxel_c::set | ( | unsigned int | p, | |
| voxel_type | val | |||
| ) | [inline] |
The 1-dimensional variant of the set function.
| void voxel_c::setAll | ( | voxel_type | val | ) | [inline] |
Set all the voxels to the given value.
| unsigned int voxel_c::count | ( | voxel_type | val | ) | const |
counts the number of voxels that have the given value
| virtual void voxel_c::transformPoint | ( | int * | x, | |
| int * | y, | |||
| int * | z, | |||
| unsigned int | trans | |||
| ) | const [pure virtual] |
| 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
| 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.
| unsigned int voxel_c::boundX1 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| unsigned int voxel_c::boundX2 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| unsigned int voxel_c::boundY1 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| unsigned int voxel_c::boundY2 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| unsigned int voxel_c::boundZ1 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| unsigned int voxel_c::boundZ2 | ( | void | ) | const [inline] |
Get the coordinate of the Bounding Box.
| 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
| 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
| 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
| 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
| 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
| void voxel_c::resize | ( | unsigned int | nsx, | |
| unsigned int | nsy, | |||
| unsigned int | nsz, | |||
| voxel_type | filler | |||
| ) |
resizes the voxelspace.
preserving the lower part of the data, when the new one is smaller and adding new voxels at the upper end, if the new space is bigger
| 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::scale | ( | unsigned int | amount | ) | [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)
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)
| 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.
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
| 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
| void voxel_c::fillHoles | ( | char | type | ) |
fills in all empty voxels that are completely surrounded by non empty voxels,
| 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.
| 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.
| 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
| int voxel_c::getState | ( | unsigned int | x, | |
| unsigned int | y, | |||
| unsigned int | z | |||
| ) | const [inline] |
Functions to get the voxel state or color of a single voxel.
| int voxel_c::getState2 | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) | const [inline] |
| int voxel_c::getState | ( | 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] |
| unsigned int voxel_c::getColor | ( | unsigned int | i | ) | const [inline] |
| bool voxel_c::isEmpty | ( | unsigned int | x, | |
| unsigned int | y, | |||
| unsigned int | z | |||
| ) | const [inline] |
Functions to ask, if a voxel has a certain state.
| bool voxel_c::isEmpty2 | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) | const [inline] |
| bool voxel_c::isEmpty | ( | unsigned int | i | ) | const [inline] |
| bool voxel_c::isFilled | ( | unsigned int | x, | |
| unsigned int | y, | |||
| unsigned int | z | |||
| ) | const [inline] |
| bool voxel_c::isFilled2 | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) | const [inline] |
| bool voxel_c::isFilled | ( | unsigned int | i | ) | const [inline] |
| 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] |
| bool voxel_c::isVariable | ( | unsigned int | i | ) | const [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
| void voxel_c::setColor | ( | unsigned int | x, | |
| unsigned int | y, | |||
| unsigned int | z, | |||
| unsigned int | color | |||
| ) | [inline] |
| void voxel_c::setState | ( | unsigned int | i, | |
| int | state | |||
| ) | [inline] |
| void voxel_c::setColor | ( | unsigned int | i, | |
| unsigned int | color | |||
| ) | [inline] |
| 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
| 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
| void voxel_c::save | ( | xmlWriter_c & | xml | ) | const |
used to save to XML
| int voxel_c::getHx | ( | void | ) | const [inline] |
Get the hotspot.
| int voxel_c::getHy | ( | void | ) | const [inline] |
Get the hotspot.
| int voxel_c::getHz | ( | void | ) | const [inline] |
Get the hotspot.
| void voxel_c::setHotspot | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) |
Set the hotspot.
| 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.
| bool voxel_c::getHotspot | ( | unsigned char | trans, | |
| int * | x, | |||
| int * | y, | |||
| int * | z | |||
| ) | const |
this function returns the hotspot of the rotated space.
| const std::string& voxel_c::getName | ( | void | ) | const [inline] |
function to get the name
| 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
| int voxel_c::getWeight | ( | void | ) | const [inline] |
get the weight of this space
| void voxel_c::setWeight | ( | int | w | ) | [inline] |
set the weight of this space
| 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.
| bool voxel_c::unionintersect | ( | const voxel_c * | va, | |
| int | xa, | |||
| int | ya, | |||
| int | za, | |||
| const voxel_c * | vb, | |||
| int | xb, | |||
| int | yb, | |||
| int | zb | |||
| ) |
| virtual bool voxel_c::onGrid | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) | const [pure virtual] |
| void voxel_c::operator= | ( | const voxel_c & | ) | [private] |
const gridType_c* voxel_c::gt [protected] |
each voxel needs to know the parameters for its space grid
unsigned int voxel_c::sx [protected] |
The x size of the space.
unsigned int voxel_c::sy [protected] |
The y size of the space.
unsigned int voxel_c::sz [protected] |
The z size of the space.
unsigned int voxel_c::voxels [protected] |
The number of voxel inside the space.
voxels is always equal to
it's just here to ease things a bit
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
unsigned int voxel_c::bx1 [protected] |
lower x-coordinate of the Bounding Box
unsigned int voxel_c::bx2 [protected] |
upper x-coordinate of the Bounding Box
unsigned int voxel_c::by1 [protected] |
lower y-coordinate of the Bounding Box
unsigned int voxel_c::by2 [protected] |
upper y-coordinate of the Bounding Box
unsigned int voxel_c::bz1 [protected] |
lower z-coordinate of the Bounding Box
unsigned int voxel_c::bz2 [protected] |
upper z-coordinate of the Bounding Box
bool voxel_c::doRecalc [protected] |
bounding box recalculation is only done when this is true
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
int voxel_c::hx [protected] |
x-coordinate of The Hot Spot
int voxel_c::hy [protected] |
y-coordinate of The Hot Spot
int voxel_c::hz [protected] |
z-coordinate of The Hot Spot
std::string voxel_c::name [protected] |
The name of the shape.
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
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
1.5.4