SourceForge.net Logo

camvox::VoxTree Class Reference

#include <VoxTree.h>

List of all members.


Detailed Description

An VoxTree instance holds a complete oct-tree of voxels.

The VoxTree includes the memory menagement of all of the nodes in the octtree.


Public Member Functions

 VoxTree (double _size)
 Construct a voxel space.
 ~VoxTree (void)
void generatePOVCode (void)
 Generate POV-RAY code.
void addCSGObject (const CSGObject *obj, VoxOperation &csg_op)
 Render a CSG object into voxel space.
void prune (void)
 Reduce the memory footprint of the voxel space.

Public Attributes

uint64_t nr_nodes_created
 A counter showing the number of nodes created.
uint64_t nr_nodes_destroyed
 A counter showing the number of nodes removed.

Private Member Functions

uint32_t alloc (void)
 Alocate a new oct-tree node.
void free (uint32_t node_nr)
 Frees an oct-tree node.
void checkSize (void)
 Checks and resizes the available memory for holding the nodes.
Voxel pruneVoxel (uint32_t node_nr, const VoxCoord &coord, int voxel_index)
 Optimizes the voxel tree.
Voxel pruneNode (uint32_t node_nr, const VoxCoord &coord)
 Optimizes the voxel tree.
Voxel addCSGObjectToVoxel (uint32_t node_nr, const VoxCoord &coord, int voxel_index, const CSGObject *obj, VoxOperation &csg_op)
 Adds an CSG object to a voxel.
Voxel addCSGObjectToNode (uint32_t node_nr, const VoxCoord &coord, const CSGObject *obj, VoxOperation &csg_op)
 Adds an CSG object to a voxel.
void generatePOVCodeForVoxel (uint32_t node_nr, const VoxCoord &coord, int voxel_index)
 Generate POVRAY code.
void generatePOVCodeForNode (uint32_t node_nr, const VoxCoord &coord)
 Generate POVRAY code.

Private Attributes

FreeList free_list
uint32_t nodes_size
vox_node_tnodes
uint32_t root
double size
 The length of each axis of voxel space.
double scale
 The size of the smallest possible voxel.

Constructor & Destructor Documentation

camvox::VoxTree::VoxTree ( double  _size  ) 

Construct a voxel space.

Parameters:
_size size of each axis of the voxel space in mm, inches or anything else. but make sure that you keep units consistant troughout.

camvox::VoxTree::~VoxTree ( void   ) 


Member Function Documentation

uint32_t camvox::VoxTree::alloc ( void   )  [inline, private]

Alocate a new oct-tree node.

This takes a node from the free list, this is garanteed to be the lowest value available.

Returns:
node_nr

void camvox::VoxTree::free ( uint32_t  node_nr  )  [inline, private]

Frees an oct-tree node.

This returns the node back to the free list.

Parameters:
node_nr The node_nr of the node to be freed.

void camvox::VoxTree::checkSize ( void   )  [private]

Checks and resizes the available memory for holding the nodes.

This should be run everytime a new node gets allocated. It increases the size of the buffer by 50%. Because the nodes may be moved in memory after this call, one should always use node_nrs when accesing nodes.

Voxel camvox::VoxTree::pruneVoxel ( uint32_t  node_nr,
const VoxCoord coord,
int  voxel_index 
) [private]

Optimizes the voxel tree.

See also:
void pruneVoxel(void)

Voxel camvox::VoxTree::pruneNode ( uint32_t  node_nr,
const VoxCoord coord 
) [private]

Optimizes the voxel tree.

See also:
void pruneVoxel(void)

Voxel camvox::VoxTree::addCSGObjectToVoxel ( uint32_t  node_nr,
const VoxCoord coord,
int  voxel_index,
const CSGObject obj,
VoxOperation csg_op 
) [private]

Adds an CSG object to a voxel.

See also:
void addCSGObject(CSGObject *obj, VoxOperation *new_data)

Voxel camvox::VoxTree::addCSGObjectToNode ( uint32_t  node_nr,
const VoxCoord coord,
const CSGObject obj,
VoxOperation csg_op 
) [private]

Adds an CSG object to a voxel.

See also:
void addCSGObject(CSGObject *obj, VoxOperation *new_data)

void camvox::VoxTree::generatePOVCodeForVoxel ( uint32_t  node_nr,
const VoxCoord coord,
int  voxel_index 
) [private]

Generate POVRAY code.

See also:
void generatePOVCode(void)

void camvox::VoxTree::generatePOVCodeForNode ( uint32_t  node_nr,
const VoxCoord coord 
) [private]

Generate POVRAY code.

See also:
void generatePOVCode(void)

void camvox::VoxTree::generatePOVCode ( void   ) 

Generate POV-RAY code.

This method outputs a POV-RAY file representing the oct-tree. It writes out a set of boxes in different colors, each one node of the oct-tree.

void camvox::VoxTree::addCSGObject ( const CSGObject obj,
VoxOperation csg_op 
)

Render a CSG object into voxel space.

Parameters:
obj An CSGObject, either a primative or a compound object.
new_data The new data and the command to be executed when a voxel is inside the CSG Object.

void camvox::VoxTree::prune ( void   ) 

Reduce the memory footprint of the voxel space.

addCSGObject* alreay automatically prune, so this function rarelly needs to be called.


Member Data Documentation

uint32_t camvox::VoxTree::nodes_size [private]

uint32_t camvox::VoxTree::root [private]

double camvox::VoxTree::size [private]

The length of each axis of voxel space.

double camvox::VoxTree::scale [private]

The size of the smallest possible voxel.

A counter showing the number of nodes created.

A counter showing the number of nodes removed.


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