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 nrOfJoints(0), 00029 nrOfSegments(0), 00030 segments(0) 00031 { 00032 } 00033 00034 Chain::Chain(const Chain& in): 00035 nrOfJoints(0), 00036 nrOfSegments(0), 00037 segments(0) 00038 { 00039 for(unsigned int i=0;i<in.getNrOfSegments();i++) 00040 this->addSegment(in.getSegment(i)); 00041 } 00042 00043 Chain& Chain::operator=(const Chain& arg) 00044 { 00045 nrOfJoints=0; 00046 nrOfSegments=0; 00047 segments.resize(0); 00048 for(unsigned int i=0;i<arg.nrOfSegments;i++) 00049 addSegment(arg.getSegment(i)); 00050 return *this; 00051 00052 } 00053 00054 void Chain::addSegment(const Segment& segment) 00055 { 00056 segments.push_back(segment); 00057 nrOfSegments++; 00058 if(segment.getJoint().getType()!=Joint::None) 00059 nrOfJoints++; 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 Segment& Chain::getSegment(unsigned int nr) 00074 { 00075 return segments[nr]; 00076 } 00077 00078 Chain::~Chain() 00079 { 00080 } 00081 00082 } 00083