Choreonoid  1.5
LinkTraverse.h
Go to the documentation of this file.
1 
7 #ifndef CNOID_BODY_LINK_TRAVERSE_H
8 #define CNOID_BODY_LINK_TRAVERSE_H
9 
10 #include <vector>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class Link;
16 
18 {
19 public:
20  LinkTraverse();
21  LinkTraverse(int size);
22  LinkTraverse(Link* root, bool doUpward = false, bool doDownward = true);
23 
24  virtual ~LinkTraverse();
25 
26  void clear();
27 
28  virtual void find(Link* root, bool doUpward = false, bool doDownward = true);
29 
30  int numLinks() const {
31  return links.size();
32  }
33 
34  bool empty() const {
35  return links.empty();
36  }
37 
38  std::size_t size() const {
39  return links.size();
40  }
41 
42  Link* rootLink() const {
43  return (links.empty() ? 0 : links.front());
44  }
45 
46  Link* link(int index) const {
47  return links[index];
48  }
49 
50  Link* operator[] (int index) const {
51  return links[index];
52  }
53 
54  std::vector<Link*>::const_iterator begin() const {
55  return links.begin();
56  }
57 
58  std::vector<Link*>::const_iterator end() const {
59  return links.end();
60  }
61 
67  bool isDownward(int index) const {
68  return (index >= numUpwardConnections);
69  }
70 
71  void calcForwardKinematics(bool calcVelocity = false, bool calcAcceleration = false) const;
72 
73 protected:
74  std::vector<Link*> links;
76 
77 private:
78  void traverse(Link* link, bool doUpward, bool doDownward, bool isUpward, Link* prev);
79 };
80 
81 };
82 
83 #endif
bool isDownward(int index) const
Definition: LinkTraverse.h:67
std::size_t size() const
Definition: LinkTraverse.h:38
Link * link(int index) const
Definition: LinkTraverse.h:46
std::vector< Link * > links
Definition: LinkTraverse.h:74
std::vector< Link * >::const_iterator begin() const
Definition: LinkTraverse.h:54
bool empty() const
Definition: LinkTraverse.h:34
int numUpwardConnections
Definition: LinkTraverse.h:75
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
Definition: LinkTraverse.h:17
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
int numLinks() const
Definition: LinkTraverse.h:30
Link * rootLink() const
Definition: LinkTraverse.h:42
std::vector< Link * >::const_iterator end() const
Definition: LinkTraverse.h:58