ed
examples/custom_properties/pose_info.h
Go to the documentation of this file.
1 #ifndef ED_EXAMPLES_CUSTOM_PROPERTIES_PLUGIN_POSE_INFO_H_
2 #define ED_EXAMPLES_CUSTOM_PROPERTIES_PLUGIN_POSE_INFO_H_
3 
4 #include <ed/property_info.h>
5 
6 class PoseInfo : public ed::PropertyInfo
7 {
8 
9 public:
10 
11  void serialize(const ed::Variant& v, ed::io::Writer& w) const
12  {
13  const geo::Pose3D& p = v.getValue<geo::Pose3D>();
14 
15  w.writeGroup("pos");
16  w.writeValue("x", p.t.x);
17  w.writeValue("y", p.t.y);
18  w.writeValue("z", p.t.z);
19  w.endGroup();
20 
21  w.writeGroup("rot");
22  w.writeValue("xx", p.R.xx);
23  w.writeValue("xy", p.R.xy);
24  w.writeValue("xz", p.R.xz);
25  w.writeValue("yx", p.R.yx);
26  w.writeValue("yy", p.R.yy);
27  w.writeValue("yz", p.R.yz);
28  w.writeValue("zx", p.R.zx);
29  w.writeValue("zy", p.R.zy);
30  w.writeValue("zz", p.R.zz);
31  w.endGroup();
32  }
33 
35  {
37 
38  if (r.readGroup("pos"))
39  {
40  r.readValue("x", p.t.x);
41  r.readValue("y", p.t.y);
42  r.readValue("z", p.t.z);
43  r.endGroup();
44  }
45 
46  if (r.readGroup("rot"))
47  {
48  r.readValue("xx", p.R.xx);
49  r.readValue("xy", p.R.xy);
50  r.readValue("xz", p.R.xz);
51  r.readValue("yx", p.R.yx);
52  r.readValue("yy", p.R.yy);
53  r.readValue("yz", p.R.yz);
54  r.readValue("zx", p.R.zx);
55  r.readValue("zy", p.R.zy);
56  r.readValue("zz", p.R.zz);
57  r.endGroup();
58  }
59 
60  v = p;
61  return true;
62  }
63 
64  bool serializable() const { return true; }
65 
66 };
67 
68 #endif
PoseInfo
Definition: examples/custom_properties/pose_info.h:6
ed::io::Writer::endGroup
virtual void endGroup()=0
PoseInfo::deserialize
bool deserialize(ed::io::Reader &r, ed::Variant &v) const
Definition: examples/custom_properties/pose_info.h:34
geo::Transform3T::identity
static Transform3T identity()
geo::Mat3T::xz
T xz
geo::Transform3T
geo::Vec3T::y
T y
PoseInfo::serializable
bool serializable() const
Definition: examples/custom_properties/pose_info.h:64
ed::io::Writer::writeValue
virtual void writeValue(const std::string &key, float f)=0
property_info.h
ed::io::Reader::readValue
virtual bool readValue(const std::string &, float &f)=0
geo::Mat3T::zx
T zx
geo::Mat3T::zz
T zz
geo::Mat3T::yy
T yy
ed::io::Reader
Definition: reader.h:14
geo::Transform3T::t
Vec3T< T > t
ed::Variant
Definition: variant.h:49
ed::io::Writer::writeGroup
virtual void writeGroup(const std::string &name)=0
geo::Mat3T::xx
T xx
ed::io::Reader::readGroup
virtual bool readGroup(const std::string &name)=0
ed::io::Writer
Definition: writer.h:17
geo::Mat3T::zy
T zy
PoseInfo::serialize
void serialize(const ed::Variant &v, ed::io::Writer &w) const
Definition: examples/custom_properties/pose_info.h:11
geo::Mat3T::yx
T yx
geo::Transform3T::R
Mat3T< T > R
ed::io::Reader::endGroup
virtual bool endGroup()=0
ed::PropertyInfo
Definition: property_info.h:12
geo::Mat3T::yz
T yz
ed::Variant::getValue
TypeWrapper< T >::REFTYPE getValue()
Definition: variant.h:61
geo::Vec3T::z
T z
geo::Mat3T::xy
T xy
geo::Vec3T::x
T x