Public Types |
enum | stateInfoType {
DISPLACEMENT,
VELOCITY,
KINETIC_ENERGY,
ANGULAR_DISPLACEMENT,
ANGULAR_VELOCITY,
ENG_STRESS,
ENG_STRAIN,
STRAIN_ENERGY,
PRESSURE,
MASS
} |
| Defines various types of information to query about the state of a voxelyze object. More...
|
enum | valueType { MIN,
MAX,
TOTAL,
AVERAGE
} |
| The type if value desired for a given stateInfoType. Considers all voxels or all links (depending on stateInfoType). More...
|
Public Member Functions |
| CVoxelyze (double voxelSize=DEFAULT_VOXEL_SIZE) |
| Constructs an empty voxelyze object.
|
| CVoxelyze (const char *jsonFilePath) |
| Constructs a voxelyze object from a *.vxl.json file. The details of this file format are available in the Voxelyze user guide.
|
| CVoxelyze (rapidjson::Value *pV) |
| Constructs a voxelyze object from a rapidjson parser node that contains valid voxelyze sub-nodes.
|
| ~CVoxelyze (void) |
| Destructor.
|
| CVoxelyze (CVoxelyze &VIn) |
| Copy constructor.
|
CVoxelyze & | operator= (CVoxelyze &VIn) |
| Equals operator.
|
void | clear () |
| Erases all voxels and materials and restores the voxelyze object to its default (empty) state.
|
bool | loadJSON (const char *jsonFilePath) |
| Clears this voxelyze instance and loads fresh from a *.vxl.json file. The details of this file format are available in the Voxelyze user guide.
|
bool | saveJSON (const char *jsonFilePath) |
| Saves this voxelyze instance to a json file. All voxels are saved at their default locations - the state is not captured. It is recommended to specify the standard *.vxl.json file suffix.
|
bool | doLinearSolve () |
| Linearizes the voxelyze object and does a one-time linear solution to set the position and orientation of all voxels. The current state of the voxel object will be discarded. Currently only the pardiso solver is supported. To make use of this feature voxelyze must be built with PARDISO_5 defined in the preprocessor. A valid pardiso 5 license file and library file (i.e libpardiso500-WIN-X86-64.dll for windows) should be obtained from www.pardiso-project.org and placed in the directory your executable will be run from.
|
bool | doTimeStep (float dt=-1.0f) |
| Executes a single timestep on this voxelyze object and updates all state information (voxel positions and orientations) accordingly. In most situations this function will be called repeatedly until the desired result is obtained.
|
float | recommendedTimeStep () const |
| Returns an estimate of the largest stable time step based on the current state of the simulation. If poisson's ratios are all zero and material properties do not otherwise change this can be called once and the same timestep value used for all subsequent doTimeStep() calls. Otherwise the timestep should be recalculated whenever the simulation has changed.
|
void | resetTime () |
| Resets all voxels to their initial state and zeroes the elapsed time counter. Call this to "start over" without changing any of the voxels.
|
CVX_Material * | addMaterial (float youngsModulus=1e6f, float density=1e3f) |
| Adds a material to this voxelyze object with the minimum necessary information for dynamic simulation (stiffness, density). Returns a pointer to the newly created material that can be used to further specify properties using CVX_Material public memer functions. See CVX_Material documentation. This function does not create any voxels, but a returned CVX_material pointer is a necessary parameter for the setVoxel() function that does add voxels.
|
CVX_Material * | addMaterial (rapidjson::Value &mat) |
| Adds a material to this voxelyze object from a rapidjson parser node that contains valid CVX_Material sub-nodes.
|
CVX_Material * | addMaterial (const CVX_Material &mat) |
| Adds a material to this voxelyse object and copies all material properties from the specified CVX_Material.
|
bool | removeMaterial (CVX_Material *toRemove) |
| Removes the specified material from the voxelyze object and deletes all voxels currently using it.
|
bool | replaceMaterial (CVX_Material *replaceMe, CVX_Material *replaceWith) |
| Replaces all voxels of one material with another material.
|
int | materialCount () |
| Returns the number of materials currently in this voxelyze object.
|
CVX_Material * | material (int materialIndex) |
| Returns a pointer to a material that has been added to this voxelyze object. CVX_Material public member functions can be safely called on this pointer to modify the material. A given index may or may not always return the same material - Use material pointers to keep permanent handles to specific materials. This function is primarily used while iterating through all materials in conjuntion with materialCount().
|
CVX_Voxel * | setVoxel (CVX_Material *material, int xIndex, int yIndex, int zIndex) |
| Adds a voxel made of material at the specified index. If a voxel already exists here it is replaced. The returned pointer can be safely modified by calling any CVX_Voxel public member function on it.
|
CVX_Voxel * | voxel (int xIndex, int yIndex, int zIndex) const |
| Returns a pointer to the voxel at this location if one exists, or null otherwise. The returned pointer can be safely modified by calling any CVX_Voxel public member function on it.
|
int | voxelCount () const |
| Returns the number of voxels currently in this voxelyze object.
|
CVX_Voxel * | voxel (int voxelIndex) const |
| Returns a pointer to a voxel that has been added to this voxelyze object. CVX_Voxel public member functions can be safely called on this pointer to query or modify the voxel. A given index may or may not always return the same voxel - Use voxel pointers to keep permanent handles to specific voxels. This function is primarily used while iterating through all voxels in conjuntion with voxelCount().
|
const std::vector< CVX_Voxel * > * | voxelList () const |
| Returns a pointer to the internal list of voxels in this voxelyze object. In some situations where all voxels must be iterated over quickly there may be performance gains from iterating directly on the underlying std::vector container accessed with this function.
|
int | indexMinX () const |
| The minimum X index of any voxel in this voxelyze object. Use to determine limits.
|
int | indexMaxX () const |
| The minimum Y index of any voxel in this voxelyze object. Use to determine limits.
|
int | indexMinY () const |
| The minimum Z index of any voxel in this voxelyze object. Use to determine limits.
|
int | indexMaxY () const |
| The maximum X index of any voxel in this voxelyze object. Use to determine limits.
|
int | indexMinZ () const |
| The maximum Y index of any voxel in this voxelyze object. Use to determine limits.
|
int | indexMaxZ () const |
| The maximum Z index of any voxel in this voxelyze object. Use to determine limits.
|
CVX_Link * | link (int xIndex, int yIndex, int zIndex, CVX_Voxel::linkDirection direction) const |
| Returns a pointer to the link at this voxel location in the direction indicated if one exists, or null otherwise. The returned pointer can be safely modified by calling any CVX_Link public member function on it.
|
int | linkCount () const |
| Returns the number of links currently in this voxelyze object.
|
CVX_Link * | link (int linkIndex) |
| Returns a pointer to a link that is a part of this voxelyze object. CVX_Link public member functions can be safely called on this pointer to query the link. A given index may or may not always return the same link - Use link pointers to keep permanent handles to specific voxels. This function is primarily used while iterating through all links in conjuntion with linkCount().
|
const std::vector< CVX_Link * > * | linkList () const |
| Returns a pointer to the internal list of links in this voxelyze object. In some situations where all links must be iterated over quickly there may be performance gains from iterating directly on the underlying std::vector container accessed with this function.
|
const std::vector
< CVX_Collision * > * | collisionList () const |
| Returns a pointer to the internal list of collisions in this voxelyze object. See CVX_Collision documentation for more information on collision objects.
|
void | setVoxelSize (double voxelSize) |
| Sets the base voxel size for the entire voxelyze object.
|
double | voxelSize () const |
| Returns the base voxel size in meters.
|
void | setAmbientTemperature (float relativeTemperature, bool allVoxels=false) |
| Sets the relative ambient temperature of the environment. A relative temperature of zero indicates that materials will experience zero thermal expansion.
|
float | ambientTemperature (void) const |
| Returns the current relative ambient temperature.
|
void | setGravity (float g=1.0f) |
| Sets the gravitational acceleration to apply to all voxels. Gravity acts in the -Z direction. Set to 0 to disable.
|
float | gravity (void) const |
| Returns the current gravitational acceleration in g's. 1 g = -9.80665 m/s^2.
|
void | enableFloor (bool enabled=true) |
| Enables or disables a floor that resists voxel penetration at z=0.
|
bool | isFloorEnabled (void) const |
| Returns a boolean value indication if the floor is enabled or not.
|
void | enableCollisions (bool enabled=true) |
| Enables or disables a collision watcher that results in voxels resisting penetration with one another. This may slow down the simulation significantly.
|
bool | isCollisionsEnabled (void) const |
| Returns a boolean value indication if the collision watcher is enabled or not.
|
float | stateInfo (stateInfoType info, valueType type) |
| Returns a specific piece of information about the current state of the simulation. This method is not gaurenteed threadafe.
|
Defines and simulates a configuration of voxels.
The primary user-accesible concepts of Voxelyze are materials, voxels, and links.
Materials represent an abstract material with physical properties and must be added via one of the addMaterial() functions before any voxels may be added. Materials hold no state - they are essentially just a container for a set of material properties.
Voxels are added using setVoxel() and use a previously added material. Voxels always begin as cubes on a regular lattice - therefore only x, y, and z indices are need to fully specify where to add a voxel. A voxel object may have an "external" influence (such as being fixed to ground in one or more degrees of freedom, or an external force applied) which is accessed through its external() member function. A voxel also contains state information such as its current position and velocity.
Links are never added directly. Instead whenenver a voxel is added a link is automatically created to any adjacent voxels. Links hold all the structural information of the simulated Euler-Bernoulli beam connecting two adjacent voxels. In the case of two voxels with dissimilar materials, the link object automatically calculates the appropriate composite material properties. Links hold state information such as stress, strain, and strain energy.
The pointers returned for materials, voxels, and links are valid for the entire lifetime of that particular material, voxel, or link. It is also possible to iterate over all materials, voxels, or links using, for example, materialCount() and material().
Once the desired voxels are set up, the simulation is run by simply calling doTimeStep() repeatedly until the desired result is acheived. Because Voxelyze utilizes numerical integration, too large of a timestep will cause divergent instability. This depends on many things, most notably the stiffness and density of voxels in use. Heavy, stiff voxels will be stable for larger timesteps. Calling doTimeStep() without an argument will use a good estimation of the larger stable timestep duration. This timestep is used synchronously for all voxels, so the entire simulation will run at the slowest timestep (as determined usually by the stiffest/lightest material in use).