浏览代码

typo in tutorial, add all alternatives to example

Former-commit-id: 136bbd895ee61711d0167d910ac78a8d68e25ce6
Alec Jacobson 9 年之前
父节点
当前提交
0bee6df6ee
共有 2 个文件被更改,包括 51 次插入30 次删除
  1. 50 29
      tutorial/601_Serialization/main.cpp
  2. 1 1
      tutorial/tutorial.md.REMOVED.git-id

+ 50 - 29
tutorial/601_Serialization/main.cpp

@@ -8,38 +8,59 @@
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 
-// derive from igl::Serializable to serialize your own type
-struct State : public igl::Serializable
-{
-  Eigen::MatrixXd V;
-  Eigen::MatrixXi F;
-  std::vector<int> ids;
-
-  // You have to define this function to
-  // register the fields you want to serialize
-  void InitSerialization()
-  {
-    this->Add(V  , "V");
-    this->Add(F  , "F");
-    this->Add(ids, "ids");
-  }
-};
+//// derive from igl::Serializable to serialize your own type
+//struct State : public igl::Serializable
+//{
+//  Eigen::MatrixXd V;
+//  Eigen::MatrixXi F;
+//  std::vector<int> ids;
+//
+//  // You have to define this function to
+//  // register the fields you want to serialize
+//  void InitSerialization()
+//  {
+//    this->Add(V  , "V");
+//    this->Add(F  , "F");
+//    this->Add(ids, "ids");
+//  }
+//};
 
-// alternatively you can do it like the following to have
-// a non-intrusive serialization:
+//// alternatively you can do it like the following to have
+//// a non-intrusive serialization:
+////
+//struct State
+//{
+//  Eigen::MatrixXd V;
+//  Eigen::MatrixXi F;
+//  std::vector<int> ids;
+//};
+//
+//
+//namespace igl
+//{
+//  namespace serialization
+//  {
+//    // the `template <>` is essential
+//    template <> inline void serialize(const State& obj,std::vector<char>& buffer){
+//      ::igl::serialize(obj.V,std::string("V"),buffer);
+//      ::igl::serialize(obj.F,std::string("F"),buffer);
+//      ::igl::serialize(obj.ids,std::string("ids"),buffer);
+//    }
+//    template <> inline void deserialize(State& obj,const std::vector<char>& buffer){
+//      ::igl::deserialize(obj.V,std::string("V"),buffer);
+//      ::igl::deserialize(obj.F,std::string("F"),buffer);
+//      ::igl::deserialize(obj.ids,std::string("ids"),buffer);
+//    }
+//  }
+//}
 //
-// struct State
-// {
-//   Eigen::MatrixXd V;
-//   Eigen::MatrixXi F;
-//   std::vector<int> ids;
-// };
+////OR:
 // 
-// SERIALIZE_TYPE(State,
-//  SERIALIZE_MEMBER(V)
-//   SERIALIZE_MEMBER(F)
-//   SERIALIZE_MEMBER_NAME(ids,"ids")
-// )
+//SERIALIZE_TYPE(State,
+// SERIALIZE_MEMBER(V)
+//  SERIALIZE_MEMBER(F)
+//  SERIALIZE_MEMBER_NAME(ids,"ids")
+//)
 
 int main(int argc, char *argv[])
 {

+ 1 - 1
tutorial/tutorial.md.REMOVED.git-id

@@ -1 +1 @@
-d039bd30783b382638c2631f9585d659105ad78c
+e2e0d9675881ddf6a0d438a24c4ef1bb8f4b4791