OGS
VTK2TIN.cpp
Go to the documentation of this file.
1
10#include <tclap/CmdLine.h>
11
12#include <fstream>
13#include <memory>
14#include <string>
15
16#include "BaseLib/Logging.h"
17#include "BaseLib/MPI.h"
19#include "GeoLib/GEOObjects.h"
21#include "GeoLib/Surface.h"
22#include "InfoLib/GitInfo.h"
25#include "MeshLib/Mesh.h"
26#include "MeshLib/Node.h"
28
29int main(int argc, char* argv[])
30{
31 TCLAP::CmdLine cmd(
32 "Converts VTK mesh into TIN file.\n\n"
33 "OpenGeoSys-6 software, version " +
35 ".\n"
36 "Copyright (c) 2012-2025, OpenGeoSys Community "
37 "(http://www.opengeosys.org)",
39 TCLAP::ValueArg<std::string> mesh_in(
40 "i", "mesh-input-file",
41 "Input (.vtk). The name of the file containing the input mesh", true,
42 "", "INPUT_FILE");
43 cmd.add(mesh_in);
44 TCLAP::ValueArg<std::string> mesh_out(
45 "o", "TIN-output-file",
46 "Output (.tin). The name of the file the TIN will be written to", true,
47 "", "OUTPUT_FILE");
48 cmd.add(mesh_out);
49 auto log_level_arg = BaseLib::makeLogLevelArg();
50 cmd.add(log_level_arg);
51 cmd.parse(argc, argv);
52
53 BaseLib::MPI::Setup mpi_setup(argc, argv);
54 BaseLib::initOGSLogger(log_level_arg.getValue());
55 std::unique_ptr<MeshLib::Mesh> mesh(
56 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
57 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
58 mesh->getNumberOfElements());
59
60 INFO("Converting the mesh to TIN");
61 GeoLib::GEOObjects geo_objects;
62 if (MeshToolsLib::convertMeshToGeo(*mesh, geo_objects))
63 {
64 INFO("Writing TIN into the file");
66 *(*geo_objects.getSurfaceVec(mesh->getName()))[0],
67 mesh_out.getValue());
68 }
69
70 return EXIT_SUCCESS;
71}
Definition of the Element class.
Definition of the GEOObjects class.
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
Definition of the Mesh class.
Definition of the Node class.
int main(int argc, char *argv[])
Definition VTK2TIN.cpp:29
Implementation of the VtuInterface class.
Container class for geometric objects.
Definition GEOObjects.h:57
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)
Definition of mesh to geometry conversion.
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
GITINFOLIB_EXPORT const std::string ogs_version
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)