Commit 24f96b7c authored by Isaak Lim's avatar Isaak Lim
Browse files

use serialize and deserialize functionality provided by Serializers.hh (thanks to Max Lyon)

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@290 66977474-1d4b-4f09-8fe9-267525286df2
parent e08e0d1c
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
#include "OpenVolumeMeshBaseProperty.hh" #include "OpenVolumeMeshBaseProperty.hh"
#include "Serializers.hh"
namespace OpenVolumeMesh { namespace OpenVolumeMesh {
//== CLASS DEFINITION ========================================================= //== CLASS DEFINITION =========================================================
...@@ -146,16 +148,14 @@ public: ...@@ -146,16 +148,14 @@ public:
virtual void serialize(std::ostream& _ostr) const { virtual void serialize(std::ostream& _ostr) const {
for(typename vector_type::const_iterator it = data_.begin(); for(typename vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) { it != data_.end(); ++it) {
_ostr << *it << std::endl; OpenVolumeMesh::serialize(_ostr, *it) << std::endl;
} }
} }
// Function to deserialize a property // Function to deserialize a property
virtual void deserialize(std::istream& _istr) { virtual void deserialize(std::istream& _istr) {
for(unsigned int i = 0; i < n_elements(); ++i) { for(unsigned int i = 0; i < n_elements(); ++i) {
value_type val; OpenVolumeMesh::deserialize(_istr, data_[i]);
_istr >> val;
data_[i] = val;
} }
} }
...@@ -297,7 +297,7 @@ public: ...@@ -297,7 +297,7 @@ public:
virtual void serialize(std::ostream& _ostr) const { virtual void serialize(std::ostream& _ostr) const {
for(vector_type::const_iterator it = data_.begin(); for(vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) { it != data_.end(); ++it) {
_ostr << *it << std::endl; OpenVolumeMesh::serialize(_ostr, *it) << std::endl;
} }
} }
...@@ -305,7 +305,7 @@ public: ...@@ -305,7 +305,7 @@ public:
virtual void deserialize(std::istream& _istr) { virtual void deserialize(std::istream& _istr) {
for(unsigned int i = 0; i < n_elements(); ++i) { for(unsigned int i = 0; i < n_elements(); ++i) {
value_type val; value_type val;
_istr >> val; OpenVolumeMesh::deserialize(_istr, val);
data_[i] = val; data_[i] = val;
} }
} }
...@@ -436,6 +436,21 @@ public: ...@@ -436,6 +436,21 @@ public:
} }
} }
// Function to serialize a property
virtual void serialize(std::ostream& _ostr) const {
for(vector_type::const_iterator it = data_.begin();
it != data_.end(); ++it) {
OpenVolumeMesh::serialize(_ostr, *it) << std::endl;
}
}
// Function to deserialize a property
virtual void deserialize(std::istream& _istr) {
for(unsigned int i = 0; i < n_elements(); ++i) {
OpenVolumeMesh::deserialize(_istr, data_[i]);
}
}
public: public:
const value_type* data() const { const value_type* data() const {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment