pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
broadphase-manager.hpp
1//
2// Copyright (c) 2022 INRIA
3//
4
5#ifndef __pinocchio_collision_pool_broadphase_manager_hpp__
6#define __pinocchio_collision_pool_broadphase_manager_hpp__
7
8#include <omp.h>
9
10#include "pinocchio/multibody/pool/geometry.hpp"
11#include "pinocchio/collision/broadphase-manager.hpp"
12
13namespace pinocchio
14{
15
16 template<
17 typename _BroadPhaseManagerDerived,
18 typename _Scalar,
19 int _Options,
20 template<typename, int> class JointCollectionTpl>
21 class BroadPhaseManagerPoolBase : public GeometryPoolTpl<_Scalar, _Options, JointCollectionTpl>
22 {
23 public:
25
28 typedef _Scalar Scalar;
29 enum
30 {
31 Options = _Options
32 };
33
34 typedef typename Base::Model Model;
35 typedef typename Base::Data Data;
36 typedef typename Base::DataVector DataVector;
37 typedef typename Base::GeometryModel GeometryModel;
38 typedef typename Base::GeometryData GeometryData;
39
40 // typedef std::vector<BroadPhaseManager,Eigen::aligned_allocator<BroadPhaseManager> >
41 // BroadPhaseManagerVector;
42
43 typedef std::vector<BroadPhaseManager> BroadPhaseManagerVector;
44
52 const Model & model,
54 const size_t pool_size = (size_t)omp_get_max_threads())
56 {
57 init();
58 }
59
69
71 const BroadPhaseManager & getBroadPhaseManager(const size_t index) const
72 {
73 PINOCCHIO_CHECK_INPUT_ARGUMENT(
74 index < m_managers.size(), "Index greater than the size of the manager vector.");
75 return m_managers[index];
76 }
77
80 {
81 PINOCCHIO_CHECK_INPUT_ARGUMENT(
82 index < m_managers.size(), "Index greater than the size of the manager vector.");
83 return m_managers[index];
84 }
85
87 const BroadPhaseManagerVector & getBroadPhaseManagers() const
88 {
89 return m_managers;
90 }
91
93 BroadPhaseManagerVector & getBroadPhaseManagers()
94 {
95 return m_managers;
96 }
97
98 using Base::getData;
99 using Base::getDatas;
104 using Base::getModel;
105 using Base::getModels;
106 using Base::size;
107 using Base::update;
108
114 virtual void update(const GeometryData & geometry_data)
115 {
117
118 for (size_t i = 0; i < size(); ++i)
119 {
120 m_managers[i].update(&getGeometryData(i));
121 }
122 }
123
125 bool check() const
126 {
127 for (size_t i = 0; i < size(); ++i)
128 {
129 const BroadPhaseManager & manager = m_managers[i];
130 bool res = true;
131 res &= (&manager.getModel() == &getModel(i));
132 res &= (&manager.getGeometryData() == &getGeometryData(i));
133
134 res &= (&manager.getGeometryModel() == &getGeometryModel(i));
135 res &= manager.check();
136
137 if (!res)
138 return false;
139 }
140
141 return true;
142 }
143
146
147 protected:
148 void init()
149 {
150 m_managers.reserve(size());
151 for (size_t i = 0; i < size(); ++i)
152 {
153 m_managers.push_back(
154 BroadPhaseManager(&getModel(i), &getGeometryModel(i), &getGeometryData(i)));
155 }
156 }
157
159 BroadPhaseManagerVector m_managers;
160
162 virtual void doResize(const size_t new_size)
163 {
164 m_managers.resize(new_size);
165 if (size() < new_size)
166 {
167 typename BroadPhaseManagerVector::iterator it = m_managers.begin();
168 std::advance(it, (long)(new_size - size()));
169 std::fill(it, m_managers.end(), m_managers[0]);
170 }
171 }
172 };
173} // namespace pinocchio
174
175#endif // ifndef __pinocchio_collision_pool_broadphase_manager_hpp__
const GeometryModel & getGeometryModel(const size_t index) const
Returns the geometry_model at given index.
Definition geometry.hpp:81
virtual void update(const GeometryData &geometry_data)
Update the geometry datas with the new value.
BroadPhaseManagerVector & getBroadPhaseManagers()
Access to the vector of broad phase managers.
bool check() const
Check the validity of the current broadphase.
const BroadPhaseManager & getBroadPhaseManager(const size_t index) const
Returns the geometry_data at index.
BroadPhaseManager & getBroadPhaseManager(const size_t index)
Returns the geometry_data at index.
BroadPhaseManagerPoolBase(const Model &model, const GeometryModel &geometry_model, const size_t pool_size=(size_t) omp_get_max_threads())
Default constructor from a model and a pool size.
BroadPhaseManagerVector m_managers
Broad phase managers associated to the pool.
BroadPhaseManagerPoolBase(const BroadPhaseManagerPoolBase &other)
Copy constructor from an other BroadPhaseManagerPoolTpl.
virtual void doResize(const size_t new_size)
&#160;
const BroadPhaseManagerVector & getBroadPhaseManagers() const
Access to the vector of broad phase managers.
const GeometryData & getGeometryData(const size_t index) const
Returns the geometry_data at given index.
Definition geometry.hpp:99
const GeometryModel & getGeometryModel(const size_t index) const
Returns the geometry_model at given index.
Definition geometry.hpp:81
size_t size() const
Returns the size of the pool.
Definition model.hpp:68
virtual void update(const GeometryData &geometry_data_to_copy)
Update the geometry datas with the new value.
Definition geometry.hpp:164
const GeometryModelVector & getGeometryModels() const
Returns the vector of Geometry Model.
Definition geometry.hpp:129
const GeometryDataVector & getGeometryDatas() const
Returns the vector of Geometry Data.
Definition geometry.hpp:117
const GeometryData & getGeometryData(const size_t index) const
Returns the geometry_data at given index.
Definition geometry.hpp:99
const Model & getModel(const size_t index) const
Return a specific model.
Definition model.hpp:107
const DataVector & getDatas() const
Returns the data vector.
Definition model.hpp:123
const ModelVector & getModels() const
Returns the vector of models.
Definition model.hpp:95
const Data & getData(const size_t index) const
Return a specific data.
Definition model.hpp:135
Main pinocchio namespace.
Definition treeview.dox:11