basic/kinematics/Configuration.cpp

Go to the documentation of this file.
00001 
00002 #include <assert.h>
00003 #include "Configuration.h"
00004 #include "opengl/glos.h"
00005 #include <iostream>
00006 
00007 #ifndef NOGL
00008 #include <gl/gl.h>
00009 #endif
00010 //## begin module%36FB16A7000A.additionalDeclarations preserve=yes
00011 
00012 using std::ostream ;
00013 using std::istream ;
00014 
00015 //## end module%36FB16A7000A.additionalDeclarations
00016 
00017 
00018 // Class Configuration 
00019 
00020 
00021 
00022 
00023 
00024 Configuration::Configuration (const VectorN& right)
00025   //## begin Configuration::Configuration%922595701.hasinit preserve=no
00026   //## end Configuration::Configuration%922595701.hasinit
00027   //## begin Configuration::Configuration%922595701.initialization preserve=yes
00028   :
00029         VectorN( right )
00030   //## end Configuration::Configuration%922595701.initialization
00031 {
00032   //## begin Configuration::Configuration%922595701.body preserve=yes
00033   //## end Configuration::Configuration%922595701.body
00034 }
00035 
00036 Configuration::Configuration ()
00037   //## begin Configuration::Configuration%922595705.hasinit preserve=no
00038   //## end Configuration::Configuration%922595705.hasinit
00039   //## begin Configuration::Configuration%922595705.initialization preserve=yes
00040   //## end Configuration::Configuration%922595705.initialization
00041 {
00042   //## begin Configuration::Configuration%922595705.body preserve=yes
00043   //## end Configuration::Configuration%922595705.body
00044 }
00045 
00046 
00047 Configuration::~Configuration()
00048 {
00049   //## begin Configuration::~Configuration%.body preserve=yes
00050   //## end Configuration::~Configuration%.body
00051 }
00052 
00053 
00054 
00055 //## Other Operations (implementation)
00056 void Configuration::SetNumDOF (const int dof)
00057 {
00058   //## begin Configuration::SetNumDOF%922569945.body preserve=yes
00059         SetLength( dof ) ;
00060   //## end Configuration::SetNumDOF%922569945.body
00061 }
00062 
00063 bool Configuration::SetJointVar (const unsigned int jointNum, const double jointVal)
00064 {
00065   //## begin Configuration::SetJointVar%922569946.body preserve=yes
00066     unsigned int size = Size();
00067         if( jointNum >= size )
00068         {
00069                 return false ;
00070         }
00071     operator[]( jointNum ) = jointVal;
00072         return true ;
00073   //## end Configuration::SetJointVar%922569946.body
00074 }
00075 
00076 const unsigned int Configuration::DOF () const
00077 {
00078   //## begin Configuration::DOF%923255751.body preserve=yes
00079         return Length() ;
00080   //## end Configuration::DOF%923255751.body
00081 }
00082 
00083 double Configuration::GetJointVar (const unsigned int jointNum) const
00084 {
00085   //## begin Configuration::GetJointVar%923255752.body preserve=yes
00086         assert( jointNum < DOF() ) ;
00087         return this->operator[]( jointNum ) ; 
00088   //## end Configuration::GetJointVar%923255752.body
00089 }
00090 
00091 //=============================================================================
00092 // GlDraw()
00093 //
00094 // Description: sends the vertex off to opengl
00095 //=============================================================================
00096 void Configuration::GlDraw() const
00097 {
00098 #ifndef NOGL
00099         double x = 0;
00100         double y = 0; 
00101         double z = 0;
00102     unsigned int elementSize = Size();
00103         int size = elementSize;
00104         if( size > 0 )
00105         {
00106                 x = operator[]( 0 );
00107                 if( size > 1 )
00108                 {
00109                         y = operator[]( 1 );
00110                         if( size > 2 )
00111                         {
00112                                 z = operator[]( 2 );
00113                         }
00114                 }
00115         }
00116         glVertex3d( x, y, z );
00117 #endif
00118 }
00119 
00120 
00121 Configuration& Configuration::operator = (const Configuration& right)
00122 {
00123   //## begin Configuration::operator=%923255754.body preserve=yes
00124         if( this == &right )
00125         {
00126                 return *this ;
00127         }
00128         VectorN::operator=( right ) ;   //call the parent's assignment operator
00129         return *this;
00130   //## end Configuration::operator=%923255754.body
00131 }
00132 
00133 bool Configuration::operator < (const VectorN& right) const
00134 {
00135   //## begin Configuration::operator<%945198435.body preserve=yes
00136         assert( false ) ;
00137         return false ;
00138   //## end Configuration::operator<%945198435.body
00139 }
00140 
00141 // Additional Declarations
00142   //## begin Configuration%36FB16A7000A.declarations preserve=yes
00143   //## end Configuration%36FB16A7000A.declarations
00144 
00145 //## begin module%36FB16A7000A.epilog preserve=yes
00146 //-----------------------------------------------------------------------------
00147 ostream & operator<<(ostream &os, const Configuration& v)
00148 {
00149         os << VectorN( v ) ;
00150         return os ;
00151 }
00152 //-----------------------------------------------------------------------------
00153 istream & operator>>(istream &is, Configuration& v)
00154 {
00155         VectorN readIn ;
00156         is >> readIn ;
00157         v = Configuration( readIn );
00158         return is ;
00159 }
00160 //## end module%36FB16A7000A.epilog

Generated on Sat Apr 1 21:30:34 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO