33 #ifndef DART_DYNAMICS_DETAIL_NODE_HPP_
34 #define DART_DYNAMICS_DETAIL_NODE_HPP_
46 template <
class NodeType>
49 return static_cast<const NodeType*
>(
this)->mIndexInBodyNode;
53 template <
class NodeType>
56 return static_cast<const NodeType*
>(
this)->mIndexInSkeleton;
60 template <
class NodeType>
63 return static_cast<const NodeType*
>(
this)->mIndexInTree;
67 template <
class NodeType>
70 return static_cast<const NodeType*
>(
this)->getBodyNodePtr()->getTreeIndex();
74 template <
class NodeType>
77 return static_cast<NodeType*
>(
this)->stageForRemoval();
81 template <
class NodeType>
84 static_cast<NodeType*
>(
this)->attach();
93 #define DART_ENABLE_NODE_SPECIALIZATION() \
96 std::size_t getNumNodes() const \
98 return dart::dynamics::BodyNode::getNumNodes<T>(); \
101 T* getNode(std::size_t index) \
103 return dart::dynamics::BodyNode::getNode<T>(index); \
106 const T* getNode(std::size_t index) const \
108 return dart::dynamics::BodyNode::getNode<T>(index); \
112 #define DETAIL_DART_INSTANTIATE_SPECIALIZED_NODE(NodeName, it) \
113 mNodeMap[typeid(NodeName)] = std::vector<dart::dynamics::Node*>(); \
114 it = mNodeMap.find(typeid(NodeName));
117 #define DART_INSTANTIATE_SPECIALIZED_NODE_IRREGULAR(NodeName, PluralName) \
118 DETAIL_DART_INSTANTIATE_SPECIALIZED_NODE(NodeName, m##PluralName##Iterator)
121 #define DART_INSTANTIATE_SPECALIZED_NODE(NodeName) \
122 DART_INSTANTIATE_SPECIALIZED_NODE_IRREGULAR(NodeName, NodeName##s)
125 #define DETAIL_DART_SPECIALIZED_NODE_INLINE(NodeName, PluralName, it) \
127 dart::dynamics::BodyNode::NodeMap::iterator it; \
130 inline std::size_t getNum##PluralName() const \
132 return it->second.size(); \
135 inline NodeName* get##NodeName(std::size_t index) \
137 return static_cast<NodeName*>( \
138 getVectorObjectIfAvailable(index, it->second)); \
141 inline const NodeName* get##NodeName(std::size_t index) const \
143 return static_cast<const NodeName*>( \
144 getVectorObjectIfAvailable(index, it->second)); \
148 #define DART_SPECIALIZED_NODE_INLINE_IRREGULAR(NodeName, PluralName) \
149 DETAIL_DART_SPECIALIZED_NODE_INLINE( \
150 NodeName, PluralName, m##PluralName##Iterator)
153 #define DART_SPECIALIZED_NODE_INTERNAL(NodeName) \
154 DART_SPECIALIZED_NODE_INLINE_IRREGULAR(NodeName, NodeName##s)
157 #define DETAIL_DART_SPECIALIZED_NODE_DECLARE(NodeName, PluralName, it) \
159 dart::dynamics::BodyNode::NodeMap::iterator it; \
162 std::size_t getNum##PluralName() const; \
163 NodeName* get##NodeName(std::size_t index); \
164 const NodeName* get##NodeName(std::size_t index) const;
167 #define DART_SPECIALIZED_NODE_DECLARE_IRREGULAR(NodeName, PluralName) \
168 DETAIL_DART_SPECIALIZED_NODE_DECLARE( \
169 NodeName, PluralName, m##PluralName##Iterator)
172 #define DART_SPECIALIZED_NODE_DECLARE(NodeName) \
173 DART_SPECIALIZED_NODE_DECLARE_IRREGULAR(NodeName, NodeName##s)
176 #define DETAIL_DART_SPECIALIZED_NODE_DEFINE( \
177 BodyNodeType, NodeName, PluralName, it) \
178 std::size_t BodyNodeType ::getNum##PluralName() const \
180 return it->second.size(); \
183 NodeName* BodyNodeType ::get##NodeName(std::size_t index) \
185 return static_cast<NodeName*>( \
186 getVectorObjectIfAvailable(index, it->second)); \
189 const NodeName* BodyNodeType ::get##NodeName(std::size_t index) const \
191 return static_cast<const NodeName*>( \
192 getVectorObjectIfAvailable(index, it->second)); \
196 #define DART_SPECIALIZED_NODE_DEFINE_IRREGULAR( \
197 BodyNodeType, NodeName, PluralName) \
198 DETAIL_DART_SPECIALIZED_NODE_DEFINE( \
199 BodyNodeType, NodeName, PluralName, m##PluralName##Iterator)
202 #define DART_SPECIALIZED_NODE_DEFINE(BodyNodeType, NodeName) \
203 DART_SPECIALIZED_NODE_DEFINE_IRREGULAR(BodyNodeType, NodeName, NodeName##s)
206 #define DETAIL_DART_SPECIALIZED_NODE_TEMPLATE( \
207 BodyNodeType, NodeName, PluralName) \
209 inline std::size_t BodyNodeType ::getNumNodes<NodeName>() const \
211 return getNum##PluralName(); \
214 inline NodeName* BodyNodeType ::getNode<NodeName>(std::size_t index) \
216 return get##NodeName(index); \
219 inline const NodeName* BodyNodeType ::getNode<NodeName>(std::size_t index) \
222 return get##NodeName(index); \
226 #define DART_SPECIALIZED_NODE_TEMPLATE_IRREGULAR( \
227 BodyNodeType, NodeName, PluralName) \
228 DETAIL_DART_SPECIALIZED_NODE_TEMPLATE(BodyNodeType, NodeName, PluralName)
231 #define DART_SPECIALIZED_NODE_TEMPLATE(BodyNodeType, NodeName) \
232 DART_SPECIALIZED_NODE_TEMPLATE_IRREGULAR(BodyNodeType, NodeName, NodeName##s)
237 #define DART_SKEL_ENABLE_NODE_SPECIALIZATION() \
240 std::size_t getNumNodes() const \
242 return dart::dynamics::Skeleton::getNumNodes<T>(); \
245 std::size_t getNumNodes(std::size_t treeIndex) const \
247 return dart::dynamics::Skeleton::getNumNodes<T>(treeIndex); \
250 T* getNode(std::size_t index) \
252 return dart::dynamics::Skeleton::getNode<T>(index); \
255 T* getNode(std::size_t nodeIdx, std::size_t treeIndex) \
257 return dart::dynamics::Skeleton::getNode<T>(nodeIdx, treeIndex); \
260 const T* getNode(std::size_t index) const \
262 return dart::dynamics::Skeleton::getNode<T>(index); \
265 const T* getNode(std::size_t nodeIdx, std::size_t treeIndex) const \
267 return dart::dynamics::Skeleton::getNode<T>(nodeIdx, treeIndex); \
270 T* getNode(const std::string& name) \
272 return dart::dynamics::Skeleton::getNode<T>(name); \
275 const T* getNode(const std::string& name) const \
277 return dart::dynamics::Skeleton::getNode<T>(name); \
281 #define DART_SKEL_INSTANTIATE_SPECIALIZED_NODE_IRREGULAR(NodeName, PluralName) \
282 mSpecializedTreeNodes[typeid(NodeName)] = &mTree##PluralName##Iterators; \
283 mSkelCache.mNodeMap[typeid(NodeName)] \
284 = std::vector<dart::dynamics::Node*>(); \
285 m##PluralName##Iterator = mSkelCache.mNodeMap.find(typeid(NodeName)); \
286 mNodeNameMgrMap[typeid(NodeName)] = dart::common::NameManager<Node*>( \
287 std::string("Skeleton::") + #NodeName + " | " \
288 + mAspectProperties.mName); \
289 mNameMgrFor##PluralName = &mNodeNameMgrMap.find(typeid(NodeName))->second;
292 #define DART_SKEL_INSTANTIATE_SPECIALIZED_NODE(NodeName) \
293 DART_SKEL_INSTANTIATE_SPECIALIZED_NODE_IRREGULAR(NodeName, NodeName##s);
296 #define DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, func) \
297 if (treeIndex >= treeIts.size()) \
299 dterr << "[" << #func << "] Requesting an invalid tree (" << treeIndex \
301 << "The number of trees in this Skeleton is: " << treeIts.size() \
308 #define DETAIL_DART_SKEL_SPECIALIZED_NODE_INLINE( \
309 NodeName, PluralName, skelIt, treeIts, NameMgr) \
311 dart::dynamics::Skeleton::NodeMap::iterator skelIt; \
312 std::vector<dart::dynamics::Skeleton::NodeMap::iterator> treeIts; \
313 dart::common::NameManager<dart::dynamics::Node*>* NameMgr; \
316 inline std::size_t getNum##PluralName() const \
318 return skelIt->second.size(); \
320 inline std::size_t getNum##PluralName(std::size_t treeIndex) const \
322 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, getNum##PluralName); \
323 treeIts[treeIndex]->second.size(); \
326 inline NodeName* get##NodeName(std::size_t index) \
328 return static_cast<NodeName*>( \
329 getVectorObjectIfAvailable(index, skelIt->second)); \
331 inline NodeName* get##NodeName(std::size_t treeIndex, std::size_t nodeIndex) \
333 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, get##NodeName); \
334 return static_cast<NodeName*>( \
335 getVectorObjectIfAvailable(nodeIndex, treeIts[treeIndex]->second)); \
338 inline const NodeName* get##NodeName(std::size_t index) const \
340 return static_cast<const NodeName*>( \
341 getVectorObjectIfAvailable(index, skelIt->second)); \
343 inline const NodeName* get##NodeName( \
344 std::size_t treeIndex, std::size_t nodeIndex) const \
346 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, get##NodeName); \
347 return static_cast<const NodeName*>( \
348 getVectorObjectIfAvailable(nodeIndex, treeIts[treeIndex]->second)); \
351 inline NodeName* get##NodeName(const std::string& name) \
353 return static_cast<NodeName*>(NameMgr->getObject(name)); \
355 inline const NodeName* get##NodeName(const std::string& name) const \
357 return static_cast<const NodeName*>(NameMgr->getObject(name)); \
361 #define DART_SKEL_SPECIALIZED_NODE_INLINE_IRREGULAR(NodeName, PluralName) \
362 DETAIL_DART_SKEL_SPECIALIZED_NODE_INLINE( \
365 m##PluralName##Iterator, \
366 mTree##PluralName##Iterators, \
367 mNameMgrFor##PluralName);
370 #define DART_SKEL_SPECIALIZED_NODE_INLINE(NodeName) \
371 DART_SKEL_SPECIALIZED_NODE_INLINE_IRREGULAR(NodeName, NodeName##s);
374 #define DETAIL_DART_SKEL_SPECIALIZED_NODE_DECLARE( \
375 NodeName, PluralName, skelIt, treeIts, NameMgr) \
377 dart::dynamics::Skeleton::NodeMap::iterator skelIt; \
378 std::vector<dart::dynamics::Skeleton::NodeMap::iterator> treeIts; \
379 dart::common::NameManager<dart::dynamics::Node*>* NameMgr; \
382 std::size_t getNum##PluralName() const; \
384 std::size_t getNum##PluralName(std::size_t treeIndex) const; \
386 NodeName* get##NodeName(std::size_t index); \
388 NodeName* get##NodeName(std::size_t treeIndex, std::size_t nodeIndex); \
390 const NodeName* get##NodeName(std::size_t index) const; \
392 const NodeName* get##NodeName(std::size_t treeIndex, std::size_t nodeIndex) \
395 NodeName* get##NodeName(const std::string& name); \
397 const NodeName* get##NodeName(const std::string& name) const;
400 #define DART_SKEL_SPECIALIZED_NODE_DECLARE_IRREGULAR(NodeName, PluralName) \
401 DETAIL_DART_SKEL_SPECIALIZED_NODE_DECLARE( \
404 m##PluralName##Iterator, \
405 mTree##PluralName##Iterators, \
406 mNameMgrFor##PluralName);
409 #define DART_SKEL_SPECIALIZED_NODE_DECLARE(NodeName) \
410 DART_SKEL_SPECIALIZED_NODE_DECLARE_IRREGULAR(NodeName, NodeName##s);
413 #define DETAIL_DART_SKEL_SPECIALIZED_NODE_DEFINE( \
414 SkeletonType, NodeName, PluralName, skelIt, treeIts, NameMgr) \
415 std::size_t SkeletonType ::getNum##PluralName() const \
417 return skelIt->second.size(); \
419 std::size_t SkeletonType ::getNum##PluralName(std::size_t treeIndex) const \
421 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, getNum##PluralName); \
422 return treeIts[treeIndex]->second.size(); \
425 NodeName* SkeletonType ::get##NodeName(std::size_t index) \
427 return static_cast<NodeName*>( \
428 getVectorObjectIfAvailable(index, skelIt->second)); \
430 NodeName* SkeletonType ::get##NodeName( \
431 std::size_t treeIndex, std::size_t nodeIndex) \
433 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, get##NodeName); \
434 return static_cast<NodeName*>( \
435 getVectorObjectIfAvailable(nodeIndex, treeIts[treeIndex]->second)); \
438 const NodeName* SkeletonType ::get##NodeName(std::size_t index) const \
440 return static_cast<const NodeName*>( \
441 getVectorObjectIfAvailable(index, skelIt->second)); \
443 const NodeName* SkeletonType ::get##NodeName( \
444 std::size_t treeIndex, std::size_t nodeIndex) const \
446 DETAIL_DART_WARN_TREE_INDEX(treeIts, treeIndex, get##NodeName); \
447 return static_cast<const NodeName*>( \
448 getVectorObjectIfAvailable(nodeIndex, treeIts[treeIndex]->second)); \
451 NodeName* SkeletonType ::get##NodeName(const std::string& name) \
453 return static_cast<NodeName*>(NameMgr->getObject(name)); \
455 const NodeName* SkeletonType ::get##NodeName(const std::string& name) const \
457 return static_cast<const NodeName*>(NameMgr->getObject(name)); \
461 #define DART_SKEL_SPECIALIZED_NODE_DEFINED_IRREGULAR( \
462 SkeletonType, NodeName, PluralName) \
463 DETAIL_DART_SKEL_SPECIALIZED_NODE_DEFINE( \
467 m##PluralName##Iterator, \
468 mTree##PluralName##Iterators, \
469 mNameMgrFor##PluralName);
472 #define DART_SKEL_SPECIALIZED_NODE_DEFINE(SkeletonType, NodeName) \
473 DART_SKEL_SPECIALIZED_NODE_DEFINED_IRREGULAR( \
474 SkeletonType, NodeName, NodeName##s);
477 #define DETAIL_DART_SKEL_SPECIALIZED_NODE_TEMPLATE( \
478 SkelType, NodeName, PluralName) \
480 inline std::size_t SkelType ::getNumNodes<NodeName>() const \
482 return getNum##PluralName(); \
485 inline std::size_t SkelType ::getNumNodes<NodeName>(std::size_t index) const \
487 return getNum##PluralName(index); \
490 inline NodeName* SkelType ::getNode<NodeName>(std::size_t index) \
492 return get##NodeName(index); \
495 inline NodeName* SkelType ::getNode<NodeName>( \
496 std::size_t treeIndex, std::size_t nodeIndex) \
498 return get##NodeName(treeIndex, nodeIndex); \
501 inline const NodeName* SkelType ::getNode<NodeName>(std::size_t index) const \
503 return get##NodeName(index); \
506 inline const NodeName* SkelType ::getNode<NodeName>( \
507 std::size_t treeIndex, std::size_t nodeIndex) const \
509 return get##NodeName(treeIndex, nodeIndex); \
512 inline NodeName* SkelType::getNode<NodeName>(const std::string& name) \
514 return get##NodeName(name); \
517 inline const NodeName* SkelType::getNode<NodeName>(const std::string& name) \
520 return get##NodeName(name); \
524 #define DART_SKEL_SPECIALIZED_NODE_TEMPLATE_IRREGULAR( \
525 SkelType, NodeName, PluralName) \
526 DETAIL_DART_SKEL_SPECIALIZED_NODE_TEMPLATE(SkelType, NodeName, PluralName)
529 #define DART_SKEL_SPECIALIZED_NODE_TEMPLATE(SkelType, NodeName) \
530 DART_SKEL_SPECIALIZED_NODE_TEMPLATE_IRREGULAR( \
531 SkelType, NodeName, NodeName##s);
std::size_t getTreeIndex() const
Get the index of this Node's tree within its Skeleton.
Definition: Node.hpp:68
std::size_t getIndexInBodyNode() const
Get the index of this Node within its BodyNode.
Definition: Node.hpp:47
std::size_t getIndexInSkeleton() const
Get the index of this Node within its Skeleton.
Definition: Node.hpp:54
void remove()
Stage the Node for removal.
Definition: Node.hpp:75
void reattach()
Undo the effectos of calling remove().
Definition: Node.hpp:82
std::size_t getIndexInTree() const
Get the index of this Node within its tree.
Definition: Node.hpp:61
Definition: BulletCollisionDetector.cpp:65