OGS
VTK2TIN.cpp
Go to the documentation of this file.
1
10#include <tclap/CmdLine.h>
11
12#ifdef USE_PETSC
13#include <mpi.h>
14#endif
15
16// STL
17#include <fstream>
18#include <memory>
19#include <string>
20
21// BaseLib
22#include "BaseLib/Logging.h"
23#include "InfoLib/GitInfo.h"
24
25// GeoLib
26#include "GeoLib/GEOObjects.h"
28#include "GeoLib/Surface.h"
29
30// MeshLib
33#include "MeshLib/Mesh.h"
34#include "MeshLib/Node.h"
36
37int main(int argc, char* argv[])
38{
39 TCLAP::CmdLine cmd(
40 "Converts VTK mesh into TIN file.\n\n"
41 "OpenGeoSys-6 software, version " +
43 ".\n"
44 "Copyright (c) 2012-2024, OpenGeoSys Community "
45 "(http://www.opengeosys.org)",
47 TCLAP::ValueArg<std::string> mesh_in(
48 "i", "mesh-input-file",
49 "the name of the file containing the input mesh", true, "",
50 "file name of input mesh");
51 cmd.add(mesh_in);
52 TCLAP::ValueArg<std::string> mesh_out(
53 "o", "TIN-output-file",
54 "the name of the file the TIN will be written to", true, "",
55 "file name of output TIN");
56 cmd.add(mesh_out);
57 cmd.parse(argc, argv);
58
59#ifdef USE_PETSC
60 MPI_Init(&argc, &argv);
61#endif
62 std::unique_ptr<MeshLib::Mesh> mesh(
63 MeshLib::IO::VtuInterface::readVTUFile(mesh_in.getValue()));
64 INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
65 mesh->getNumberOfElements());
66
67 INFO("Converting the mesh to TIN");
68 GeoLib::GEOObjects geo_objects;
69 if (MeshToolsLib::convertMeshToGeo(*mesh, geo_objects))
70 {
71 INFO("Writing TIN into the file");
73 *(*geo_objects.getSurfaceVec(mesh->getName()))[0],
74 mesh_out.getValue());
75 }
76
77#ifdef USE_PETSC
78 MPI_Finalize();
79#endif
80 return EXIT_SUCCESS;
81}
Definition of the Element class.
Definition of the GEOObjects class.
Git information.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the Mesh class.
Definition of the Node class.
int main(int argc, char *argv[])
Definition VTK2TIN.cpp:37
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.
GITINFOLIB_EXPORT const std::string ogs_version
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)