branch: devel-tetsuo-xml-binary commit dbb6493369a23f6462e7a9165af04a42ac763586 Author: Tetsuo Koyama <tkoyama...@gmail.com> AuthorDate: Sun Jul 12 05:13:05 2020 +0000
:wrench: base64 --- src/getfem/getfem_export.h | 2 +- src/getfem_export.cc | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h index 9c861ae..b1e5840 100644 --- a/src/getfem/getfem_export.h +++ b/src/getfem/getfem_export.h @@ -287,7 +287,7 @@ namespace getfem { } else GMM_ASSERT1(false, std::string(vtk ? "vtk" : "vtu") + " does not accept vectors of dimension > 3"); - write_separ(); + if (vtk) write_separ(); if (!vtk) os << (ascii ? "" : "\n") << "</DataArray>\n"; } diff --git a/src/getfem_export.cc b/src/getfem_export.cc index ac98527..534a936 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -414,6 +414,7 @@ namespace getfem void vtk_export::write_vals() { if (!vtk && !ascii) { +/* int v = sizeof(vals)*sizeof(unsigned char); char *p = (char*)&v; if (reverse_endian) @@ -425,6 +426,43 @@ namespace getfem vals.insert(vals.begin(), h.begin(), h.end()); os << base64_encode(vals) << "\n"; clear_vals(); +*/ + union { + float value; + unsigned char bytes[sizeof(float)]; + } ufloat; + union { + int64_t value; + unsigned char bytes[sizeof(int64_t)]; + } uint64_t; + union { + int value; + unsigned char bytes[sizeof(int)]; + } uint; + /* Points */ + std::vector<unsigned char> v; + uint.value = sizeof(float)*6; + for (int i=0; i < sizeof(int); i++) + v.push_back(uint.bytes[i]); + ufloat.value = 0.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + ufloat.value = 0.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + ufloat.value = 0.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + ufloat.value = 1.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + ufloat.value = 0.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + ufloat.value = 0.0; + for (int i=0; i < sizeof(float); i++) + v.push_back(ufloat.bytes[i]); + os << base64_encode(v); } }