OGS
Mesh2Shape.cpp File Reference
#include <tclap/CmdLine.h>
#include "Applications/FileIO/SHPInterface.h"
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.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 14 of file Mesh2Shape.cpp.

15{
16 TCLAP::CmdLine cmd(
17 "Converts 2D mesh file into shapfile such that each element is "
18 "represented by a polygon. Cell attributes are transferred onto shape "
19 "polygons while point attributes are ignored.\n\n"
20 "OpenGeoSys-6 software, version " +
22 ".\n"
23 "Copyright (c) 2012-2026, OpenGeoSys Community "
24 "(http://www.opengeosys.org)",
26
27 TCLAP::ValueArg<std::string> output_arg("o", "output-file",
28 "Output (.shp). Esri Shapefile",
29 true, "", "OUTPUT_FILE");
30 cmd.add(output_arg);
31
32 TCLAP::ValueArg<std::string> input_arg("i", "input-file",
33 "Input (.vtu | .msh). OGS mesh file",
34 true, "", "INPUT_FILE");
35 cmd.add(input_arg);
36
37 auto log_level_arg = BaseLib::makeLogLevelArg();
38 cmd.add(log_level_arg);
39 cmd.parse(argc, argv);
40
41 BaseLib::MPI::Setup mpi_setup(argc, argv);
42 BaseLib::initOGSLogger(log_level_arg.getValue());
43
44 std::string const file_name(input_arg.getValue());
45 std::unique_ptr<MeshLib::Mesh> const mesh(
47 if (FileIO::SHPInterface::write2dMeshToSHP(output_arg.getValue(), *mesh))
48 {
49 return EXIT_SUCCESS;
50 }
51 return EXIT_FAILURE;
52}
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:56
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)

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