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 #ifndef JOINTT_HH
45 #define JOINTT_HH
46
47 #include <vector>
48
49 template<typename PointT>
50 class SkeletonT;
51
59 template <class PointT>
60 class JointT
61 {
62 template< class >
63 friend class SkeletonT;
64
65 public:
66 typedef PointT Point;
67 typedef typename Point::value_type Scalar;
68 typedef JointT<PointT> Joint;
69 typedef typename std::vector<Joint*>::iterator ChildIter;
70
71 public:
73 JointT(const Joint &_other);
74 JointT(Joint *_parent, std::string _name = "");
76 ~JointT();
77
79 inline size_t id() const;
80
82 inline void setParent(Joint *_newParent, SkeletonT<PointT> &_skeleton);
83 inline Joint *parent();
84
85 inline bool isRoot() const;
86
87 public:
93 inline ChildIter begin();
94 inline ChildIter end();
95 inline size_t size() const;
96 inline Joint *child(size_t _index);
98
104 inline bool selected() const;
105 inline void setSelected(bool _selected);
107
109 inline std::string name() const;
110 inline void setName(const std::string& _name);
111
112 private:
114 size_t id_;
115 bool selected_;
116
117 protected:
118 inline void setId(const size_t _id);
119
121 Joint *parent_;
123 std::vector<Joint*> children_;
125 std::string name_;
126 };
127
128 //=============================================================================
129 #if defined(INCLUDE_TEMPLATES) && !defined(JOINTT_C)
130 #define JOINTT_TEMPLATES
131 #include "JointT_impl.hh"
132 #endif
133 //=============================================================================
134 #endif
JointT::id
size_t id() const
returns the joint id
Definition: JointT_impl.hh:97
JointT::size
size_t size() const
Returns the number of children.
Definition: JointT_impl.hh:197
JointT::setSelected
void setSelected(bool _selected)
Set the joint&#39;s selction state.
Definition: JointT_impl.hh:239
JointT::setParent
void setParent(Joint *_newParent, SkeletonT< PointT > &_skeleton)
access parent of the joint
Definition: JointT_impl.hh:122
JointT::name
std::string name() const
Access the name of the joint.
Definition: JointT_impl.hh:247
JointT::end
ChildIter end()
Returns the end iterator for the joints children.
Definition: JointT_impl.hh:186
JointT::JointT
JointT(const Joint &_other)
Constructor.
Definition: JointT_impl.hh:73
JointT
Represents a single joint in the skeleton.
Definition: JointT.hh:60
JointT::selected
bool selected() const
Returns the joint&#39;s selection state.
Definition: JointT_impl.hh:227
JointT::child
Joint * child(size_t _index)
Returns the child joint with the given index.
Definition: JointT_impl.hh:211
JointT::name_
std::string name_
the name of the joint
Definition: JointT.hh:125
JointT::id_
size_t id_
An unique identifier, guaranteed to be part of a continuous sequence starting from 0...
Definition: JointT.hh:114
JointT::parent
Joint * parent()
Returns the parent joint.
Definition: JointT_impl.hh:156
SkeletonT
Definition: JointT.hh:50
JointT::parent_
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:121
JointT::~JointT
~JointT()
Destructor.
Definition: JointT_impl.hh:84
JointT::children_
std::vector< Joint * > children_
The joints children, use the JointT::getChild method to access them.
Definition: JointT.hh:123
JointT::begin
ChildIter begin()
Returns an iterator on the joints children.
Definition: JointT_impl.hh:175