#include <vclip.h>
Voronoi Clip Algorithm. One have to setup a vclip mesh in order to use this collision algorithm. An vclip mesh is a polygon mesh annotated with voronoi planes of the external voronoi regions of each mesh feature.
An utility tool have been created for setting up a vclip mesh. An example:
polymesh::PolyMesh<....> my_usual_mesh; mesh::obj_read(my_favorite_polymesh_file,my_usual_mesh); vclip_mesh_type my_vclip_mesh; convert(my_usual_mesh,my_vclip_mesh);
Now you can simply invoke the run method on this class to do a collision test between two vclip meshes.
Here is a little longer example. First at startup one initializes the geometries
OpenTissue::vclip::vclip_mesh_type A; OpenTissue::vclip::vclip_mesh_type B;
polymesh::PolyMesh<> tmp; mesh::make_box(1.0,1.0,1.0, tmp); mesh::make_box(1.0,1.0,1.0, tmp);
OpenTissue::vclip::convert(tmp,A); OpenTissue::vclip::convert(tmp,B);
Then during runtime, one determines where the geometries are places in the world
coordsys_type Awcs = coordsys_type( vector3_type(-1.0,0.0,0.0), quaternion_type()); coordsys_type Bwcs = coordsys_type( vector3_type( 1.0,0.0,0.0), quaternion_type()); coordsys_type AtoB = model_update(Awcs,Bwcs); coordsys_type BtoA = inverse(AtoB);
Finally one can query the vclip algorithm about cloest features and separation distance.
OpenTissue::vclip::Feature * seed_a = &( * ea ); OpenTissue::vclip::Feature * seed_b = &( * fb ); real_type distance = vclip.run(A,B,AtoB,BtoA,&seed_a,&seed_b,p_a,p_b,max_iterations);
typedef vclip_mesh_type::face_halfedge_circulator OpenTissue::vclip::VClip::face_halfedge_circulator |
typedef halfedge_type::plane_type OpenTissue::vclip::VClip::plane_type |
typedef unsigned char OpenTissue::vclip::VClip::state_type |
typedef vclip_mesh_type::vertex_halfedge_circulator OpenTissue::vclip::VClip::vertex_halfedge_circulator |
real_type OpenTissue::vclip::VClip::run | ( | vclip_mesh_type const & | meshA, | |
vclip_mesh_type const & | meshB, | |||
coordsys_type const & | AtoB, | |||
coordsys_type const & | BtoA, | |||
feature_pointer * | seedA, | |||
feature_pointer * | seedB, | |||
vector3_type & | cpA, | |||
vector3_type & | cpB, | |||
unsigned int const | max_iterations = 500 | |||
) | [inline] |
Run V-Clip algorithm. When this method is invoked the v-clip algorithm is run on the two specified polyhedra.
meshA | The mesh of object A (in model frame). | |
meshB | The mesh of object B (in model frame). | |
AtoB | A coordinate transform from model frame of object A to the model frame of object B. | |
BtoA | The inverse coordinate transform of AtoB. | |
seedA | A feature from the mesh of object A. This is used to seed the algorithm. | |
seedB | A feature from the mesh of object B. This is used to seed the algorithm. | |
cpA | Upon return this argument holds the closest point on A. | |
cpB | Upon return this argument holds the closest point on B. | |
max_iterations | This is an iterative algorithm, one can use this argument to either do single steps (usefull for visualizing the internal feature tracking) or simply guard against infinite loops. |
const state_type OpenTissue::vclip::VClip::edge_edge_state = 5 [static] |
const state_type OpenTissue::vclip::VClip::edge_face_state = 6 [static] |
const state_type OpenTissue::vclip::VClip::edge_vertex_state = 4 [static] |
const state_type OpenTissue::vclip::VClip::face_edge_state = 9 [static] |
const state_type OpenTissue::vclip::VClip::face_vertex_state = 8 [static] |
const int OpenTissue::vclip::VClip::INSIDE = 0x000 [static] |
Constants used to describe an edges relative position to a edge-face voronoi plane.
std::vector<int> OpenTissue::vclip::VClip::m_code |
Edge Clip Code. When an edge is clipped against the edge-face voronoi planes along the boundary of a face then this data structure is used to keep track of the edges position relatively to each voronoi plane.
That is an edge can be either inside, outside, minimum-cross or maximum-cross of a voronoi plane.
The Separation Distance.
std::vector<real_type> OpenTissue::vclip::VClip::m_parameter |
Edge Clipping Parameter Storage. This array is used in a similar way to the code-array except this time we store the actual value of the clipping parameter.
Temporary Storage. All these are used to pass along information about the two current withness features to each state handler.
const int OpenTissue::vclip::VClip::MAX = 0x004 [static] |
const int OpenTissue::vclip::VClip::MIN = 0x002 [static] |
const int OpenTissue::vclip::VClip::OUTSIDE = 0x001 [static] |
const state_type OpenTissue::vclip::VClip::vertex_edge_state = 1 [static] |
const state_type OpenTissue::vclip::VClip::vertex_face_state = 2 [static] |
const state_type OpenTissue::vclip::VClip::vertex_vertex_state = 0 [static] |
State type constants.