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