21 #ifndef __VTK_WRITER_H 22 #define __VTK_WRITER_H 44 bool binary,
bool compress);
48 bool binary,
bool compress);
59 static std::string ascii_cell_data(
const Mesh& mesh,
60 const std::vector<std::size_t>& offset,
61 const std::vector<double>& values,
62 std::size_t dim, std::size_t rank);
65 static std::string base64_cell_data(
const Mesh& mesh,
66 const std::vector<std::size_t>& offset,
67 const std::vector<double>& values,
68 std::size_t dim, std::size_t rank,
72 static void write_ascii_mesh(
const Mesh& mesh, std::size_t cell_dim,
76 static void write_base64_mesh(
const Mesh& mesh, std::size_t cell_dim,
77 std::string file,
bool compress);
80 static std::uint8_t vtk_cell_type(
const Mesh& mesh, std::size_t cell_dim);
84 static std::string encode_inline_base64(
const std::vector<T>& data);
88 static std::string encode_inline_compressed_base64(
const std::vector<T>&
98 std::stringstream stream;
103 return encode_inline_compressed_base64(data);
105 warning(
"zlib must be configured to enable compressed VTK output. Using uncompressed base64 encoding instead.");
106 return encode_inline_base64(data);
110 return encode_inline_base64(data);
114 std::string VTKWriter::encode_inline_base64(
const std::vector<T>& data)
116 std::stringstream stream;
118 const std::uint32_t size = data.size()*
sizeof(T);
119 Encoder::encode_base64(&size, 1, stream);
120 Encoder::encode_base64(data, stream);
127 std::string VTKWriter::encode_inline_compressed_base64(
const std::vector<T>&
130 std::stringstream stream;
132 std::uint32_t header[4];
134 header[1] = data.size()*
sizeof(T);
138 std::vector<unsigned char> compressed_data
139 = Encoder::compress_data(data);
142 header[3] = compressed_data.size();
145 Encoder::encode_base64(&header[0], 4, stream);
148 Encoder::encode_base64(compressed_data.data(),
149 compressed_data.size(), stream);
static void write_cell_data(const Function &u, std::string file, bool binary, bool compress)
Cell data writer.
Definition: VTKWriter.cpp:54
void warning(std::string msg,...)
Print warning.
Definition: log.cpp:115
Write VTK Mesh representation.
Definition: VTKWriter.h:37
static std::string encode_stream(const std::vector< T > &data, bool compress)
Form (compressed) base64 encoded string for VTK.
Definition: VTKWriter.h:95
static void write_mesh(const Mesh &mesh, std::size_t cell_dim, std::string file, bool binary, bool compress)
Mesh writer.
Definition: VTKWriter.cpp:45
Definition: Function.h:65