Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vpjoint.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // ChangeLog
00006 // May 18, 2005 - Bruno de Oliveira Schneider
00007 // - Added destructor that deletes DOFs marked as autoDelete.
00008 // Jan 10, 2005 - Bruno de Oliveira Schneider
00009 // - Added "#include <algorithm>" because MS VC++ users reported compilation errors.
00010 // Oct 08, 2004 - Bruno de Oliveira Schneider
00011 // - Code typing has been cleaned (tabs replaced by spaces, excessive spaces
00012 //   removed, etc.) because tabs and spaces were mixed together.
00013 // - Removed "#include <stdio.h>" from implementation file. Commented out 
00014 //   "PrintLim" method.
00015 // - Moved "using namespace std" from header file to implementation.
00016 // - Removed 'vp' preffix of every method name.
00017 // - Turned VPJoint a subclass of VPTransform. AS A RESULT, MOST ATTRIBUTES AND
00018 //   METHODS WERE REMOVED.
00019 // - Reimplemented "MakeLim()".
00020 // - Added "TransformDofs(VPDof*, const VPTransform&)" so that when one DOF changes
00021 //   it may changed its siblings. This is temporary behaviour - how changes should
00022 //   be carried to the siblings is still an open issue!
00023 // Aug 10, 2000 - Anderson Maciel
00024 // - Class and new methods declaration.
00025 
00026 #include <algorithm>
00027 #include "vpmatrix.h"
00028 #include "vpjoint.h"
00029 #include "vpdof.h"
00030 
00031 //?
00032 #include <iostream>
00033 
00034 using namespace std;
00035 
00036 VPJoint::VPJoint()
00037 {
00038 }
00039 
00040 VPJoint::~VPJoint()
00041 {
00042     // FixMe: Not sure whether this will automatically be called from derived classes,
00043     // deallocation still has to be examined because of stdlib's exit problem...
00044 
00045     //~ cout << "VPJoint::~VPJoint()" << endl;
00046     list<VPDof*>::iterator iter;
00047     for (iter = dofList.begin(); iter != dofList.end(); ++iter)
00048     {
00049         if ((*iter)->autoDelete)
00050         {
00051             //~ cout<<"Joint '"<<description<<"' deleted dof '"<<(*iter)->GetDescription()<<"'.\n";
00052             delete *iter;
00053         }
00054     }
00055 }
00056 
00057 unsigned short int VPJoint::GetNumDofs()
00058 {
00059     return dofList.size();
00060 }
00061 
00062 void VPJoint::AddDof(VPDof* dof)
00063 {
00064     dofList.push_back(dof);
00065     dof->SetOwnerJoint(this);
00066 }
00067 
00068 void VPJoint::MakeLim()
00069 {
00070 // LIM = ...DOF3 * DOF2 * DOF1
00071     list<VPDof*>::const_iterator iter = dofList.begin();
00072     // Copy DOF1's matrix to this object
00073     (*iter)->GetLim(this);
00074     ++iter;
00075     while (iter != dofList.end())
00076     {
00077         (*iter)->ApplyTransformTo(this);
00078         ++iter;
00079     }
00080 }
00081 
00082 void VPJoint::TransformDofs(VPDof* initialDof, const VPTransform& trans)
00083 {
00084     // Transform DOFs that come after initialDof on the dofList
00085     list<VPDof*>::iterator iter = find(dofList.begin(), dofList.end(), initialDof);
00086     ++iter;
00087     while (iter != dofList.end())
00088     {
00089         (*iter)->Transform(trans);
00090         ++iter;
00091     }
00092 }

Generated on Tue Sep 6 10:00:04 2005 for VPAT by  doxygen 1.4.4