chain.cpp

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

Generated on Wed Nov 23 19:00:00 2011 for FreeCAD by  doxygen 1.6.1