Blender V2.61 - r43446

FixedObject.cpp

Go to the documentation of this file.
00001 
00004 /*
00005  * FixedObject.cpp
00006  *
00007  *  Created on: Feb 10, 2009
00008  *      Author: benoitbolsee
00009  */
00010 
00011 #include "FixedObject.hpp"
00012 
00013 namespace iTaSC{
00014 
00015 
00016 FixedObject::FixedObject():UncontrolledObject(),
00017     m_finalized(false), m_nframe(0)
00018 {
00019 }
00020 
00021 FixedObject::~FixedObject() 
00022 {
00023     m_frameArray.clear();
00024 }
00025 
00026 int FixedObject::addFrame(const std::string& name, const Frame& frame)
00027 {
00028     if (m_finalized)
00029         return -1;
00030     FrameList::iterator it;
00031     unsigned int i;
00032     for (i=0, it=m_frameArray.begin(); i<m_nframe; i++, it++) {
00033         if (it->first == name) {
00034             // this frame will replace the old frame
00035             it->second = frame;
00036             return i;
00037         }
00038     }
00039     m_frameArray.push_back(FrameList::value_type(name,frame));
00040     return m_nframe++;
00041 }
00042 
00043 int FixedObject::addEndEffector(const std::string& name)
00044 {
00045     // verify that this frame name exist
00046     FrameList::iterator it;
00047     unsigned int i;
00048     for (i=0, it=m_frameArray.begin(); i<m_nframe; i++, it++) {
00049         if (it->first == name) {
00050             return i;
00051         }
00052     }
00053     return -1;
00054 }
00055 
00056 void FixedObject::finalize()
00057 {
00058     if (m_finalized)
00059         return;
00060     initialize(0, m_nframe);
00061     m_finalized = true;
00062 }
00063 
00064 const Frame& FixedObject::getPose(const unsigned int frameIndex)
00065 {
00066     if (frameIndex < m_nframe) {
00067         return m_frameArray[frameIndex].second;
00068     } else {
00069         return F_identity;
00070     }
00071 }
00072 
00073 }