OGS
VTK2TIN.cpp
Go to the documentation of this file.
1 
10 // STL
11 #include <tclap/CmdLine.h>
12 
13 #include <fstream>
14 #include <memory>
15 #include <string>
16 
17 // BaseLib
18 #include "BaseLib/Logging.h"
19 #include "InfoLib/GitInfo.h"
20 
21 // GeoLib
22 #include "GeoLib/GEOObjects.h"
23 #include "GeoLib/IO/TINInterface.h"
24 #include "GeoLib/Surface.h"
25 
26 // MeshLib
29 #include "MeshLib/Mesh.h"
30 #include "MeshLib/Node.h"
32 
33 int main(int argc, char* argv[])
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-2021, 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  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 (MeshLib::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(char const *fmt, Args const &... args)
Definition: Logging.h:32
Definition of the Mesh class.
Definition of the Node class.
int main(int argc, char *argv[])
Definition: VTK2TIN.cpp:33
Implementation of the VtuInterface class.
Container class for geometric objects.
Definition: GEOObjects.h:61
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
Definition: GEOObjects.cpp:307
static void writeSurfaceAsTIN(GeoLib::Surface const &surface, std::string const &file_name)
static MeshLib::Mesh * readVTUFile(std::string const &file_name)
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)