5 #ifndef CNOID_UTIL_EIGEN_ARCHIVE_H 6 #define CNOID_UTIL_EIGEN_ARCHIVE_H 11 #include <boost/function.hpp> 12 #include <boost/format.hpp> 16 template<
typename Derived>
17 void read(
const Listing& listing, Eigen::MatrixBase<Derived>& x)
19 const int nr = x.rows();
20 const int nc = x.cols();
21 if(listing.
size() != nr * nc){
23 str(boost::format(
"A %1% x %2% matrix / vector value is expected") % nr % nc));
26 for(
int i=0; i < nr; ++i){
27 for(
int j=0; j < nc; ++j){
28 x(i, j) = listing[index++].
toDouble();
34 template<
typename Derived>
35 bool read(
const Mapping& mapping,
const std::string& key, Eigen::MatrixBase<Derived>& x)
46 template<
typename Scalar,
int Dim,
int Mode>
47 bool read(
const Mapping& mapping,
const std::string& key, Eigen::Transform<Scalar, Dim, Mode>& T)
49 return read(mapping, key, T.matrix());
53 template<
typename Derived>
54 void readEx(
const Mapping& mapping,
const std::string& key, Eigen::MatrixBase<Derived>& x)
56 if(!
read(mapping, key, x)){
61 template<
typename Derived>
66 const int nr = x.rows();
67 const int nc = x.cols();
69 for(
int i=0; i < nr; ++i){
73 for(
int i=0; i < nr; ++i){
75 for(
int j=0; j < nc; ++j){
84 template<
typename Scalar,
int Dim,
int Mode>
85 Listing&
write(
Mapping& mapping,
const std::string& key,
const Eigen::Transform<Scalar, Dim, Mode>& T)
87 return write(mapping, key, T.matrix());
120 template<
typename Scalar>
121 bool read(
const Mapping& mapping,
const std::string& key, Eigen::AngleAxis<Scalar>& r)
132 template<
typename Scalar>
144 inline bool read(
const Mapping& mapping,
const std::string& key, boost::function<
void(
Vector3&)> setterFunc)
147 if(
read(mapping, key, x)){
bool isValid() const
Definition: ValueTree.h:51
Definition: ValueTree.h:224
void append(ValueNode *node)
Definition: ValueTree.h:484
Listing * findListing(const std::string &key) const
Definition: ValueTree.cpp:545
double toDouble() const
Definition: ValueTree.cpp:200
Listing & write(Mapping &mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:62
void throwException(const std::string &message) const
Definition: ValueTree.cpp:412
int size() const
Definition: ValueTree.h:440
std::string str(const Vector3 &v)
Definition: EigenUtil.cpp:90
Definition: ValueTree.h:424
Listing * createFlowStyleListing(const std::string &key)
Definition: ValueTree.h:295
void read(const Listing &listing, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:17
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
void throwKeyNotFoundException(const std::string &key) const
Definition: ValueTree.cpp:590
Eigen::Vector3d Vector3
Definition: EigenTypes.h:58
void setDoubleFormat(const char *format)
Definition: ValueTree.cpp:930
void appendLF()
Definition: ValueTree.cpp:948
void readEx(const Mapping &mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:54