From 0b0616eee8610fc3569d71bd349bed7dd1d4245a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Sat, 28 Apr 2018 10:34:46 +0200 Subject: [PATCH] bug fix table archive --- libsrc/general/table.cpp | 15 ++++++++++----- libsrc/meshing/meshclass.cpp | 8 +------- libsrc/meshing/meshtype.cpp | 26 ++++++++++++++++++++++++++ libsrc/meshing/meshtype.hpp | 28 +--------------------------- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/libsrc/general/table.cpp b/libsrc/general/table.cpp index 9b3ca2d8..6769e03c 100644 --- a/libsrc/general/table.cpp +++ b/libsrc/general/table.cpp @@ -225,6 +225,11 @@ namespace netgen { ar & data[i].size; ar.Do ((unsigned char*)data[i].col, data[i].size*elemsize); + /* + for (size_t j = 0; j < data[i].size*elemsize; j++) + ar & ((unsigned char*) data[i].col)[j]; + cout << "write " << data[i].size*elemsize << " chars" << endl; + */ } } else @@ -233,14 +238,14 @@ namespace netgen ar & size & entries; data.SetSize(size); oneblock = new char [entries*elemsize]; - char * ptr = oneblock; - for (size_t i = 0; i < data.Size(); i++) + size_t cnt = 0; + for (size_t i = 0; i < size; i++) { ar & data[i].size; - data[i].col = ptr; + data[i].col = oneblock+cnt; data[i].maxsize = data[i].size; - ar.Do ((unsigned char*)data[i].col, data[i].size*elemsize); - ptr += size*elemsize; + ar.Do ((unsigned char*)(oneblock+cnt), data[i].size*elemsize); + cnt += data[i].size*elemsize; } } return ar; diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 5d9c669c..73194ead 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -1313,13 +1313,7 @@ namespace netgen archive & facedecoding; archive & materials & bcnames & cd2names; - if (archive.Output()) - archive & *ident; - else - { - // ident = new Identifications(*this); - archive & *ident; - } + archive & *ident; if (archive.Input()) { diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 161bff3c..e9ad5ac7 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2461,6 +2461,32 @@ namespace netgen maxidentnr = 0; } + ngstd::Archive & Identifications :: DoArchive (ngstd::Archive & ar) + { + ar & maxidentnr; + ar & identifiedpoints & identifiedpoints_nr; + + ar & idpoints_table; + if (ar.Output()) + { + size_t s = type.Size(); + ar & s; + for (auto & t : type) + ar & (unsigned char&)(t); + } + else + { + size_t s; + ar & s; + type.SetSize(s); + for (auto & t : type) + ar & (unsigned char&)(t); + } + return ar; + } + + + void Identifications :: Add (PointIndex pi1, PointIndex pi2, int identnr) { // (*testout) << "Identification::Add, pi1 = " << pi1 << ", pi2 = " << pi2 << ", identnr = " << identnr << endl; diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 9801ac07..46345e08 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1532,33 +1532,7 @@ namespace netgen DLL_HEADER void Print (ostream & ost) const; - ngstd::Archive & DoArchive (ngstd::Archive & ar) - { - ar & maxidentnr; - ar & identifiedpoints & identifiedpoints_nr; - ar & idpoints_table; - if (ar.Output()) - { - size_t s = type.Size(); - ar & s; - for (auto & t : type) - ar & (unsigned char&)(t); - } - else - { - size_t s; - ar & s; - type.SetSize(s); - for (auto & t : type) - ar & (unsigned char&)(t); - } - - cout << "identifiedpoints = " << identifiedpoints << endl; - cout << "identifiedpoints_nr = " << identifiedpoints_nr << endl; - cout << "idpoints_table = " << idpoints_table << endl; - cout << "type = " << type << endl; - return ar; - } + ngstd::Archive & DoArchive (ngstd::Archive & ar); }; inline ngstd::Archive & operator & (ngstd::Archive & archive, Identifications & mp)