OGS
VTK2TIN.cpp File Reference

Detailed Description

Definition in file VTK2TIN.cpp.

#include <tclap/CmdLine.h>
#include <fstream>
#include <memory>
#include <string>
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "InfoLib/GitInfo.h"
#include "GeoLib/GEOObjects.h"
#include "GeoLib/IO/TINInterface.h"
#include "GeoLib/Surface.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 33 of file VTK2TIN.cpp.

34{
35 TCLAP::CmdLine cmd(
36 "Converts VTK mesh into TIN file.\n\n"
37 "OpenGeoSys-6 software, version " +
39 ".\n"
40 "Copyright (c) 2012-2024, OpenGeoSys Community "
41 "(http://www.opengeosys.org)",
43 TCLAP::ValueArg<std::string> mesh_in(
44 "i", "mesh-input-file",
45 "the name of the file containing the input mesh", true, "",
46 "file name of input mesh");
47 cmd.add(mesh_in);
48 TCLAP::ValueArg<std::string> mesh_out(
49 "o", "TIN-output-file",
50 "the name of the file the TIN will be written to", true, "",
51 "file name of output TIN");
52 cmd.add(mesh_out);
53 cmd.parse(argc, argv);
54
55 BaseLib::MPI::Setup mpi_setup(argc, argv);
56 std::unique_ptr<MeshLib::Mesh> mesh(
57 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
58 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
59 mesh->getNumberOfElements());
60
61 INFO("Converting the mesh to TIN");
62 GeoLib::GEOObjects geo_objects;
63 if (MeshToolsLib::convertMeshToGeo(*mesh, geo_objects))
64 {
65 INFO("Writing TIN into the file");
67 *(*geo_objects.getSurfaceVec(mesh->getName()))[0],
68 mesh_out.getValue());
69 }
70
71 return EXIT_SUCCESS;
72}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
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)
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(), GitInfoLib::GitInfo::ogs_version, MeshLib::IO::VtuInterface::readVTUFile(), and GeoLib::IO::TINInterface::writeSurfaceAsTIN().