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