getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Tetsuo Koyama
Subject: [Getfem-commits] (no subject)
Date: Sat, 3 Oct 2020 20:46:02 -0400 (EDT)

branch: devel-tetsuo-xml-binary
commit edb50f060326ae5ed45f6443c2444ec397912a9f
Author: Tetsuo Koyama <tkoyama010@gmail.com>
AuthorDate: Sun Sep 6 00:25:21 2020 +0900

    Add vtu binary to export
---
 src/getfem/getfem_export.h |  7 +++++--
 src/getfem_export.cc       | 50 ++--------------------------------------------
 2 files changed, 7 insertions(+), 50 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index f6f9171..c488dd5 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -163,9 +163,12 @@ namespace getfem {
         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
+      else {
+        union { T value; unsigned char bytes[sizeof(T)]; } UNION;
+        UNION.value = v;
         for (size_type i=0; i < sizeof(T); i++)
-          vals.push_back(p[i]);
+          vals.push_back(UNION.bytes[i]);
+      }
     }
   }
 
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index c8f5e19..4352b96 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -414,55 +414,8 @@ namespace getfem
 
   void vtk_export::write_vals() {
     if (!vtk && !ascii) {
-/*
-      int v = sizeof(vals)*sizeof(unsigned char);
-      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]);
-      std::vector<unsigned char> h;
-      for (size_type i=0; i < sizeof(int); i++)
-        h.push_back(p[i]);
-      vals.insert(vals.begin(), h.begin(), h.end());
-      os << base64_encode(vals) << "\n";
+      os << base64_encode(vals);
       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 (size_type i=0; i < sizeof(int); i++)
-        v.push_back(uint.bytes[i]);
-      ufloat.value = 0.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      ufloat.value = 0.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      ufloat.value = 0.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      ufloat.value = 1.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      ufloat.value = 0.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      ufloat.value = 0.0;
-      for (size_type i=0; i < sizeof(float); i++)
-        v.push_back(ufloat.bytes[i]);
-      os << base64_encode(v);
     }
   }
 
@@ -592,6 +545,7 @@ namespace getfem
     }
     std::vector<int> dofmap(pmf->nb_dof());
     int cnt = 0;
+    if (!vtk && !ascii) write_val(sizeof(float)*6);
     for (dal::bv_visitor d(pmf_dof_used); !d.finished(); ++d) {
       dofmap[d] = cnt++;
       base_node P = pmf->point_of_basic_dof(d);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]