20int main(
int argc,
char* argv[])
23 "Assigns the pixel information of a raster file to a scalar array of a "
24 "specified 2D mesh. Data will be assigned to a node array by default. "
25 "Adding information to cell arrays is also possible, pixel values at "
26 "the centre of the cell will be used in this case. Note that large "
27 "differences in resolution between cell size of the mesh and pixel "
28 "size of the raster can give unexpected results. A no-data value will "
29 "be added in case of missing or transparent values.\n\n"
30 "OpenGeoSys-6 software, version " +
33 "Copyright (c) 2012-2026, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
37 TCLAP::ValueArg<double> nodata_arg(
39 "The no data value used for missing values "
44 TCLAP::SwitchArg set_cells_arg(
"c",
"cell-array",
45 "Assigns raster data to cell array");
46 cmd.add(set_cells_arg);
48 TCLAP::SwitchArg set_nodes_arg(
49 "n",
"node-array",
"Assigns raster data to node array (default)");
50 cmd.add(set_nodes_arg);
52 TCLAP::ValueArg<std::string> array_name_arg(
53 "s",
"scalar-name",
"The name of the newly created scalar array.",
true,
55 cmd.add(array_name_arg);
56 TCLAP::ValueArg<std::string> raster_arg(
57 "r",
"raster",
"Input (.asc). Name of the input raster file",
true,
"",
61 TCLAP::ValueArg<std::string> output_arg(
62 "o",
"output",
"Output (.vtu). Name of the output mesh file",
true,
"",
65 TCLAP::ValueArg<std::string> input_arg(
66 "i",
"input",
"Input (.vtu). Name of the input mesh file",
true,
"",
70 cmd.add(log_level_arg);
71 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());