branch: devel-tetsuo-xml-binary commit 4afc12f85cf42adaa0b4c0806c5d2632a6d2454c Author: Tetsuo Koyama <tkoyama...@gmail.com> AuthorDate: Sun Sep 6 03:26:05 2020 +0900
Update for pass --- src/getfem/getfem_export.h | 11 ++++++----- src/getfem_export.cc | 35 +++++++++-------------------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h index c488dd5..d54c0e5 100644 --- a/src/getfem/getfem_export.h +++ b/src/getfem/getfem_export.h @@ -159,11 +159,12 @@ namespace getfem { if (ascii) os << " " << v; else { char *p = (char*)&v; - if (reverse_endian) - for (size_type i=0; i < sizeof(v)/2; ++i) - std::swap(p[i], p[sizeof(v)-i-1]); - if (vtk) os.write(p, sizeof(T)); - else { + if (vtk) { + if (reverse_endian) + for (size_type i=0; i < sizeof(v)/2; ++i) + std::swap(p[i], p[sizeof(v)-i-1]); + os.write(p, sizeof(T)); + } else { union { T value; unsigned char bytes[sizeof(T)]; } UNION; UNION.value = v; for (size_type i=0; i < sizeof(T); i++) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index c2ce7ee..5f8883b 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -559,36 +559,19 @@ namespace getfem 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 */ clear_vals(); - uint.value = sizeof(float)*6; - for (size_type i=0; i < sizeof(int); i++) - vals.push_back(uint.bytes[i]); - ufloat.value = 0.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); - ufloat.value = 0.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); - ufloat.value = 0.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); - ufloat.value = 1.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); - ufloat.value = 0.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); - ufloat.value = 0.0; - for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); + int size = sizeof(float)*6; + write_val(size); + float value; + value = 0.0; write_val(value); + value = 0.0; write_val(value); + value = 0.0; write_val(value); + value = 1.0; write_val(value); + value = 0.0; write_val(value); + value = 0.0; write_val(value); os << base64_encode(vals); clear_vals();