OGS
TIN2VTK.cpp File Reference

Detailed Description

Definition in file TIN2VTK.cpp.

#include <tclap/CmdLine.h>
#include <memory>
#include <string>
#include <vector>
#include "BaseLib/FileTools.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 "MeshLib/Mesh.h"
#include "MeshLib/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 32 of file TIN2VTK.cpp.

33 {
34  TCLAP::CmdLine cmd(
35  "Converts TIN file into VTU file.\n\n"
36  "OpenGeoSys-6 software, version " +
38  ".\n"
39  "Copyright (c) 2012-2021, OpenGeoSys Community "
40  "(http://www.opengeosys.org)",
42  TCLAP::ValueArg<std::string> inArg(
43  "i", "input-tin-file", "the name of the file containing the input TIN",
44  true, "", "string");
45  cmd.add(inArg);
46  TCLAP::ValueArg<std::string> outArg(
47  "o", "output-vtu-file",
48  "the name of the file the mesh will be written to", true, "", "string");
49  cmd.add(outArg);
50  cmd.parse(argc, argv);
51 
52  INFO("reading the TIN file...");
53  const std::string tinFileName(inArg.getValue());
54  GeoLib::PointVec point_vec("SurfacePoints",
55  std::make_unique<std::vector<GeoLib::Point*>>());
56  std::unique_ptr<GeoLib::Surface> sfc(
57  GeoLib::IO::TINInterface::readTIN(tinFileName, point_vec));
58  if (!sfc)
59  {
60  return EXIT_FAILURE;
61  }
62  INFO("TIN read: {:d} points, {:d} triangles", point_vec.size(),
63  sfc->getNumberOfTriangles());
64 
65  INFO("converting to mesh data");
66  std::unique_ptr<MeshLib::Mesh> mesh(MeshLib::convertSurfaceToMesh(
68  std::numeric_limits<double>::epsilon()));
69  INFO("Mesh created: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
70  mesh->getNumberOfElements());
71 
72  INFO("Write it into VTU");
73  MeshLib::IO::VtuInterface writer(mesh.get());
74  writer.writeToFile(outArg.getValue());
75 
76  return EXIT_SUCCESS;
77 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
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 deletin...
Definition: PointVec.h:39
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
Definition: VtuInterface.h:38
std::string extractBaseNameWithoutExtension(std::string const &pathname)
Definition: FileTools.cpp:180
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::string &mesh_name, double eps)

References MeshLib::convertSurfaceToMesh(), BaseLib::extractBaseNameWithoutExtension(), INFO(), GitInfoLib::GitInfo::ogs_version, GeoLib::IO::TINInterface::readTIN(), GeoLib::TemplateVec< T >::size(), and MeshLib::IO::VtuInterface::writeToFile().