Skip to content
Snippets Groups Projects
Commit f53c6d3e authored by Tom Fischer's avatar Tom Fischer
Browse files

Added simple program to convert OGS meshes into vtk format.

parent 923006ab
No related branches found
No related tags found
No related merge requests found
...@@ -90,7 +90,6 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) ...@@ -90,7 +90,6 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name)
"UnstructuredGrid.Piece"); "UnstructuredGrid.Piece");
if (piece_node) if (piece_node)
{ {
const unsigned nNodes = const unsigned nNodes =
static_cast<unsigned>(piece_node->get("<xmlattr>.NumberOfPoints", 0)); static_cast<unsigned>(piece_node->get("<xmlattr>.NumberOfPoints", 0));
const unsigned nElems = const unsigned nElems =
...@@ -180,7 +179,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) ...@@ -180,7 +179,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name)
optional<std::string> const& format = getXmlAttribute("format", *types); optional<std::string> const& format = getXmlAttribute("format", *types);
if (*format == "ascii") if (*format == "ascii")
{ {
for(unsigned i=0; i<nElems; i++) for(unsigned i = 0; i < nElems; i++)
iss >> cell_types[i]; iss >> cell_types[i];
} }
else if (*format == "appended") else if (*format == "appended")
...@@ -216,7 +215,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name) ...@@ -216,7 +215,7 @@ MeshLib::Mesh* BoostVtuInterface::readVTUFile(const std::string &file_name)
INFO("BoostVtuInterface::readVTUFile(): \tfinished."); INFO("BoostVtuInterface::readVTUFile(): \tfinished.");
INFO("BoostVtuInterface::readVTUFile(): Nr. Nodes: %d", nodes.size()); 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, return new MeshLib::Mesh(BaseLib::extractBaseNameWithoutExtension(file_name), nodes,
elements); elements);
......
...@@ -83,3 +83,11 @@ TARGET_LINK_LIBRARIES (GMSH2OGS ...@@ -83,3 +83,11 @@ TARGET_LINK_LIBRARIES (GMSH2OGS
FileIO FileIO
) )
ADD_EXECUTABLE (OGS2VTK OGS2VTK.cpp)
SET_TARGET_PROPERTIES(OGS2VTK PROPERTIES FOLDER Utilities)
TARGET_LINK_LIBRARIES (OGS2VTK
MeshLib
FileIO
zlib
)
/**
* @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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment