An articulated tree with rendring function for openGL display. More...
#include <EmbodiedArticulatedTree.h>
Public Member Functions | |
| EmbodiedArticulatedTree (const pTree tree) | |
| void | SetShape (Shape *sol) |
| void | UpdateShape () |
| Shape * | GetShape () |
| int | SetAllShapes (pTree shape_tree) |
| void | Render () |
| void | Highlight () |
| virtual void | StreamTree (ostream &out) const |
| void | CopyTree (pArticulatedTree_t tree) |
| copies the values from another tree with the same structure. | |
| void | AddTree (pArticulatedTree_t ptree) |
| int | GetSize () const |
| pArticulatedTree_t | FindJoint (string &name) |
| pArticulatedTree_t | FindSubTree (pArticulatedTree_t t, pArticulatedTree_t exclude=NULL) |
| tells whether the tree contains a given subtree. | |
| pArticulatedTree_t | GetParent () |
| ArticulatedTreeList_t * | GetChildren () |
| RigidTransfo * | GetJoint () |
| void | RandomAxis () |
| void | NoTranslation () |
| void | RandomAngle () |
| void | ZeroPosition () |
| void | Reshape (CVector3_t offset=NULL) |
| void | Reshape2 (CVector3_t offset=NULL) |
| void | GetAxis (CVector3_t axis) |
| int | CheckPairsOfNodes (int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg) |
| goes through all pairs of nodes in the tree and performed a given function | |
| int | CheckTreeNode1 (pArticulatedTree_t tree, int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg) |
| int | CheckTreeNode2 (pArticulatedTree_t tree, int(*f)(pArticulatedTree_t, pArticulatedTree_t, void *), void *arg) |
| int | GetAngleList (float *list) |
| @ brief puts all the joint angles into a list @ param list the array of angles. | |
| int | SetAngleList (float *list) |
| int | GetAngleRangeList (float *list_min, float *list_max) |
| float | GetLowerRange () |
| float | GetUpperRange () |
| int | FindAngleRanges (float *lower_range, float *upper_range, KinematicChain *chain) |
| recursively looks in the tree for the ranges corresponding to the joints in a KinematicChain | |
| int | Serialize (float *data, int data_size) const |
| Serializes the translation vectors and rotation axes. | |
| int | Deserialize (const float *data, int data_size) |
| Deserializes the translation vectors and rotation axes. | |
| void | PrintList () |
| void | PrintAngles () |
Data Fields | |
| string | name |
Protected Member Functions | |
| void | RenderBegin () |
| void | RenderEnd () |
Protected Attributes | |
| Shape * | solid |
| RigidTransfo | joint |
| ArticulatedTree * | parent |
| ArticulatedTreeList_t | children |
| float | range [2] |
An articulated tree with rendring function for openGL display.
Definition at line 30 of file EmbodiedArticulatedTree.h.
| int ArticulatedTree::CheckPairsOfNodes | ( | int(*)(pArticulatedTree_t, pArticulatedTree_t, void *) | f, | |
| void * | arg | |||
| ) | [inherited] |
goes through all pairs of nodes in the tree and performed a given function
goes through all unordered pairs of nodes in the tree and performs a given function.
| f | the function performed with all pairs of nodes | |
| arg | a pointer to an addition argument that is passed to f |
Pairs of the sames nodes are skipped. Uncomment the corresponding line of code if you want them.
| f | the function performed with all pairs of nodes | |
| arg | a pointer to an addition argument that is passed to f |
Definition at line 339 of file KinematicTree.cpp.
{
unsigned int i,j;
int nb=0;
//nb = (*f)(this,this,arg); //if one wants pairs of same elements
for(i=0; i<children.size();i++){
nb+=children[i]->CheckPairsOfNodes(f,arg); // the pair of nodes is in the same subtree i
nb+=children[i]->CheckTreeNode1(this,f,arg); // the pairs composed of this and all descent of i
for(j=i+1; j<children.size();j++){ // the pairs composed of one elmnt in i and one in j
nb+= children[j]->CheckTreeNode2(children[i],f,arg);
}
}
return nb;
}
| void ArticulatedTree::CopyTree | ( | pArticulatedTree_t | tree | ) | [inherited] |
copies the values from another tree with the same structure.
Assumes that all the tree structure is already allocated
| tree | the tree to be copied |
Definition at line 213 of file KinematicTree.cpp.
{
unsigned int j;
CVector3_t v;
tree->GetAxis(v);
joint.SetRotationAxis(v);
// tree->GetJoint()->GetRotationParam(v);
// joint.SetTransfo(v);
joint.SetTranslation(tree->GetJoint()->GetTranslation());
for(j=0;j<children.size();j++){
children[j]->CopyTree(tree->GetChildren()->at(j));
}
}
| int ArticulatedTree::Deserialize | ( | const float * | data, | |
| int | data_size | |||
| ) | [inherited] |
Deserializes the translation vectors and rotation axes.
Assumes that the other side (i.e. Serialize) knows the structure of the tree. No information about joint angles is extracted
Definition at line 392 of file KinematicTree.cpp.
{
int n=1;
ArticulatedTreeList_t::const_iterator it;
if(data_size<6){
cout<<"warning: writing outside buffer in ArticulatedTree::Deserialize"
<<endl;
return 0;
}
joint.SetTranslation(data);
joint.SetRotationAxis(data+3);
for(it=children.begin(); it!=children.end(); ++it){
n+=(*it)->Deserialize(data+n*6,data_size-n*6);
}
return n;
}
| pArticulatedTree_t ArticulatedTree::FindSubTree | ( | pArticulatedTree_t | t, | |
| pArticulatedTree_t | exclude = NULL | |||
| ) | [inherited] |
tells whether the tree contains a given subtree.
| t | the subtree to look for | |
| exclude | a subtree to exclude from search (typically because it has already been searched) NULL if the tree does not contain the given subtree, a pointer to the subtree (i.e. t) otherwise |
Definition at line 139 of file KinematicTree.cpp.
References ArticulatedTree::FindSubTree().
Referenced by ArticulatedTree::FindSubTree(), and KinematicTree::LoadChainRec().
{
if(this==t){
return this;
}
else{
ArticulatedTreeList_t::const_iterator it;
pArticulatedTree_t res;
for(it=children.begin(); it!=children.end(); ++it){
if(*it != exclude){
res =(*it)->FindSubTree(t,exclude);
if(res != NULL){
return res;
}
}
}
return NULL;
}
}
| int ArticulatedTree::GetAngleList | ( | float * | list | ) | [inherited] |
@ brief puts all the joint angles into a list @ param list the array of angles.
Use GetSize to know with what size to initializze this array
Definition at line 411 of file KinematicTree.cpp.
{
ArticulatedTreeList_t::const_iterator it;
int n=1;
*list= joint.GetAngle();
for(it=children.begin(); it!=children.end(); ++it){
n+=(*it)->GetAngleList(list+n);
}
return n;
}
| void EmbodiedArticulatedTree::Render | ( | ) |
| update | 0 if the shape should not be updated according the ArticulatedTree |
Definition at line 100 of file EmbodiedArticulatedTree.cpp.
{
RenderBegin();
if(solid){
solid->Render();
solid->Unhighlight();
}
ArticulatedTreeList_t::const_iterator it;
for(it=children.begin(); it!=children.end(); ++it){
((EmbodiedArticulatedTree *)(*it))->Render();
}
RenderEnd();
}
| int ArticulatedTree::Serialize | ( | float * | data, | |
| int | data_size | |||
| ) | const [inherited] |
Serializes the translation vectors and rotation axes.
Assumes that the other side (i.e. Deserialize) knows the structure of the tree. No information about joint angles is provided
Definition at line 375 of file KinematicTree.cpp.
{
int n=1;
ArticulatedTreeList_t::const_iterator it;
if(data_size<6){
cout<<"warning: writing outside buffer in ArticulatedTree::Serialize"
<<endl;
return 0;
}
v_copy(joint.GetTranslation(),data);
v_copy(joint.GetRotationAxis(),data+3);
for(it=children.begin(); it!=children.end(); ++it){
n+=(*it)->Serialize(data+n*6,data_size-n*6);
}
return n;
}
1.7.1