pinocchio  2.7.1
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
geometry.hpp
1 //
2 // Copyright (c) 2021 INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_pool_geometry_hpp__
6 #define __pinocchio_multibody_pool_geometry_hpp__
7 
8 #include "pinocchio/multibody/geometry.hpp"
9 #include "pinocchio/multibody/pool/model.hpp"
10 
11 #include "pinocchio/utils/openmp.hpp"
12 
13 namespace pinocchio
14 {
15  template<typename _Scalar, int _Options, template<typename,int> class JointCollectionTpl>
17  : public ModelPoolTpl<_Scalar,_Options,JointCollectionTpl>
18  {
19  public:
20 
21  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22 
24  typedef _Scalar Scalar;
25  enum { Options = _Options };
26 
27  typedef typename Base::Model Model;
28  typedef typename Base::Data Data;
29  typedef typename Base::DataVector DataVector;
30  typedef ::pinocchio::GeometryModel GeometryModel;
31  typedef ::pinocchio::GeometryData GeometryData;
32 
33  typedef std::vector<GeometryModel,Eigen::aligned_allocator<GeometryModel> > GeometryModelVector;
34  typedef std::vector<GeometryData,Eigen::aligned_allocator<GeometryData> > GeometryDataVector;
35 
43  const int pool_size = omp_get_max_threads())
44  : Base(model,pool_size)
46  , m_geometry_datas((size_t)pool_size,GeometryData(geometry_model))
47  {}
48 
54  : Base(other)
57  {}
58 
60  const GeometryModel & geometry_model() const { return m_geometry_model; }
61 
64 
66  const GeometryData & geometry_data(const size_t index) const
67  {
68  PINOCCHIO_CHECK_INPUT_ARGUMENT(index < m_geometry_datas.size(),
69  "Index greater than the size of the geometry_datas vector.");
70  return m_geometry_datas[index];
71  }
72 
74  GeometryData & geometry_data(const size_t index)
75  {
76  PINOCCHIO_CHECK_INPUT_ARGUMENT(index < m_geometry_datas.size(),
77  "Index greater than the size of the geometry_datas vector.");
78  return m_geometry_datas[index];
79  }
80 
82  const GeometryDataVector & geometry_datas() const { return m_geometry_datas; }
83 
85  GeometryDataVector & geometry_datas() { return m_geometry_datas; }
86 
87  using Base::update;
88  using Base::size;
89  using Base::model;
90  using Base::datas;
91 
98  {
99  std::fill(m_geometry_datas.begin(),m_geometry_datas.end(),geometry_data);
100  }
101 
109  {
111  std::fill(m_geometry_datas.begin(),m_geometry_datas.end(),
113  }
114 
123  const GeometryData & geometry_data)
124  {
127  }
128 
130  virtual ~GeometryPoolTpl() {};
131 
132  protected:
133 
136 
138  GeometryDataVector m_geometry_datas;
139 
141  virtual void do_resize(const int new_size)
142  {
143  m_geometry_datas.resize((size_t)new_size);
144  if(size() < new_size)
145  {
146  typename GeometryDataVector::iterator it = m_geometry_datas.begin();
147  std::advance(it, (long)(new_size - size()));
148  std::fill(it,m_geometry_datas.end(),m_geometry_datas[0]);
149  }
150  }
151 
152  };
153 
154  typedef GeometryPoolTpl<double,0,JointCollectionDefaultTpl> GeometryPool;
155 }
156 
157 #endif // ifndef __pinocchio_multibody_pool_geometry_hpp__
pinocchio::GeometryPoolTpl::do_resize
virtual void do_resize(const int new_size)
&#160;
Definition: geometry.hpp:141
pinocchio::DataTpl
Definition: data.hpp:29
pinocchio::ModelPoolTpl::size
int size() const
Returns the size of the pool.
Definition: model.hpp:96
pinocchio::GeometryPoolTpl::geometry_datas
GeometryDataVector & geometry_datas()
Vector of Geometry Data.
Definition: geometry.hpp:85
pinocchio::ModelPoolTpl::model
const Model & model() const
Returns the model stored within the pool.
Definition: model.hpp:57
pinocchio::GeometryPoolTpl::~GeometryPoolTpl
virtual ~GeometryPoolTpl()
&#160;
Definition: geometry.hpp:130
pinocchio::GeometryPoolTpl::m_geometry_datas
GeometryDataVector m_geometry_datas
Vector of Geometry Data associated to the pool.
Definition: geometry.hpp:138
pinocchio::GeometryPoolTpl::GeometryPoolTpl
GeometryPoolTpl(const Model &model, const GeometryModel &geometry_model, const int pool_size=omp_get_max_threads())
Default constructor from a model and a pool size.
Definition: geometry.hpp:42
pinocchio::GeometryPoolTpl::geometry_datas
const GeometryDataVector & geometry_datas() const
Vector of Geometry Data.
Definition: geometry.hpp:82
pinocchio::GeometryPoolTpl::geometry_data
GeometryData & geometry_data(const size_t index)
Returns the geometry_data at index.
Definition: geometry.hpp:74
pinocchio::GeometryData
Definition: geometry.hpp:187
pinocchio::GeometryPoolTpl::m_geometry_model
GeometryModel m_geometry_model
Geometry Model associated to the pool.
Definition: geometry.hpp:130
pinocchio::ModelPoolTpl::update
void update(const Model &model)
Update the model, meaning that all the datas will be refreshed accordingly.
Definition: model.hpp:66
pinocchio::GeometryPoolTpl::update
void update(const GeometryModel &geometry_model, const GeometryData &geometry_data)
Update the geometry model and data with the new input values. In this case, all the geometry_datas wi...
Definition: geometry.hpp:122
pinocchio::ModelPoolTpl
Definition: model.hpp:19
pinocchio::GeometryPoolTpl::geometry_model
const GeometryModel & geometry_model() const
Returns the geometry model.
Definition: geometry.hpp:60
pinocchio::GeometryPoolTpl::geometry_model
GeometryModel & geometry_model()
Returns the geometry model.
Definition: geometry.hpp:63
pinocchio::GeometryPoolTpl::update
void update(const GeometryModel &geometry_model)
Update the geometry model with the new input value. In this case, all the geometry_datas will be repl...
Definition: geometry.hpp:108
pinocchio::GeometryPoolTpl::geometry_data
const GeometryData & geometry_data(const size_t index) const
Returns the geometry_data at index.
Definition: geometry.hpp:66
pinocchio::GeometryModel
Definition: geometry.hpp:22
pinocchio::GeometryPoolTpl::GeometryPoolTpl
GeometryPoolTpl(const GeometryPoolTpl &other)
Copy constructor from an other GeometryPoolTpl.
Definition: geometry.hpp:53
pinocchio::ModelTpl< Scalar, Options, JointCollectionTpl >
pinocchio::ModelPoolTpl::datas
const DataVector & datas() const
Returns the data vectors.
Definition: model.hpp:113
pinocchio::GeometryPoolTpl
Definition: geometry.hpp:16
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:11
pinocchio::GeometryPoolTpl::update
void update(const GeometryData &geometry_data)
Update the geometry datas with the new value.
Definition: geometry.hpp:97