OGS
TIN2VTK.cpp File Reference

Detailed Description

Definition in file TIN2VTK.cpp.

#include <tclap/CmdLine.h>
#include "BaseLib/TCLAPArguments.h"
#include <memory>
#include <string>
#include <vector>
#include "BaseLib/FileTools.h"
#include "BaseLib/MPI.h"
#include "InfoLib/GitInfo.h"
#include "GeoLib/IO/TINInterface.h"
#include "GeoLib/Point.h"
#include "GeoLib/PointVec.h"
#include "GeoLib/Surface.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "BaseLib/Logging.h"
#include "MeshLib/Mesh.h"
#include "MeshToolsLib/convertMeshToGeo.h"
Include dependency graph for TIN2VTK.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 35 of file TIN2VTK.cpp.

36{
37 TCLAP::CmdLine cmd(
38 "Converts TIN file into VTU file.\n\n"
39 "OpenGeoSys-6 software, version " +
41 ".\n"
42 "Copyright (c) 2012-2025, OpenGeoSys Community "
43 "(http://www.opengeosys.org)",
45 TCLAP::ValueArg<std::string> inArg("i", "input-tin-file",
46 "Input (.tin). The name "
47 "of the input file "
48 "containing the input TIN ",
49 true, "", "INPUT_FILE");
50 cmd.add(inArg);
51 TCLAP::ValueArg<std::string> outArg(
52 "o", "output-vtu-file",
53 "Output (.vtu). The name of the output file "
54 "the mesh will be written to",
55 true, "", "OUTPUT_FILE");
56 cmd.add(outArg);
57 auto log_level_arg = BaseLib::makeLogLevelArg();
58 cmd.add(log_level_arg);
59 cmd.parse(argc, argv);
60
61 BaseLib::MPI::Setup mpi_setup(argc, argv);
62 BaseLib::initOGSLogger(log_level_arg.getValue());
63
64 INFO("reading the TIN file...");
65 const std::string tinFileName(inArg.getValue());
66 std::string point_vec_name{"SurfacePoints"};
67 GeoLib::PointVec point_vec{point_vec_name, std::vector<GeoLib::Point*>{},
69 std::unique_ptr<GeoLib::Surface> sfc(
70 GeoLib::IO::TINInterface::readTIN(tinFileName, point_vec));
71 if (!sfc)
72 {
73 return EXIT_FAILURE;
74 }
75 INFO("TIN read: {:d} points, {:d} triangles", point_vec.size(),
76 sfc->getNumberOfTriangles());
77
78 INFO("converting to mesh data");
79 std::unique_ptr<MeshLib::Mesh> mesh(MeshToolsLib::convertSurfaceToMesh(
81 std::numeric_limits<double>::epsilon()));
82 INFO("Mesh created: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
83 mesh->getNumberOfElements());
84
85 INFO("Write it into VTU");
86 MeshLib::IO::VtuInterface writer(mesh.get());
87 writer.writeToFile(outArg.getValue());
88
89 return EXIT_SUCCESS;
90}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:36
static GeoLib::Surface * readTIN(std::string const &fname, GeoLib::PointVec &pnt_vec, std::vector< std::string > *errors=nullptr)
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition PointVec.h:36
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:41
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
std::string extractBaseNameWithoutExtension(std::string const &pathname)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::string &mesh_name, double eps)

References MeshToolsLib::convertSurfaceToMesh(), BaseLib::extractBaseNameWithoutExtension(), INFO(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, GeoLib::IO::TINInterface::readTIN(), and MeshLib::IO::VtuInterface::writeToFile().