Biorbd Release_1.13.0
Loading...
Searching...
No Matches
PathModifiers.cpp
1#define BIORBD_API_EXPORTS
2#include "InternalForces/PathModifiers.h"
3
4#include "InternalForces/ViaPoint.h"
5#include "InternalForces/WrappingHalfCylinder.h"
6#include "InternalForces/WrappingSphere.h"
7#include "Utils/Error.h"
8#include "Utils/Vector3d.h"
9
10using namespace BIORBD_NAMESPACE;
11
13 : m_obj(std::make_shared<std::vector<std::shared_ptr<utils::Vector3d>>>()),
14 m_nbWraps(std::make_shared<size_t>(0)),
15 m_nbVia(std::make_shared<size_t>(0)),
16 m_totalObjects(std::make_shared<size_t>(0)) {}
17
24
26 const internal_forces::PathModifiers& other) {
27 m_obj->resize(other.m_obj->size());
28 for (size_t i = 0; i < other.m_obj->size(); ++i) {
29 (*m_obj)[i] = std::make_shared<utils::Vector3d>();
30 *(*m_obj)[i] = (*other.m_obj)[i]->DeepCopy();
31 }
32 *m_nbWraps = *other.m_nbWraps;
33 *m_nbVia = *other.m_nbVia;
35}
36
37// Private method to assing values
39 // Add a muscle to the pool of muscle depending on type
40 if (object.typeOfNode() == utils::NODE_TYPE::WRAPPING_SPHERE) {
42 *m_nbVia == 0, "Cannot mix via points and wrapping objects yet");
43 m_obj->push_back(
44 std::make_shared<internal_forces::WrappingSphere>(
45 static_cast<internal_forces::WrappingSphere&>(object)));
46 ++*m_nbWraps;
47 } else if (object.typeOfNode() == utils::NODE_TYPE::WRAPPING_HALF_CYLINDER) {
49 *m_nbVia == 0, "Cannot mix via points and wrapping objects yet");
50 m_obj->push_back(
51 std::make_shared<internal_forces::WrappingHalfCylinder>(
52 dynamic_cast<internal_forces::WrappingHalfCylinder&>(object)));
53 ++*m_nbWraps;
54 } else if (object.typeOfNode() == utils::NODE_TYPE::VIA_POINT) {
56 *m_nbWraps == 0, "Cannot mix via points and wrapping objects yet");
57 m_obj->push_back(
58 std::make_shared<internal_forces::ViaPoint>(
59 dynamic_cast<internal_forces::ViaPoint&>(object)));
60 ++*m_nbVia;
61 } else {
62 utils::Error::raise("Wrapping type not found");
63 }
65}
66
68
70
74
77 idx < nbObjects(), "Idx asked is higher than number of wrapping objects");
78 return *(*m_obj)[idx];
79}
80
82 size_t idx) const {
84 idx < nbObjects(), "Idx asked is higher than number of wrapping objects");
85 return *(*m_obj)[idx];
86}
Holder of all the path modifiers of a muscle.
size_t nbVia() const
Return the total number of via points in the set.
PathModifiers DeepCopy() const
Deep copy of path changers.
std::shared_ptr< size_t > m_nbWraps
Number of wrapping object in the set.
size_t nbWraps() const
Return the total number of wrapping objects in the set.
size_t nbObjects() const
Return the total number of path modifier objects in the set.
utils::Vector3d & object(size_t idx)
Return the object at a specific index in the set.
std::shared_ptr< size_t > m_nbVia
Number of via points in the set.
std::shared_ptr< size_t > m_totalObjects
Number of total objects in the set.
void addPathChanger(utils::Vector3d &object)
Add a wrapping or a via point to the set of path modifiers.
std::shared_ptr< std::vector< std::shared_ptr< utils::Vector3d > > > m_obj
set of objects
Half cylinder of infinite length (the length only affect the graphical representation) object that ma...
Sphere object that makes the muscle to wrap around.
static void raise(const String &message)
Throw an error message.
Definition Error.cpp:6
static void check(bool cond, const String &message)
Assert that raises the error message if false.
Definition Error.cpp:10
Wrapper around Eigen Vector3d and attach it to a parent.
Definition Vector3d.h:27