DART  6.6.2
ShapeFrame.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_DYNAMICS_SHAPEFRAME_HPP_
34 #define DART_DYNAMICS_SHAPEFRAME_HPP_
35 
36 #include <Eigen/Dense>
37 
38 #include "dart/common/Signal.hpp"
45 
46 namespace dart {
47 namespace dynamics {
48 
49 //==============================================================================
50 class VisualAspect final :
52  VisualAspect,
53  detail::VisualAspectProperties,
54  ShapeFrame>
55 {
56 public:
57 
60 
63 
64  VisualAspect(const VisualAspect&) = delete;
65 
67  void setRGBA(const Eigen::Vector4d& color);
68 
69  DART_COMMON_GET_ASPECT_PROPERTY( Eigen::Vector4d, RGBA )
70  // const Eigen::Vector4d& getRGBA() const;
71 
73  // void setHidden(const bool& value);
74  // const bool& getHidden() const;
75 
77  // void setShadowed(const bool& value);
78  // const bool& getShadowed() const;
79 
81  void setColor(const Eigen::Vector3d& color);
82 
84  void setColor(const Eigen::Vector4d& color);
85 
87  void setRGB(const Eigen::Vector3d& rgb);
88 
90  void setAlpha(const double alpha);
91 
93  Eigen::Vector3d getColor() const;
94 
96  Eigen::Vector3d getRGB() const;
97 
99  double getAlpha() const;
100 
102  void hide();
103 
105  void show();
106 
109  bool isHidden() const;
110 
111 };
112 
113 //==============================================================================
114 class CollisionAspect final :
115  public common::AspectWithVersionedProperties<
117  detail::CollisionAspectProperties,
118  ShapeFrame>
119 {
120 public:
121 
122  CollisionAspect(const CollisionAspect &) = delete;
124 
126  // void setCollidable(const bool& value);
127  // const bool& getCollidable() const;
128 
129 
130  bool isCollidable() const;
131 
132 };
133 
134 //==============================================================================
135 class DynamicsAspect final :
137  DynamicsAspect,
138  detail::DynamicsAspectProperties,
139  ShapeFrame>
140 {
141 public:
142 
145 
146  DynamicsAspect(const DynamicsAspect&) = delete;
147 
149 
150  DART_COMMON_SET_GET_ASPECT_PROPERTY( double, FrictionCoeff )
151  // void setFrictionCoeff(const double& value);
152  // const double& getFrictionCoeff() const;
153  DART_COMMON_SET_GET_ASPECT_PROPERTY( double, RestitutionCoeff )
154  // void setRestitutionCoeff(const double& value);
155  // const double& getRestitutionCoeff() const;
156 
157 };
158 
159 //==============================================================================
160 class ShapeFrame :
161  public virtual common::VersionCounter,
162  public detail::ShapeFrameCompositeBase,
163  public virtual Frame
164 {
165 public:
166 
167  friend class BodyNode;
168 
170  = common::Signal<void(const ShapeFrame* thisShapeFrame,
171  const ShapePtr& oldShape,
172  const ShapePtr& newShape)>;
173 
175  = common::Signal<void(const ShapeFrame* thisShapeFrame,
176  const Eigen::Isometry3d& oldTransform,
177  const Eigen::Isometry3d& newTransform)>;
178 
181 
183  virtual ~ShapeFrame() = default;
184 
187 
190 
191  const AspectProperties& getAspectProperties() const;
192 
194  void setShape(const ShapePtr& shape);
195 
197  ShapePtr getShape();
198 
200  ConstShapePtr getShape() const;
201 
203 
205 
207 
208  // Documentation inherited
209  ShapeFrame* asShapeFrame() override;
210 
211  // Documentation inherited
212  const ShapeFrame* asShapeFrame() const override;
213 
215  bool isShapeNode() const;
216 
219  virtual ShapeNode* asShapeNode();
220 
226  virtual const ShapeNode* asShapeNode() const;
227 
228 protected:
229 
231  ShapeFrame(Frame* parent, const Properties& properties);
232 
234  ShapeFrame(Frame* parent, const ShapePtr& shape = nullptr);
235 
237  ShapeFrame(const std::tuple<Frame*, Properties>& args);
238 
240  bool mAmShapeNode;
241 
243  ShapeUpdatedSignal mShapeUpdatedSignal;
244 
246  RelativeTransformUpdatedSignal mRelativeTransformUpdatedSignal;
247 
248 public:
249 
251  common::SlotRegister<ShapeUpdatedSignal> onShapeUpdated;
252 
254  common::SlotRegister<RelativeTransformUpdatedSignal>
255  onRelativeTransformUpdated;
256 
257 };
258 
259 } // namespace dynamics
260 } // namespace dart
261 
262 #endif // DART_DYNAMICS_SHAPEFRAME_HPP_
#define DART_COMMON_SET_GET_ASPECT_PROPERTY(Type, Name)
Definition: Aspect.hpp:189
#define DART_COMMON_GET_ASPECT_PROPERTY(Type, Name)
Definition: Aspect.hpp:184
BodyPropPtr properties
Definition: SdfParser.cpp:80
typename Impl::AspectProperties AspectProperties
Definition: EmbeddedAspect.hpp:254
AspectWithProtectedProperties generates implementations of the Property managing functions for an Asp...
Definition: AspectWithVersion.hpp:107
PropertiesDataT PropertiesData
Definition: AspectWithVersion.hpp:112
const Aspect::Properties * getAspectProperties() const override final
Definition: AspectWithVersion.hpp:282
void setAspectProperties(const Aspect::Properties &someProperties) override final
Definition: AspectWithVersion.hpp:271
void setProperties(const PropertiesData &properties)
Set the Properties of this Aspect.
Definition: AspectWithVersion.hpp:292
BaseT Base
Definition: AspectWithVersion.hpp:110
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
Definition: ShapeFrame.hpp:119
CollisionAspect(const CollisionAspect &)=delete
Definition: ShapeFrame.hpp:140
DynamicsAspect(const DynamicsAspect &)=delete
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:57
Definition: ShapeFrame.hpp:164
AspectProperties UniqueProperties
Definition: ShapeFrame.hpp:179
virtual ~ShapeFrame()=default
Destructor.
UniqueProperties Properties
Definition: ShapeFrame.hpp:180
Definition: ShapeNode.hpp:49
Definition: ShapeFrame.hpp:55
void setColor(const Eigen::Vector3d &color)
Identical to setRGB(const Eigen::Vector3d&)
Definition: ShapeFrame.cpp:97
void setRGB(const Eigen::Vector3d &rgb)
Set RGB color components (leave alpha alone)
Definition: ShapeFrame.cpp:109
VisualAspect(const VisualAspect &)=delete
VisualAspect(const PropertiesData &properties=PropertiesData())
Constructor.
Definition: ShapeFrame.cpp:80
void hide()
Hide the ShapeNode.
Definition: ShapeFrame.cpp:146
double getAlpha() const
Get the transparency of the Shape.
Definition: ShapeFrame.cpp:140
Eigen::Vector3d getRGB() const
Get RGB color components.
Definition: ShapeFrame.cpp:134
Eigen::Vector3d getColor() const
Get color.
Definition: ShapeFrame.cpp:128
void setRGBA(const Eigen::Vector4d &color)
Set RGBA color.
Definition: ShapeFrame.cpp:87
void show()
Show the ShapeNode.
Definition: ShapeFrame.cpp:152
void setAlpha(const double alpha)
Set the transparency of the Shape.
Definition: ShapeFrame.cpp:118
bool isHidden() const
True iff the ShapeNode is set to be hidden.
Definition: ShapeFrame.cpp:158
#define DART_BAKE_SPECIALIZED_ASPECT(AspectName)
Definition: Composite.hpp:226
Definition: MathTypes.hpp:47
common::EmbedPropertiesOnTopOf< ShapeFrame, ShapeFrameProperties, common::SpecializedForAspect< VisualAspect, CollisionAspect, DynamicsAspect > > ShapeFrameCompositeBase
Definition: ShapeFrameAspect.hpp:120
std::shared_ptr< Shape > ShapePtr
Definition: SmartPointer.hpp:81
std::shared_ptr< const Shape > ConstShapePtr
Definition: SmartPointer.hpp:81
Definition: BulletCollisionDetector.cpp:63
Definition: SharedLibraryManager.hpp:43
Definition: ShapeFrameAspect.hpp:90
Definition: ShapeFrameAspect.hpp:52