OGS
Mesh2Shape.cpp
Go to the documentation of this file.
1
10#include <tclap/CmdLine.h>
11
13#include "BaseLib/Logging.h"
14#include "BaseLib/MPI.h"
16#include "InfoLib/GitInfo.h"
18#include "MeshLib/Mesh.h"
19
20int main(int argc, char* argv[])
21{
22 TCLAP::CmdLine cmd(
23 "Converts 2D mesh file into shapfile such that each element is "
24 "represented by a polygon. Cell attributes are transferred onto shape "
25 "polygons while point attributes are ignored.\n\n"
26 "OpenGeoSys-6 software, version " +
28 ".\n"
29 "Copyright (c) 2012-2025, OpenGeoSys Community "
30 "(http://www.opengeosys.org)",
32
33 TCLAP::ValueArg<std::string> output_arg("o", "output-file",
34 "Output (.shp). Esri Shapefile",
35 true, "", "OUTPUT_FILE");
36 cmd.add(output_arg);
37
38 TCLAP::ValueArg<std::string> input_arg("i", "input-file",
39 "Input (.vtu | .msh). OGS mesh file",
40 true, "", "INPUT_FILE");
41 cmd.add(input_arg);
42
43 auto log_level_arg = BaseLib::makeLogLevelArg();
44 cmd.add(log_level_arg);
45 cmd.parse(argc, argv);
46
47 BaseLib::MPI::Setup mpi_setup(argc, argv);
48 BaseLib::initOGSLogger(log_level_arg.getValue());
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 return EXIT_SUCCESS;
56 }
57 return EXIT_FAILURE;
58}
Git information.
int main(int argc, char *argv[])
Definition of the Mesh class.
Implementation of the SHPInterface class.
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:64
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
Definition of readMeshFromFile function.