Choreonoid  1.1
LinkTraverse.h
説明を見る。
1 
7 #ifndef CNOID_BODY_LINK_TRAVERSE_H_INCLUDED
8 #define CNOID_BODY_LINK_TRAVERSE_H_INCLUDED
9 
10 #include <vector>
11 #include <ostream>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16  class Link;
17 
19  {
20  public:
21  LinkTraverse();
22  LinkTraverse(int size);
23  LinkTraverse(Link* root, bool doUpward = false, bool doDownward = true);
24 
25  virtual ~LinkTraverse();
26 
27  virtual void find(Link* root, bool doUpward = false, bool doDownward = true);
28 
29  inline int numLinks() const {
30  return links.size();
31  }
32 
33  inline bool empty() const {
34  return links.empty();
35  }
36 
37  inline size_t size() const {
38  return links.size();
39  }
40 
41  inline Link* rootLink() const {
42  return (links.empty() ? 0 : links.front());
43  }
44 
45  inline Link* link(int index) const {
46  return links[index];
47  }
48 
49  inline Link* operator[] (int index) const {
50  return links[index];
51  }
52 
53  inline std::vector<Link*>::const_iterator begin() const {
54  return links.begin();
55  }
56 
57  inline std::vector<Link*>::const_iterator end() const {
58  return links.end();
59  }
60 
66  inline bool isDownward(int index) const {
67  return (index >= numUpwardConnections);
68  }
69 
70  void calcForwardKinematics(bool calcVelocity = false, bool calcAcceleration = false) const;
71 
72  protected:
73 
74  std::vector<Link*> links;
76 
77  private:
78 
79  void traverse(Link* link, bool doUpward, bool doDownward, bool isUpward, Link* prev);
80 
81  };
82 
83 };
84 
85 CNOID_EXPORT std::ostream& operator<<(std::ostream& os, cnoid::LinkTraverse& traverse);
86 
87 #endif