| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/* |
| 2 |
|
|
Code adapted from: |
| 3 |
|
|
https://gist.githubusercontent.com/mtao/5798888/raw/5be9fa9b66336c166dba3a92c0e5b69ffdb81501/eigen_boost_serialization.hpp |
| 4 |
|
|
Copyright (c) 2015 Michael Tao |
| 5 |
|
|
|
| 6 |
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
|
|
of this software and associated documentation files (the "Software"), to deal |
| 8 |
|
|
in the Software without restriction, including without limitation the rights |
| 9 |
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
|
|
copies of the Software, and to permit persons to whom the Software is |
| 11 |
|
|
furnished to do so, subject to the following conditions: |
| 12 |
|
|
|
| 13 |
|
|
The above copyright notice and this permission notice shall be included in |
| 14 |
|
|
all copies or substantial portions of the Software. |
| 15 |
|
|
|
| 16 |
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 |
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 |
|
|
THE SOFTWARE. |
| 23 |
|
|
*/ |
| 24 |
|
|
|
| 25 |
|
|
#ifndef __parameteric_curves_serialization_eigen_matrix_hpp__ |
| 26 |
|
|
#define __parameteric_curves_serialization_eigen_matrix_hpp__ |
| 27 |
|
|
|
| 28 |
|
|
#include <Eigen/Dense> |
| 29 |
|
|
#include <boost/serialization/split_free.hpp> |
| 30 |
|
|
#include <boost/serialization/vector.hpp> |
| 31 |
|
|
|
| 32 |
|
|
namespace boost { |
| 33 |
|
|
|
| 34 |
|
|
namespace serialization { |
| 35 |
|
|
|
| 36 |
|
|
template <class Archive, typename _Scalar, int _Rows, int _Cols, int _Options, |
| 37 |
|
|
int _MaxRows, int _MaxCols> |
| 38 |
|
✗ |
void save( |
| 39 |
|
|
Archive& ar, |
| 40 |
|
|
const Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m, |
| 41 |
|
|
const unsigned int /*version*/) { |
| 42 |
|
✗ |
Eigen::DenseIndex rows(m.rows()), cols(m.cols()); |
| 43 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(rows); |
| 44 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(cols); |
| 45 |
|
✗ |
ar& make_nvp("data", make_array(m.data(), (size_t)m.size())); |
| 46 |
|
|
} |
| 47 |
|
|
|
| 48 |
|
|
template <class Archive, typename _Scalar, int _Rows, int _Cols, int _Options, |
| 49 |
|
|
int _MaxRows, int _MaxCols> |
| 50 |
|
✗ |
void load(Archive& ar, |
| 51 |
|
|
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m, |
| 52 |
|
|
const unsigned int /*version*/) { |
| 53 |
|
|
Eigen::DenseIndex rows, cols; |
| 54 |
|
✗ |
ar >> BOOST_SERIALIZATION_NVP(rows); |
| 55 |
|
✗ |
ar >> BOOST_SERIALIZATION_NVP(cols); |
| 56 |
|
✗ |
m.resize(rows, cols); |
| 57 |
|
✗ |
ar >> make_nvp("data", make_array(m.data(), (size_t)m.size())); |
| 58 |
|
|
} |
| 59 |
|
|
|
| 60 |
|
|
template <class Archive, typename _Scalar, int _Rows, int _Cols, int _Options, |
| 61 |
|
|
int _MaxRows, int _MaxCols> |
| 62 |
|
✗ |
void serialize( |
| 63 |
|
|
Archive& ar, |
| 64 |
|
|
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m, |
| 65 |
|
|
const unsigned int version) { |
| 66 |
|
✗ |
split_free(ar, m, version); |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
} // namespace serialization |
| 70 |
|
|
} // namespace boost |
| 71 |
|
|
|
| 72 |
|
|
#endif // ifndef __parametric_curves_serialization_eigen_matrix_hpp__ |
| 73 |
|
|
|