25int main(
int argc,
char* argv[])
28 "Converts an ASCII raster file (*.asc) into a 2D triangle- or "
29 "quad-mesh. Pixel values can be interpreted as elevation of mesh nodes "
30 "or as scalar values for mesh elements.\nIt is highly recommended to "
31 "create triangle meshes when interpreting pixel values as elevation, "
32 "as it is likely that the resulting mesh will otherwise contain "
33 "deformed (i.e. non-planar) quad-elements.\n\n"
34 "OpenGeoSys-6 software, version " +
37 "Copyright (c) 2012-2024, OpenGeoSys Community "
38 "(http://www.opengeosys.org)",
40 TCLAP::ValueArg<std::string> array_name_arg(
42 "Name of the scalar array. Only required if assigning pixel values to "
43 "cell data has been selected (default name is 'Values').",
44 false,
"",
"name of data array");
45 cmd.add(array_name_arg);
46 std::vector<std::string> pixel_vals{
"elevation",
"materials",
"scalar"};
47 TCLAP::ValuesConstraint<std::string> pixel_val_options(pixel_vals);
48 TCLAP::ValueArg<std::string> arg_pixel_type(
50 "The choice how pixel values should be interpreted by the software: "
51 "'elevation' adjusts z-coordinates; 'materials' sets (integer) "
52 "material IDs; 'scalar' creates a (floating-point) array associated "
53 "with mesh elements.",
54 true,
"", &pixel_val_options);
55 cmd.add(arg_pixel_type);
56 std::vector<std::string> allowed_elems{
"tri",
"quad"};
57 TCLAP::ValuesConstraint<std::string> allowed_elem_vals(allowed_elems);
58 TCLAP::ValueArg<std::string> arg_elem_type(
59 "e",
"elem-type",
"The element type used in the resulting OGS mesh.",
60 true,
"", &allowed_elem_vals);
61 cmd.add(arg_elem_type);
62 TCLAP::ValueArg<std::string> output_arg(
"o",
"output",
63 "Name of the output mesh (*.vtu)",
64 true,
"",
"output file name");
66 TCLAP::ValueArg<std::string> input_arg(
"i",
"input",
67 "Name of the input raster (*.asc)",
68 true,
"",
"input file name");
70 cmd.parse(argc, argv);
74 std::string
const input_name = input_arg.getValue().c_str();
75 std::string
const output_name = output_arg.getValue().c_str();
77 std::unique_ptr<GeoLib::Raster>
const raster(
84 if (arg_pixel_type.getValue() ==
"elevation")
86 else if (arg_pixel_type.getValue() ==
"materials")
91 std::string array_name =
"Values";
93 array_name_arg.isSet())
94 array_name = array_name_arg.getValue().c_str();
96 array_name =
"MaterialIDs";
98 std::unique_ptr<MeshLib::Mesh>
const mesh(
104 ERR(
"Conversion failed.");