Commit 0f43ef67 authored by Chris Cantwell's avatar Chris Cantwell

Added XML compression support to FldToTecGmsh and MeshConvert.

parent fd6830ba
......@@ -69,6 +69,17 @@ int main(int argc, char *argv[])
{
fname = fname.substr(0,fdot);
}
else if (ending == ".gz")
{
fname = fname.substr(0,fdot);
fdot = fname.find_last_of('.');
ASSERTL0(fdot != std::string::npos,
"Error: expected file extension before .gz.");
ending = fname.substr(fdot);
ASSERTL0(ending == ".xml",
"Compressed non-xml files are not supported.");
continue;
}
else if (ending == ".xml")
{
continue;
......
......@@ -37,6 +37,13 @@
#include <string>
using namespace std;
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
namespace io = boost::iostreams;
#include <tinyxml/tinyxml.h>
#include "MeshElements.h"
#include "OutputNekpp.h"
......@@ -51,7 +58,8 @@ namespace Nektar
OutputNekpp::OutputNekpp(MeshSharedPtr m) : OutputModule(m)
{
config["z"] = ConfigOption(true, "0",
"Compress output file and append a .gz extension.");
}
OutputNekpp::~OutputNekpp()
......@@ -89,8 +97,28 @@ namespace Nektar
WriteXmlExpansions(root);
WriteXmlConditions(root);
// Save the XML file.
doc.SaveFile(config["outfile"].as<string>());
// Extract the output filename and extension
string filename = config["outfile"].as<string>();
// Compress output and append .gz extension
if (config["z"].as<bool>())
{
filename += ".gz";
ofstream fout(filename.c_str(), std::ios_base::out | std::ios_base::binary);
std::stringstream decompressed;
decompressed << doc;
io::filtering_streambuf<io::output> out;
out.push(io::gzip_compressor());
out.push(fout);
io::copy(decompressed, out);
fout.close();
}
else
{
doc.SaveFile(filename);
}
}
void OutputNekpp::WriteXmlNodes(TiXmlElement * pRoot)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment