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