Skip to content

Commit a2dbc58

Browse files
author
Tobias Löw
committed
updated LinkVisual to allow copying
1 parent 5629d79 commit a2dbc58

File tree

2 files changed

+44
-54
lines changed

2 files changed

+44
-54
lines changed

src/gafro/robot/Link.hpp

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,45 @@ namespace gafro
2929
template <class T>
3030
class Joint;
3131

32+
class LinkVisual
33+
{
34+
public:
35+
enum class Type
36+
{
37+
SPHERE,
38+
MESH,
39+
CYLINDER,
40+
BOX
41+
};
42+
43+
LinkVisual(const Type &type, const Motor<double> &transform) : type_(type), transform_(transform) {}
44+
45+
virtual ~LinkVisual() = default;
46+
47+
virtual std::unique_ptr<LinkVisual> copy() const = 0;
48+
49+
const Type &getType() const
50+
{
51+
return type_;
52+
}
53+
54+
const Motor<double> &getTransform() const
55+
{
56+
return transform_;
57+
}
58+
59+
template <class Derived>
60+
const Derived *cast() const
61+
{
62+
return static_cast<const Derived *>(this);
63+
}
64+
65+
private:
66+
const Type type_;
67+
68+
Motor<double> transform_;
69+
};
70+
3271
template <class T>
3372
class Link
3473
{
@@ -89,47 +128,14 @@ namespace gafro
89128
typename Motor<T>::Generator axis_;
90129

91130
public:
92-
class Visual
93-
{
94-
public:
95-
enum class Type
96-
{
97-
SPHERE,
98-
MESH,
99-
CYLINDER,
100-
BOX
101-
};
102-
103-
Visual(const Type &type, const Motor<T> &transform);
104-
105-
virtual ~Visual() = default;
106-
107-
virtual std::unique_ptr<Visual> copy() const = 0;
108-
109-
const Type &getType() const;
110-
111-
const Motor<T> &getTransform() const;
112-
113-
template <class Derived>
114-
const Derived *cast() const
115-
{
116-
return static_cast<const Derived *>(this);
117-
}
118-
119-
private:
120-
const Type type_;
121-
122-
Motor<T> transform_;
123-
};
124-
125131
private:
126-
std::unique_ptr<Visual> visual_;
132+
std::unique_ptr<LinkVisual> visual_;
127133

128134
public:
129-
void setVisual(std::unique_ptr<Visual> &&visual);
135+
void setVisual(std::unique_ptr<LinkVisual> &&visual);
130136

131137
bool hasVisual() const;
132138

133-
const Visual *getVisual() const;
139+
const LinkVisual *getVisual() const;
134140
};
135141
} // namespace gafro

src/gafro/robot/Link.hxx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,7 @@ namespace gafro
139139
}
140140

141141
template <class T>
142-
Link<T>::Visual::Visual(const Type &type, const Motor<T> &transform) : type_(type), transform_(transform)
143-
{}
144-
145-
template <class T>
146-
const typename Link<T>::Visual::Type &Link<T>::Visual::getType() const
147-
{
148-
return type_;
149-
}
150-
151-
template <class T>
152-
const Motor<T> &Link<T>::Visual::getTransform() const
153-
{
154-
return transform_;
155-
}
156-
157-
template <class T>
158-
void Link<T>::setVisual(std::unique_ptr<Visual> &&visual)
142+
void Link<T>::setVisual(std::unique_ptr<LinkVisual> &&visual)
159143
{
160144
visual_ = std::move(visual);
161145
}
@@ -167,7 +151,7 @@ namespace gafro
167151
}
168152

169153
template <class T>
170-
const typename Link<T>::Visual *Link<T>::getVisual() const
154+
const LinkVisual *Link<T>::getVisual() const
171155
{
172156
return visual_.get();
173157
}

0 commit comments

Comments
 (0)