diff --git a/Applications/Utils/FileConverter/OGS2VTK.cpp b/Applications/Utils/FileConverter/OGS2VTK.cpp index 6799fdbfd5e65a3974eeb0683848f80d55e24a95..fddf988cccc541f7cacdb958265a6af6e8bc3e64 100644 --- a/Applications/Utils/FileConverter/OGS2VTK.cpp +++ b/Applications/Utils/FileConverter/OGS2VTK.cpp @@ -44,6 +44,12 @@ int main (int argc, char* argv[]) "the name of the file the mesh will be written to", true, "", "file name of output mesh"); cmd.add(mesh_out); + TCLAP::ValueArg<bool> use_ascii_arg( + "", "ascii_output", + "Use ascii format for data in the vtu output. Due to possible rounding " + "the ascii output could result in lower accuracy.", + false, false, "boolean value"); + cmd.add(use_ascii_arg); cmd.parse(argc, argv); std::unique_ptr<MeshLib::Mesh const> mesh( @@ -55,8 +61,10 @@ int main (int argc, char* argv[]) INFO("Mesh read: %d nodes, %d elements.", mesh->getNumberOfNodes(), mesh->getNumberOfElements()); - MeshLib::IO::VtuInterface vtu(mesh.get()); - vtu.writeToFile(mesh_out.getValue()); + auto const data_mode = + use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary; + + MeshLib::IO::writeVtu(*mesh, mesh_out.getValue(), data_mode); return EXIT_SUCCESS; } diff --git a/Applications/Utils/MeshEdit/ExtractSurface.cpp b/Applications/Utils/MeshEdit/ExtractSurface.cpp index 75e31e621c8237701f60dc463fe787a6f0ad5ec4..30c55122398d1565310735854d373d530ad4b960 100644 --- a/Applications/Utils/MeshEdit/ExtractSurface.cpp +++ b/Applications/Utils/MeshEdit/ExtractSurface.cpp @@ -120,13 +120,9 @@ int main (int argc, char* argv[]) out_fname = BaseLib::dropFileExtension(mesh_in.getValue()) + "_sfc.vtu"; } - if (use_ascii_arg.getValue()) - { - MeshLib::IO::writeVtu(*surface_mesh, out_fname, vtkXMLWriter::Ascii); - } - else - { - MeshLib::IO::writeMeshToFile(*surface_mesh, out_fname); - } + auto const data_mode = + use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary; + MeshLib::IO::writeVtu(*surface_mesh, out_fname, data_mode); + return EXIT_SUCCESS; } diff --git a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp index ce0037029b6c1806caabbc948bef7231a873d87b..016b49fa6c59b18051102f342dccd7eacb8d9e30 100644 --- a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp +++ b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp @@ -24,7 +24,7 @@ #include "BaseLib/FileTools.h" #include "MeshLib/IO/readMeshFromFile.h" -#include "MeshLib/IO/writeMeshToFile.h" +#include "MeshLib/IO/VtkIO/VtuInterface.h" #include "Applications/FileIO/AsciiRasterInterface.h" #include "MeshLib/Mesh.h" @@ -98,6 +98,13 @@ int main (int argc, char* argv[]) false, min_thickness, "minimum layer thickness"); cmd.add(min_thickness_arg); + TCLAP::ValueArg<bool> use_ascii_arg( + "", "ascii_output", + "Use ascii format for data in the vtu output. Due to possible rounding " + "the ascii output could result in lower accuracy.", + false, false, "boolean value"); + cmd.add(use_ascii_arg); + cmd.parse(argc, argv); if (min_thickness_arg.isSet()) @@ -149,9 +156,15 @@ int main (int argc, char* argv[]) { output_name.append(".vtu"); } + INFO("Writing mesh '%s' ... ", output_name.c_str()); - MeshLib::IO::writeMeshToFile(*(mapper.getMesh("SubsurfaceMesh").release()), - output_name); + auto result_mesh = std::make_unique<MeshLib::Mesh>( + *(mapper.getMesh("SubsurfaceMesh").release())); + + auto const data_mode = + use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary; + + MeshLib::IO::writeVtu(*result_mesh, output_name, data_mode); INFO("done."); return EXIT_SUCCESS;