Skip to content
Snippets Groups Projects
Unverified Commit e1f08da7 authored by Lars Bilke's avatar Lars Bilke Committed by GitHub
Browse files

Merge pull request #2627 from rinkk/shapeexportcli

[utils] mesh to shape conversion
parents a6237de7 fcae1c15
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,10 @@ if(OGS_BUILD_GUI) ...@@ -18,6 +18,10 @@ if(OGS_BUILD_GUI)
list(APPEND TOOLS FEFLOW2OGS) list(APPEND TOOLS FEFLOW2OGS)
endif() endif()
if(Shapelib_FOUND)
list(APPEND TOOLS Mesh2Shape)
endif()
foreach(TOOL ${TOOLS}) foreach(TOOL ${TOOLS})
add_executable(${TOOL} ${TOOL}.cpp) add_executable(${TOOL} ${TOOL}.cpp)
target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib) target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib)
...@@ -28,3 +32,8 @@ install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities) ...@@ -28,3 +32,8 @@ install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities)
if(TARGET ConvertSHPToGLI) if(TARGET ConvertSHPToGLI)
target_link_libraries(ConvertSHPToGLI GeoLib Qt5::Xml ${Shapelib_LIBRARIES}) target_link_libraries(ConvertSHPToGLI GeoLib Qt5::Xml ${Shapelib_LIBRARIES})
endif() endif()
if(TARGET Mesh2Shape)
target_link_libraries(Mesh2Shape ${Shapelib_LIBRARIES})
endif()
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#include <tclap/CmdLine.h>
#include "Applications/ApplicationsLib/LogogSetup.h"
#include "Applications/FileIO/SHPInterface.h"
#include "InfoLib/GitInfo.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/Mesh.h"
int main(int argc, char* argv[])
{
ApplicationsLib::LogogSetup logog_setup;
TCLAP::CmdLine cmd(
"Converts 2D mesh file into shapfile such that each element is "
"represented by a polygon. Cell attributes are transferred onto shape "
"polygons while point attributes are ignored.\n\n"
"OpenGeoSys-6 software, version " +
GitInfoLib::GitInfo::ogs_version +
".\n"
"Copyright (c) 2012-2019, OpenGeoSys Community "
"(http://www.opengeosys.org)",
' ', GitInfoLib::GitInfo::ogs_version);
TCLAP::ValueArg<std::string> output_arg("o", "output-file",
"Esri Shapefile (*.shp)", true, "",
"output_file.shp");
cmd.add(output_arg);
TCLAP::ValueArg<std::string> input_arg("i", "input-file",
"OGS mesh file (*.vtu, *.msh)", true,
"", "input_file.vtu");
cmd.add(input_arg);
cmd.parse(argc, argv);
std::string const file_name(input_arg.getValue());
std::unique_ptr<MeshLib::Mesh> const mesh(
MeshLib::IO::readMeshFromFile(file_name));
if (FileIO::SHPInterface::write2dMeshToSHP(output_arg.getValue(), *mesh))
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment