pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
std-aligned-vector.hpp
1//
2// Copyright (c) 2016-2024 CNRS INRIA
3//
4
5#pragma once
6
7#include <boost/python.hpp>
8#include <string>
9
10#include <eigenpy/std-vector.hpp>
11
12#include "pinocchio/deprecated.hpp"
13#include "pinocchio/container/aligned-vector.hpp"
14#include "pinocchio/bindings/python/utils/pickle-vector.hpp"
15
16namespace pinocchio
17{
18 namespace python
19 {
20
30 template<class T, bool NoProxy = false, bool EnableFromPythonListConverter = true>
31 struct PINOCCHIO_DEPRECATED StdAlignedVectorPythonVisitor
32 : public ::boost::python::vector_indexing_suite<
33 typename container::aligned_vector<T>,
34 NoProxy,
35 eigenpy::internal::
36 contains_vector_derived_policies<typename container::aligned_vector<T>, NoProxy>>
37 , public eigenpy::StdContainerFromPythonList<container::aligned_vector<T>>
38 {
39 typedef container::aligned_vector<T> vector_type;
40 typedef eigenpy::StdContainerFromPythonList<vector_type, NoProxy> FromPythonListConverter;
41 typedef T value_type;
42
43 static void expose(const std::string & class_name, const std::string & doc_string = "")
44 {
45 expose(class_name, doc_string, eigenpy::EmptyPythonVisitor());
46 }
47
48 template<typename VisitorDerived>
49 static void expose(
50 const std::string & class_name, const boost::python::def_visitor<VisitorDerived> & visitor)
51 {
52 expose(class_name, "", visitor);
53 }
54
55 template<typename VisitorDerived>
56 static void expose(
57 const std::string & class_name,
58 const std::string & doc_string,
59 const boost::python::def_visitor<VisitorDerived> & visitor)
60 {
61 namespace bp = boost::python;
62 if (!eigenpy::register_symbolic_link_to_registered_type<vector_type>())
63 {
64 bp::class_<vector_type> cl(class_name.c_str(), doc_string.c_str());
66
67 .def(
68 bp::init<size_t, const value_type &>(
69 bp::args("self", "size", "value"),
70 "Constructor from a given size and a given value."))
71 .def(bp::init<const vector_type &>(bp::args("self", "other"), "Copy constructor"))
72
73 .def(
74 "tolist", &FromPythonListConverter::tolist,
75 (bp::arg("self"), bp::arg("deep_copy") = false),
76 "Returns the aligned_vector as a Python list.")
77 .def(visitor)
78#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
79 .def_pickle(PickleVector<vector_type>())
80#endif
81 .def(eigenpy::CopyableVisitor<vector_type>());
82
83 // Register conversion
84 if (EnableFromPythonListConverter)
85 FromPythonListConverter::register_converter();
86 }
87 }
88 };
89 } // namespace python
90} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11
Create a pickle interface for the std::vector and aligned vector.
Expose an container::aligned_vector from a type given as template argument.