diff --git a/FileIO/RapidXmlIO/BoostVtuInterface.cpp b/FileIO/RapidXmlIO/BoostVtuInterface.cpp index e007502ef49acf1a52c192cce6e73c17b70f7035..8333e3f7e845ea72d2bf08c16344e704c3c3a1a8 100644 --- a/FileIO/RapidXmlIO/BoostVtuInterface.cpp +++ b/FileIO/RapidXmlIO/BoostVtuInterface.cpp @@ -90,7 +90,6 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) "UnstructuredGrid.Piece"); if (piece_node) { - const unsigned nNodes = static_cast<unsigned>(piece_node->get("<xmlattr>.NumberOfPoints", 0)); const unsigned nElems = @@ -180,7 +179,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) optional<std::string> const& format = getXmlAttribute("format", *types); if (*format == "ascii") { - for(unsigned i=0; i<nElems; i++) + for(unsigned i = 0; i < nElems; i++) iss >> cell_types[i]; } else if (*format == "appended") @@ -216,7 +215,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) INFO("BoostVtuInterface::readVTUFile(): \tfinished."); INFO("BoostVtuInterface::readVTUFile(): Nr. Nodes: %d", nodes.size()); - INFO("BoostVtuInterface::readVTUFile(): Nr. Elements: ", elements.size()); + INFO("BoostVtuInterface::readVTUFile(): Nr. Elements: %d", elements.size()); return new MeshLib::Mesh(BaseLib::extractBaseNameWithoutExtension(file_name), nodes, elements); diff --git a/Utils/FileConverter/CMakeLists.txt b/Utils/FileConverter/CMakeLists.txt index 214873abe5035d755e821dcbb0a65f153b58e69c..be32d31afb706385499aa752925aa2d13f127158 100644 --- a/Utils/FileConverter/CMakeLists.txt +++ b/Utils/FileConverter/CMakeLists.txt @@ -83,3 +83,11 @@ TARGET_LINK_LIBRARIES (GMSH2OGS FileIO ) +ADD_EXECUTABLE (OGS2VTK OGS2VTK.cpp) +SET_TARGET_PROPERTIES(OGS2VTK PROPERTIES FOLDER Utilities) +TARGET_LINK_LIBRARIES (OGS2VTK + MeshLib + FileIO + zlib +) + diff --git a/Utils/FileConverter/OGS2VTK.cpp b/Utils/FileConverter/OGS2VTK.cpp new file mode 100644 index 0000000000000000000000000000000000000000..19ec71cbf8545467bed371b5aa61bf745cb1c779 --- /dev/null +++ b/Utils/FileConverter/OGS2VTK.cpp @@ -0,0 +1,63 @@ +/** + * @file OGS2VTK.cpp + * @author Thomas Fischer + * @date Jan 24, 2013 + * @brief Converts OGS mesh into VTK 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 "readMeshFromFile.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 OGS mesh into VTK 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::readMeshFromFile(mesh_in.getValue())); + INFO("Mesh read: %d nodes, %d elements.", mesh->getNNodes(), mesh->getNElements()); + + FileIO::BoostVtuInterface vtu; + vtu.setMesh(mesh); + vtu.writeToFile(mesh_out.getValue()); + + delete custom_format; + delete logog_cout; + LOGOG_SHUTDOWN(); + + return 0; +}