Blender V2.61 - r43446

chain.cpp

Go to the documentation of this file.
00001 
00004 // Copyright  (C)  2007  Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00005 
00006 // Version: 1.0
00007 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00008 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
00009 // URL: http://www.orocos.org/kdl
00010 
00011 // This library is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU Lesser General Public
00013 // License as published by the Free Software Foundation; either
00014 // version 2.1 of the License, or (at your option) any later version.
00015 
00016 // This library is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00024 
00025 #include "chain.hpp"
00026 
00027 namespace KDL {
00028     using namespace std;
00029 
00030     Chain::Chain():
00031         segments(0),
00032         nrOfJoints(0),
00033         nrOfSegments(0)
00034     {
00035     }
00036 
00037     Chain::Chain(const Chain& in):nrOfJoints(0),
00038                                   nrOfSegments(0)
00039     {
00040         for(unsigned int i=0;i<in.getNrOfSegments();i++)
00041             this->addSegment(in.getSegment(i));
00042     }
00043 
00044     Chain& Chain::operator=(const Chain& arg)
00045     {
00046         nrOfJoints=0;
00047         nrOfSegments=0;
00048         segments.resize(0);
00049         for(unsigned int i=0;i<arg.nrOfSegments;i++)
00050             addSegment(arg.getSegment(i));
00051         return *this;
00052 
00053     }
00054 
00055     void Chain::addSegment(const Segment& segment)
00056     {
00057         segments.push_back(segment);
00058         nrOfSegments++;
00059         nrOfJoints += segment.getJoint().getNDof();
00060     }
00061 
00062     void Chain::addChain(const Chain& chain)
00063     {
00064         for(unsigned int i=0;i<chain.getNrOfSegments();i++)
00065             this->addSegment(chain.getSegment(i));
00066     }
00067 
00068     const Segment& Chain::getSegment(unsigned int nr) const
00069     {
00070         return segments[nr];
00071     }
00072 
00073     Chain::~Chain()
00074     {
00075     }
00076 
00077 }
00078