33#ifndef DART_DYNAMICS_DETAIL_BODYNODE_HPP_
34#define DART_DYNAMICS_DETAIL_BODYNODE_HPP_
45template <
class Jo
intType>
47 BodyNode* _newParent,
const typename JointType::Properties& _joint)
49 if (
nullptr == _newParent)
50 return getSkeleton()->template moveBodyNodeTree<JointType>(
53 return getSkeleton()->template moveBodyNodeTree<JointType>(
54 this, _newParent->
getSkeleton(), _newParent, _joint);
58template <
class Jo
intType>
62 const typename JointType::Properties& _joint)
64 return getSkeleton()->template moveBodyNodeTree<JointType>(
65 this, _newSkeleton, _newParent, _joint);
69template <
class Jo
intType>
71 const std::string& _skeletonName,
72 const typename JointType::Properties& _joint)
75 skel->setName(_skeletonName);
76 moveTo<JointType>(skel,
nullptr, _joint);
81template <
class Jo
intType>
83 const typename JointType::Properties& _joint)
89template <
class Jo
intType>
92 const typename JointType::Properties& _joint,
95 if (
nullptr == _newParent)
100 this, _newParent->
getSkeleton(), _newParent, _joint, _recursive);
104template <
class Jo
intType>
108 const typename JointType::Properties& _joint,
109 bool _recursive)
const
111 return getSkeleton()->cloneBodyNodeTree<JointType>(
112 this, _newSkeleton, _newParent, _joint, _recursive);
116template <
class Jo
intType>
118 const std::string& _skeletonName,
119 const typename JointType::Properties& _joint,
120 bool _recursive)
const
123 skel->setName(_skeletonName);
124 copyTo<JointType>(skel,
nullptr, _joint, _recursive);
129template <
class Jo
intType,
class NodeType>
131 const typename JointType::Properties& _jointProperties,
132 const typename NodeType::Properties& _bodyProperties)
134 return getSkeleton()->createJointAndBodyNodePair<JointType, NodeType>(
135 this, _jointProperties, _bodyProperties);
139template <
class NodeType,
typename... Args>
142 NodeType* node =
new NodeType(
this, std::forward<Args>(args)...);
149template <
class ShapeNodeProperties>
151 ShapeNodeProperties
properties,
bool automaticName)
163template <
class ShapeType>
173template <
class ShapeType,
class StringType>
175 const std::shared_ptr<ShapeType>& shape, StringType&&
name)
185template <
class... Aspects>
193template <
class... Aspects>
205template <
class AspectT>
211 for (
auto i = 0u; i < numShapeNode; ++i)
221template <
class AspectT>
224 std::vector<ShapeNode*> shapeNodes;
228 for (
auto i = 0u; i < numShapeNode; ++i)
232 if (shapeNode->has<AspectT>())
233 shapeNodes.push_back(shapeNode);
240template <
class AspectT>
243 std::vector<const ShapeNode*> shapeNodes;
247 for (
auto i = 0u; i < numShapeNode; ++i)
251 if (shapeNode->has<AspectT>())
252 shapeNodes.push_back(shapeNode);
259template <
class AspectT>
262 std::size_t count = 0;
264 eachShapeNodeWith<AspectT>([&](
ShapeNode* shapeNode) ->
bool {
265 if (count++ ==
index)
277template <
class AspectT>
280 std::size_t count = 0;
282 eachShapeNodeWith<AspectT>([&](
const ShapeNode* shapeNode) ->
bool {
283 if (count++ ==
index)
295template <
class AspectT>
298 eachShapeNodeWith<AspectT>([](
ShapeNode* shapeNode) { shapeNode->remove(); });
302template <
typename AspectT,
typename Func>
305 if constexpr (std::is_same_v<
306 std::invoke_result_t<Func, const ShapeNode*>,
312 if (shapeNode->has<AspectT>())
314 if (!func(shapeNode))
324 if (shapeNode->has<AspectT>())
333template <
typename AspectT,
typename Func>
336 if constexpr (std::is_same_v<std::invoke_result_t<Func, ShapeNode*>,
bool>)
341 if (shapeNode->has<AspectT>())
343 if (!func(shapeNode))
353 if (shapeNode->has<AspectT>())
BodyPropPtr properties
Definition SdfParser.cpp:80
std::string * name
Definition SkelParser.cpp:1698
std::size_t index
Definition SkelParser.cpp:1673
const AspectProperties & getAspectProperties() const
Definition EmbeddedAspect.hpp:408
Definition CompositeData.hpp:187
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:80
ShapeNode * getShapeNodeWith(std::size_t index)
Returns the index-th ShapeNode among the ShapeNodes that have a specific Aspect.
Definition BodyNode.hpp:260
const std::string & getName() const override
Return the name of this Entity.
Definition BodyNode.cpp:459
void removeAllShapeNodesWith()
Remove all ShapeNodes containing given Aspect from this BodyNode.
Definition BodyNode.hpp:296
ShapeNode * createShapeNode(ShapeNodeProperties properties, bool automaticName=true)
Create an ShapeNode attached to this BodyNode.
Definition BodyNode.hpp:150
SkeletonPtr getSkeleton() override
Return the Skeleton that this Node is attached to.
Definition BodyNode.cpp:857
std::size_t getNumShapeNodes() const
Definition BodyNode.cpp:953
NodeType * createNode(Args &&... args)
Create some Node type and attach it to this BodyNode.
Definition BodyNode.hpp:140
const std::vector< ShapeNode * > getShapeNodesWith()
Return the list of ShapeNodes containing given Aspect.
Definition BodyNode.hpp:222
JointType * changeParentJointType(const typename JointType::Properties &_joint=typename JointType::Properties())
Change the Joint type of this BodyNode's parent Joint.
Definition BodyNode.hpp:82
std::pair< JointType *, NodeType * > createChildJointAndBodyNodePair(const typename JointType::Properties &_jointProperties=typename JointType::Properties(), const typename NodeType::Properties &_bodyProperties=typename NodeType::Properties())
Create a Joint and BodyNode pair as a child of this BodyNode.
Definition BodyNode.hpp:130
SkeletonPtr split(const std::string &_skeletonName)
Remove this BodyNode and all of its children (recursively) from their current Skeleton and move them ...
Definition BodyNode.cpp:808
SkeletonPtr copyAs(const std::string &_skeletonName, bool _recursive=true) const
Create clones of this BodyNode and all of its children (recursively) and create a new Skeleton with t...
Definition BodyNode.cpp:846
bool moveTo(BodyNode *_newParent)
Remove this BodyNode and all of its children (recursively) from their current parent BodyNode,...
Definition BodyNode.cpp:784
void eachShapeNodeWith(Func func) const
Iterates all the ShapeNodes that has a specific aspect and invokes the callback function.
Definition BodyNode.hpp:303
ShapeNode * createShapeNodeWith(const ShapePtr &shape)
Create a ShapeNode with the specified Aspects and an automatically assigned name: <BodyNodeName>Shape...
Definition BodyNode.hpp:186
ShapeNode * getShapeNode(std::size_t index)
Definition BodyNode.cpp:953
BodyNode * getParentBodyNode()
Return the parent BodyNdoe of this BodyNode.
Definition BodyNode.cpp:881
std::size_t getNumShapeNodesWith() const
Return the number of ShapeNodes containing given Aspect in this BodyNode.
Definition BodyNode.hpp:206
std::pair< Joint *, BodyNode * > copyTo(BodyNode *_newParent, bool _recursive=true)
Create clones of this BodyNode and all of its children recursively (unless _recursive is set to false...
Definition BodyNode.cpp:818
Definition ShapeNode.hpp:49
static SkeletonPtr create(const std::string &_name="Skeleton")
Create a new Skeleton inside of a shared_ptr.
Definition Skeleton.cpp:384
void createAspects(T *)
Attach an arbitrary number of Aspects to the specified Composite type.
Definition Composite.hpp:145
std::shared_ptr< Shape > ShapePtr
Definition SmartPointer.hpp:81
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:60