Developer Documentation
JointT.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef JOINTT_HH
51 #define JOINTT_HH
52 
53 #include <vector>
54 
55 template<typename PointT>
56 class SkeletonT;
57 
65 template <class PointT>
66 class JointT
67 {
68  template< class >
69  friend class SkeletonT;
70 
71 public:
72  typedef PointT Point;
73  typedef typename Point::value_type Scalar;
74  typedef JointT<PointT> Joint;
75  typedef typename std::vector<Joint*>::iterator ChildIter;
76 
77 public:
79  JointT(const Joint &_other);
80  JointT(Joint *_parent, std::string _name = "");
82  ~JointT();
83 
85  inline unsigned int id();
86 
88  inline void setParent(Joint *_newParent, SkeletonT<PointT> &_skeleton);
89  inline Joint *parent();
90 
91  inline bool isRoot();
92 
93 public:
99  inline ChildIter begin();
100  inline ChildIter end();
101  inline size_t size();
102  inline Joint *child(size_t _index);
104 
110  inline bool selected();
111  inline void setSelected(bool _selected);
113 
115  inline std::string name();
116  inline void setName(std::string _name);
117 
118 private:
120  unsigned int id_;
121  bool selected_;
122 
123 protected:
124  inline void setId(unsigned int _id);
125 
127  Joint *parent_;
129  std::vector<Joint*> children_;
131  std::string name_;
132 };
133 
134 //=============================================================================
135 #if defined(INCLUDE_TEMPLATES) && !defined(JOINTT_C)
136 #define JOINTT_TEMPLATES
137 #include "JointT.cc"
138 #endif
139 //=============================================================================
140 #endif
unsigned int id_
An unique identifier, guaranteed to be part of a continuous sequence starting from 0...
Definition: JointT.hh:120
Represents a single joint in the skeleton.
Definition: JointT.hh:66
Joint * child(size_t _index)
Returns the child joint with the given index.
Definition: JointT.cc:217
std::string name_
the name of the joint
Definition: JointT.hh:131
~JointT()
Destructor.
Definition: JointT.cc:90
void setParent(Joint *_newParent, SkeletonT< PointT > &_skeleton)
access parent of the joint
Definition: JointT.cc:128
ChildIter begin()
Returns an iterator on the joints children.
Definition: JointT.cc:181
bool selected()
Returns the joint&#39;s selection state.
Definition: JointT.cc:233
void setSelected(bool _selected)
Set the joint&#39;s selction state.
Definition: JointT.cc:245
unsigned int id()
returns the joint id
Definition: JointT.cc:103
std::string name()
Access the name of the joint.
Definition: JointT.cc:253
std::vector< Joint * > children_
The joints children, use the JointT::getChild method to access them.
Definition: JointT.hh:129
Joint * parent_
The parent joint; this joint is in its parents JointT::children_ vector. It&#39;s 0 for the root node...
Definition: JointT.hh:127
Joint * parent()
Returns the parent joint.
Definition: JointT.cc:162
ChildIter end()
Returns the end iterator for the joints children.
Definition: JointT.cc:192
size_t size()
Returns the number of children.
Definition: JointT.cc:203
JointT(const Joint &_other)
Constructor.
Definition: JointT.cc:79