OGS
VTK2TIN.cpp File Reference
#include <tclap/CmdLine.h>
#include <fstream>
#include <memory>
#include <string>
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.h"
#include "GeoLib/GEOObjects.h"
#include "GeoLib/IO/TINInterface.h"
#include "GeoLib/Surface.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
#include "MeshToolsLib/convertMeshToGeo.h"
Include dependency graph for VTK2TIN.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 23 of file VTK2TIN.cpp.

24{
25 TCLAP::CmdLine cmd(
26 "Converts VTK mesh into TIN file.\n\n"
27 "OpenGeoSys-6 software, version " +
29 ".\n"
30 "Copyright (c) 2012-2026, OpenGeoSys Community "
31 "(http://www.opengeosys.org)",
33 TCLAP::ValueArg<std::string> mesh_in(
34 "i", "mesh-input-file",
35 "Input (.vtk). The name of the file containing the input mesh", true,
36 "", "INPUT_FILE");
37 cmd.add(mesh_in);
38 TCLAP::ValueArg<std::string> mesh_out(
39 "o", "TIN-output-file",
40 "Output (.tin). The name of the file the TIN will be written to", true,
41 "", "OUTPUT_FILE");
42 cmd.add(mesh_out);
43 auto log_level_arg = BaseLib::makeLogLevelArg();
44 cmd.add(log_level_arg);
45 cmd.parse(argc, argv);
46
47 BaseLib::MPI::Setup mpi_setup(argc, argv);
48 BaseLib::initOGSLogger(log_level_arg.getValue());
49 std::unique_ptr<MeshLib::Mesh> mesh(
50 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
51 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
52 mesh->getNumberOfElements());
53
54 INFO("Converting the mesh to TIN");
55 GeoLib::GEOObjects geo_objects;
56 if (MeshToolsLib::convertMeshToGeo(*mesh, geo_objects))
57 {
58 INFO("Writing TIN into the file");
60 *(*geo_objects.getSurfaceVec(mesh->getName()))[0],
61 mesh_out.getValue());
62 }
63
64 return EXIT_SUCCESS;
65}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
Container class for geometric objects.
Definition GEOObjects.h:46
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
static void writeSurfaceAsTIN(GeoLib::Surface const &surface, std::string const &file_name)
static MeshLib::Mesh * readVTUFile(std::string const &file_name, bool const compute_element_neighbors=false)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:56
GITINFOLIB_EXPORT const std::string ogs_version
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)

References MeshToolsLib::convertMeshToGeo(), GeoLib::GEOObjects::getSurfaceVec(), INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::VtuInterface::readVTUFile(), and GeoLib::IO::TINInterface::writeSurfaceAsTIN().