OGS
Mesh2Shape.cpp File Reference

Detailed Description

Definition in file Mesh2Shape.cpp.

#include <tclap/CmdLine.h>
#include <mpi.h>
#include "Applications/FileIO/SHPInterface.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/Mesh.h"
Include dependency graph for Mesh2Shape.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 21 of file Mesh2Shape.cpp.

22{
23 TCLAP::CmdLine cmd(
24 "Converts 2D mesh file into shapfile such that each element is "
25 "represented by a polygon. Cell attributes are transferred onto shape "
26 "polygons while point attributes are ignored.\n\n"
27 "OpenGeoSys-6 software, version " +
29 ".\n"
30 "Copyright (c) 2012-2024, OpenGeoSys Community "
31 "(http://www.opengeosys.org)",
33
34 TCLAP::ValueArg<std::string> output_arg("o", "output-file",
35 "Esri Shapefile (*.shp)", true, "",
36 "output_file.shp");
37 cmd.add(output_arg);
38
39 TCLAP::ValueArg<std::string> input_arg("i", "input-file",
40 "OGS mesh file (*.vtu, *.msh)", true,
41 "", "input_file.vtu");
42 cmd.add(input_arg);
43
44 cmd.parse(argc, argv);
45
46#ifdef USE_PETSC
47 MPI_Init(&argc, &argv);
48#endif
49
50 std::string const file_name(input_arg.getValue());
51 std::unique_ptr<MeshLib::Mesh> const mesh(
53 if (FileIO::SHPInterface::write2dMeshToSHP(output_arg.getValue(), *mesh))
54 {
55#ifdef USE_PETSC
56 MPI_Finalize();
57#endif
58 return EXIT_SUCCESS;
59 }
60#ifdef USE_PETSC
61 MPI_Finalize();
62#endif
63 return EXIT_FAILURE;
64}
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)

References GitInfoLib::GitInfo::ogs_version, MeshLib::IO::readMeshFromFile(), and FileIO::SHPInterface::write2dMeshToSHP().