25int main(
int argc,
char* argv[])
28 "Assigns the pixel information of a raster file to a scalar array of a "
29 "specified 2D mesh. Data will be assigned to a node array by default. "
30 "Adding information to cell arrays is also possible, pixel values at "
31 "the centre of the cell will be used in this case. Note that large "
32 "differences in resolution between cell size of the mesh and pixel "
33 "size of the raster can give unexpected results. A no-data value will "
34 "be added in case of missing or transparent values.\n\n"
35 "OpenGeoSys-6 software, version " +
38 "Copyright (c) 2012-2024, OpenGeoSys Community "
39 "(http://www.opengeosys.org)",
42 TCLAP::ValueArg<double> nodata_arg(
43 "e",
"nodata",
"The no data value used for missing values",
false, 0,
47 TCLAP::SwitchArg set_cells_arg(
"c",
"cell-array",
48 "Assigns raster data to cell array");
49 cmd.add(set_cells_arg);
51 TCLAP::SwitchArg set_nodes_arg(
52 "n",
"node-array",
"Assigns raster data to node array (default)");
53 cmd.add(set_nodes_arg);
55 TCLAP::ValueArg<std::string> array_name_arg(
56 "s",
"scalar-name",
"The name of the newly created scalar array.",
true,
57 "",
"scalar array name");
58 cmd.add(array_name_arg);
59 TCLAP::ValueArg<std::string> raster_arg(
"r",
"raster",
60 "Name of the input raster (*.asc)",
61 true,
"",
"raster file name");
64 TCLAP::ValueArg<std::string> output_arg(
"o",
"output",
65 "Name of the output mesh (*.vtu)",
66 true,
"",
"output file name");
68 TCLAP::ValueArg<std::string> input_arg(
"i",
"input",
69 "Name of the input mesh (*.vtu)",
70 true,
"",
"input file name");
72 cmd.parse(argc, argv);
76 bool const create_cell_array(set_cells_arg.isSet());
77 bool const create_node_array =
78 (create_cell_array) ? set_nodes_arg.isSet() :
true;
80 std::string
const& mesh_name = input_arg.getValue();
81 std::string
const& output_name = output_arg.getValue();
82 std::string
const& raster_name = raster_arg.getValue();
84 std::unique_ptr<MeshLib::Mesh>
const mesh(
86 if (mesh->getDimension() > 2)
88 ERR(
"Method can not be applied to 3D meshes.");
92 std::unique_ptr<GeoLib::Raster>
const raster(
95 if (create_node_array)
98 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
102 ERR(
"Error assigning raster data to scalar node array");
105 INFO(
"Created node array {:s}", array_name_arg.getValue());
108 if (create_cell_array)
111 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
115 ERR(
"Error assigning raster data to scalar cell array");
118 INFO(
"Created cell array {:s}", array_name_arg.getValue());