Blender V2.61 - r43446
|
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 #ifndef KDL_TREE_HPP 00023 #define KDL_TREE_HPP 00024 00025 #include "segment.hpp" 00026 #include "chain.hpp" 00027 00028 #include <string> 00029 #include <map> 00030 #if !defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5) 00031 #include <Eigen/Core> 00032 #endif 00033 00034 namespace KDL 00035 { 00036 //Forward declaration 00037 class TreeElement; 00038 #if !defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5) 00039 // Eigen allocator is needed for alignment of Eigen data types 00040 typedef std::map<std::string,TreeElement, std::less<std::string>, Eigen::aligned_allocator<std::pair<std::string, TreeElement> > > SegmentMap; 00041 #else 00042 typedef std::map<std::string,TreeElement> SegmentMap; 00043 #endif 00044 class TreeElement 00045 { 00046 private: 00047 TreeElement():q_nr(0) 00048 {}; 00049 public: 00050 Segment segment; 00051 unsigned int q_nr; 00052 SegmentMap::const_iterator parent; 00053 std::vector<SegmentMap::const_iterator > children; 00054 TreeElement(const Segment& segment_in,const SegmentMap::const_iterator& parent_in,unsigned int q_nr_in) 00055 { 00056 q_nr=q_nr_in; 00057 segment=segment_in; 00058 parent=parent_in; 00059 }; 00060 static TreeElement Root() 00061 { 00062 return TreeElement(); 00063 }; 00064 }; 00065 00072 class Tree 00073 { 00074 private: 00075 SegmentMap segments; 00076 unsigned int nrOfJoints; 00077 unsigned int nrOfSegments; 00078 00079 bool addTreeRecursive(SegmentMap::const_iterator root, const std::string& tree_name, const std::string& hook_name); 00080 00081 public: 00085 Tree(); 00086 Tree(const Tree& in); 00087 Tree& operator= (const Tree& arg); 00088 00100 bool addSegment(const Segment& segment, const std::string& segment_name, const std::string& hook_name); 00101 00113 bool addChain(const Chain& chain, const std::string& chain_name, const std::string& hook_name); 00114 00126 bool addTree(const Tree& tree, const std::string& tree_name,const std::string& hook_name); 00127 00136 unsigned int getNrOfJoints()const 00137 { 00138 return nrOfJoints; 00139 }; 00140 00145 unsigned int getNrOfSegments()const {return nrOfSegments;}; 00146 00154 SegmentMap::const_iterator getSegment(const std::string& segment_name)const 00155 { 00156 return segments.find(segment_name); 00157 }; 00158 00159 00160 00161 const SegmentMap& getSegments()const 00162 { 00163 return segments; 00164 } 00165 00166 virtual ~Tree(){}; 00167 }; 00168 } 00169 #endif 00170 00171 00172 00173 00174