CloneTreeCreator.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "CloneTreeCreator.hpp"
  2. #include <cstdio>
  3. namespace btInverseDynamics {
  4. #define CHECK_NULLPTR() \
  5. do { \
  6. if (m_reference == 0x0) { \
  7. error_message("m_reference == 0x0\n"); \
  8. return -1; \
  9. } \
  10. } while (0)
  11. #define TRY(x) \
  12. do { \
  13. if (x == -1) { \
  14. error_message("error calling " #x "\n"); \
  15. return -1; \
  16. } \
  17. } while (0)
  18. CloneTreeCreator::CloneTreeCreator(const MultiBodyTree* reference) { m_reference = reference; }
  19. CloneTreeCreator::~CloneTreeCreator() {}
  20. int CloneTreeCreator::getNumBodies(int* num_bodies) const {
  21. CHECK_NULLPTR();
  22. *num_bodies = m_reference->numBodies();
  23. return 0;
  24. }
  25. int CloneTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
  26. vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
  27. vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
  28. mat33* body_I_body, int* user_int, void** user_ptr) const {
  29. CHECK_NULLPTR();
  30. TRY(m_reference->getParentIndex(body_index, parent_index));
  31. TRY(m_reference->getJointType(body_index, joint_type));
  32. TRY(m_reference->getParentRParentBodyRef(body_index, parent_r_parent_body_ref));
  33. TRY(m_reference->getBodyTParentRef(body_index, body_T_parent_ref));
  34. TRY(m_reference->getBodyAxisOfMotion(body_index, body_axis_of_motion));
  35. TRY(m_reference->getBodyMass(body_index, mass));
  36. TRY(m_reference->getBodyFirstMassMoment(body_index, body_r_body_com));
  37. TRY(m_reference->getBodySecondMassMoment(body_index, body_I_body));
  38. TRY(m_reference->getUserInt(body_index, user_int));
  39. TRY(m_reference->getUserPtr(body_index, user_ptr));
  40. return 0;
  41. }
  42. }