diff --git a/Utils/FileConverter/CMakeLists.txt b/Utils/FileConverter/CMakeLists.txt index 793c07eb6e28424190ac2468d2aa4b80257e0a44..5a33d093c22e77379a25cfa9dfeeb70344f1aa9b 100644 --- a/Utils/FileConverter/CMakeLists.txt +++ b/Utils/FileConverter/CMakeLists.txt @@ -81,3 +81,10 @@ TARGET_LINK_LIBRARIES (OGS2VTK zlib ) +ADD_EXECUTABLE (VTK2OGS VTK2OGS.cpp) +SET_TARGET_PROPERTIES(VTK2OGS PROPERTIES FOLDER Utilities) +TARGET_LINK_LIBRARIES (VTK2OGS + MeshLib + FileIO + zlib +) diff --git a/Utils/FileConverter/VTK2OGS.cpp b/Utils/FileConverter/VTK2OGS.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c05b31bb74eb47f67efb47313521c2f801024b06 --- /dev/null +++ b/Utils/FileConverter/VTK2OGS.cpp @@ -0,0 +1,63 @@ +/** + * @file VTK2OGS.cpp + * @author Norihiro Watanabe + * @date Aug 07, 2013 + * @brief Converts VTK mesh into OGS mesh. + * + * @copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ + +// STL +#include <string> + +// TCLAP +#include "tclap/CmdLine.h" + +// ThirdParty/logog +#include "logog/include/logog.hpp" + +// BaseLib +#include "LogogSimpleFormatter.h" + +// FileIO +#include "RapidXmlIO/BoostVtuInterface.h" +#include "Legacy/MeshIO.h" + +// MeshLib +#include "Mesh.h" + +int main (int argc, char* argv[]) +{ + LOGOG_INITIALIZE(); + logog::Cout* logog_cout (new logog::Cout); + BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); + logog_cout->SetFormatter(*custom_format); + + TCLAP::CmdLine cmd("Converts VTK mesh into OGS mesh.", ' ', "0.1"); + TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", + "the name of the file containing the input mesh", true, + "", "file name of input mesh"); + cmd.add(mesh_in); + TCLAP::ValueArg<std::string> mesh_out("o", "mesh-output-file", + "the name of the file the mesh will be written to", true, + "", "file name of output mesh"); + cmd.add(mesh_out); + cmd.parse(argc, argv); + + MeshLib::Mesh* mesh (FileIO::BoostVtuInterface::readVTUFile(mesh_in.getValue())); + INFO("Mesh read: %d nodes, %d elements.", mesh->getNNodes(), mesh->getNElements()); + + FileIO::MeshIO meshIO; + meshIO.setMesh(mesh); + meshIO.writeToFile(mesh_out.getValue()); + + delete custom_format; + delete logog_cout; + LOGOG_SHUTDOWN(); + + return 0; +}