Biorbd
Release_1.13.0
Toggle main menu visibility
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
10
using namespace
BIORBD_NAMESPACE;
11
12
internal_forces::PathModifiers::PathModifiers
()
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
18
internal_forces::PathModifiers
internal_forces::PathModifiers::DeepCopy
()
19
const
{
20
internal_forces::PathModifiers
copy;
21
copy.
DeepCopy
(*
this
);
22
return
copy;
23
}
24
25
void
internal_forces::PathModifiers::DeepCopy
(
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
;
34
*
m_totalObjects
= *other.
m_totalObjects
;
35
}
36
37
// Private method to assing values
38
void
internal_forces::PathModifiers::addPathChanger
(
utils::Vector3d
&
object
) {
39
// Add a muscle to the pool of muscle depending on type
40
if
(
object
.typeOfNode() == utils::NODE_TYPE::WRAPPING_SPHERE) {
41
utils::Error::check
(
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) {
48
utils::Error::check
(
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) {
55
utils::Error::check
(
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
}
64
++*
m_totalObjects
;
65
}
66
67
size_t
internal_forces::PathModifiers::nbWraps
()
const
{
return
*
m_nbWraps
; }
68
69
size_t
internal_forces::PathModifiers::nbVia
()
const
{
return
*
m_nbVia
; }
70
71
size_t
internal_forces::PathModifiers::nbObjects
()
const
{
72
return
*
m_totalObjects
;
73
}
74
75
utils::Vector3d
&
internal_forces::PathModifiers::object
(
size_t
idx) {
76
utils::Error::check
(
77
idx <
nbObjects
(),
"Idx asked is higher than number of wrapping objects"
);
78
return
*(*m_obj)[idx];
79
}
80
81
const
utils::Vector3d
&
internal_forces::PathModifiers::object
(
82
size_t
idx)
const
{
83
utils::Error::check
(
84
idx <
nbObjects
(),
"Idx asked is higher than number of wrapping objects"
);
85
return
*(*m_obj)[idx];
86
}
BIORBD_NAMESPACE::internal_forces::PathModifiers
Holder of all the path modifiers of a muscle.
Definition
PathModifiers.h:18
BIORBD_NAMESPACE::internal_forces::PathModifiers::nbVia
size_t nbVia() const
Return the total number of via points in the set.
Definition
PathModifiers.cpp:69
BIORBD_NAMESPACE::internal_forces::PathModifiers::DeepCopy
PathModifiers DeepCopy() const
Deep copy of path changers.
Definition
PathModifiers.cpp:18
BIORBD_NAMESPACE::internal_forces::PathModifiers::m_nbWraps
std::shared_ptr< size_t > m_nbWraps
Number of wrapping object in the set.
Definition
PathModifiers.h:79
BIORBD_NAMESPACE::internal_forces::PathModifiers::nbWraps
size_t nbWraps() const
Return the total number of wrapping objects in the set.
Definition
PathModifiers.cpp:67
BIORBD_NAMESPACE::internal_forces::PathModifiers::nbObjects
size_t nbObjects() const
Return the total number of path modifier objects in the set.
Definition
PathModifiers.cpp:71
BIORBD_NAMESPACE::internal_forces::PathModifiers::PathModifiers
PathModifiers()
Construct path changers.
Definition
PathModifiers.cpp:12
BIORBD_NAMESPACE::internal_forces::PathModifiers::object
utils::Vector3d & object(size_t idx)
Return the object at a specific index in the set.
Definition
PathModifiers.cpp:75
BIORBD_NAMESPACE::internal_forces::PathModifiers::m_nbVia
std::shared_ptr< size_t > m_nbVia
Number of via points in the set.
Definition
PathModifiers.h:80
BIORBD_NAMESPACE::internal_forces::PathModifiers::m_totalObjects
std::shared_ptr< size_t > m_totalObjects
Number of total objects in the set.
Definition
PathModifiers.h:82
BIORBD_NAMESPACE::internal_forces::PathModifiers::addPathChanger
void addPathChanger(utils::Vector3d &object)
Add a wrapping or a via point to the set of path modifiers.
Definition
PathModifiers.cpp:38
BIORBD_NAMESPACE::internal_forces::PathModifiers::m_obj
std::shared_ptr< std::vector< std::shared_ptr< utils::Vector3d > > > m_obj
set of objects
Definition
PathModifiers.h:78
BIORBD_NAMESPACE::internal_forces::ViaPoint
Via point of a muscle.
Definition
ViaPoint.h:17
BIORBD_NAMESPACE::internal_forces::WrappingHalfCylinder
Half cylinder of infinite length (the length only affect the graphical representation) object that ma...
Definition
WrappingHalfCylinder.h:18
BIORBD_NAMESPACE::internal_forces::WrappingSphere
Sphere object that makes the muscle to wrap around.
Definition
WrappingSphere.h:13
BIORBD_NAMESPACE::utils::Error::raise
static void raise(const String &message)
Throw an error message.
Definition
Error.cpp:6
BIORBD_NAMESPACE::utils::Error::check
static void check(bool cond, const String &message)
Assert that raises the error message if false.
Definition
Error.cpp:10
BIORBD_NAMESPACE::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition
Vector3d.h:27
src
InternalForces
PathModifiers.cpp
Generated by
1.18.0