28int main(
int argc,
char* argv[])
31 "Assigns the pixel information of a raster file to a scalar array of a "
32 "specified 2D mesh. Data will be assigned to a node array by default. "
33 "Adding information to cell arrays is also possible, pixel values at "
34 "the centre of the cell will be used in this case. Note that large "
35 "differences in resolution between cell size of the mesh and pixel "
36 "size of the raster can give unexpected results. A no-data value will "
37 "be added in case of missing or transparent values.\n\n"
38 "OpenGeoSys-6 software, version " +
41 "Copyright (c) 2012-2024, OpenGeoSys Community "
42 "(http://www.opengeosys.org)",
45 TCLAP::ValueArg<double> nodata_arg(
46 "e",
"nodata",
"The no data value used for missing values",
false, 0,
50 TCLAP::SwitchArg set_cells_arg(
"c",
"cell-array",
51 "Assigns raster data to cell array");
52 cmd.add(set_cells_arg);
54 TCLAP::SwitchArg set_nodes_arg(
55 "n",
"node-array",
"Assigns raster data to node array (default)");
56 cmd.add(set_nodes_arg);
58 TCLAP::ValueArg<std::string> array_name_arg(
59 "s",
"scalar-name",
"The name of the newly created scalar array.",
true,
60 "",
"scalar array name");
61 cmd.add(array_name_arg);
62 TCLAP::ValueArg<std::string> raster_arg(
"r",
"raster",
63 "Name of the input raster (*.asc)",
64 true,
"",
"raster file name");
67 TCLAP::ValueArg<std::string> output_arg(
"o",
"output",
68 "Name of the output mesh (*.vtu)",
69 true,
"",
"output file name");
71 TCLAP::ValueArg<std::string> input_arg(
"i",
"input",
72 "Name of the input mesh (*.vtu)",
73 true,
"",
"input file name");
75 cmd.parse(argc, argv);
78 MPI_Init(&argc, &argv);
81 bool const create_cell_array(set_cells_arg.isSet());
82 bool const create_node_array =
83 (create_cell_array) ? set_nodes_arg.isSet() :
true;
85 std::string
const& mesh_name = input_arg.getValue();
86 std::string
const& output_name = output_arg.getValue();
87 std::string
const& raster_name = raster_arg.getValue();
89 std::unique_ptr<MeshLib::Mesh>
const mesh(
91 if (mesh->getDimension() > 2)
93 ERR(
"Method can not be applied to 3D meshes.");
100 std::unique_ptr<GeoLib::Raster>
const raster(
103 if (create_node_array)
106 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
110 ERR(
"Error assigning raster data to scalar node array");
116 INFO(
"Created node array {:s}", array_name_arg.getValue());
119 if (create_cell_array)
122 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
126 ERR(
"Error assigning raster data to scalar cell array");
132 INFO(
"Created cell array {:s}", array_name_arg.getValue());