27 "Converts an ASCII raster file (*.asc) into a 2D triangle- or "
28 "quad-mesh. Pixel values can be interpreted as elevation of mesh nodes "
29 "or as scalar values for mesh elements.\nIt is highly recommended to "
30 "create triangle meshes when interpreting pixel values as elevation, "
31 "as it is likely that the resulting mesh will otherwise contain "
32 "deformed (i.e. non-planar) quad-elements.\n\n"
33 "OpenGeoSys-6 software, version " +
36 "Copyright (c) 2012-2021, OpenGeoSys Community "
37 "(http://www.opengeosys.org)",
39 TCLAP::ValueArg<std::string> array_name_arg(
41 "Name of the scalar array. Only required if assigning pixel values to "
42 "cell data has been selected (default name is 'Values').",
43 false,
"",
"name of data array");
44 cmd.add(array_name_arg);
45 std::vector<std::string> pixel_vals{
"elevation",
"materials",
"scalar"};
46 TCLAP::ValuesConstraint<std::string> pixel_val_options(pixel_vals);
47 TCLAP::ValueArg<std::string> arg_pixel_type(
49 "The choice how pixel values should be interpreted by the software: "
50 "'elevation' adjusts z-coordinates; 'materials' sets (integer) "
51 "material IDs; 'scalar' creates a (floating-point) array associated "
52 "with mesh elements.",
53 true,
"", &pixel_val_options);
54 cmd.add(arg_pixel_type);
55 std::vector<std::string> allowed_elems{
"tri",
"quad"};
56 TCLAP::ValuesConstraint<std::string> allowed_elem_vals(allowed_elems);
57 TCLAP::ValueArg<std::string> arg_elem_type(
58 "e",
"elem-type",
"The element type used in the resulting OGS mesh.",
59 true,
"", &allowed_elem_vals);
60 cmd.add(arg_elem_type);
61 TCLAP::ValueArg<std::string> output_arg(
"o",
"output",
62 "Name of the output mesh (*.vtu)",
63 true,
"",
"output file name");
65 TCLAP::ValueArg<std::string> input_arg(
"i",
"input",
66 "Name of the input raster (*.asc)",
67 true,
"",
"input file name");
69 cmd.parse(argc, argv);
71 std::string
const input_name = input_arg.getValue().c_str();
72 std::string
const output_name = output_arg.getValue().c_str();
74 std::unique_ptr<GeoLib::Raster>
const raster(
81 if (arg_pixel_type.getValue() ==
"elevation")
83 else if (arg_pixel_type.getValue() ==
"materials")
88 std::string array_name =
"Values";
90 array_name_arg.isSet())
91 array_name = array_name_arg.getValue().c_str();
93 array_name =
"MaterialIDs";
96 *raster, elem_type, intensity_type, array_name));
100 ERR(
"Conversion failed.");
105 vtu.writeToFile(output_name);
void ERR(char const *fmt, Args const &... args)
static GeoLib::Raster * getRasterFromASCFile(std::string const &fname)
Reads an ArcGis ASC raster file.
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
static std::unique_ptr< MeshLib::Mesh > convert(GeoLib::Raster const &raster, MeshElemType elem_type, UseIntensityAs intensity_type, std::string const &array_name="Colour")
GITINFOLIB_EXPORT const std::string ogs_version
UseIntensityAs
Selection of possible interpretations for intensities.
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.