23int main(
int argc,
char* argv[])
26 "Reads a list of 2D unstructured mesh layers and samples them onto a "
27 "structured grid of the same extent. Note, that a large cube size may "
28 "result in an undersampling of the original structure.\nCube sizes are "
29 "defines by x/y/z-parameters. For equilateral cubes, only the "
30 "x-parameter needs to be set.\n\n"
31 "OpenGeoSys-6 software, version " +
34 "Copyright (c) 2012-2026, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37 TCLAP::SwitchArg dilate_arg(
39 "assign mat IDs based on single nodes instead of a majority of nodes, "
40 "which can result in a slightly increased voxel grid extent",
44 TCLAP::ValueArg<double> z_arg(
46 "edge length of cubes in z-direction (depth), "
48 false, 1000,
"CELLSIZE-Z");
51 TCLAP::ValueArg<double> y_arg(
53 "edge length of cubes in y-direction (latitude), "
55 false, 1000,
"CELLSIZE-Y");
58 TCLAP::ValueArg<double> x_arg(
60 "edge length of cubes in x-direction (longitude) or all directions, if "
61 "y and z are not set, (min = 0)",
62 true, 1000,
"CELLSIZE-X");
65 TCLAP::ValueArg<std::string> output_arg(
66 "o",
"output",
"Output (.vtu). Name of output mesh file",
true,
"",
70 TCLAP::ValueArg<std::string> input_arg(
72 "Input (.vtu). Name of the input file list containing the paths the "
74 "in correct order from top to bottom",
75 true,
"",
"INPUT_FILE_LIST");
79 cmd.add(log_level_arg);
81 cmd.parse(argc, argv);
86 if ((y_arg.isSet() && !z_arg.isSet()) ||
87 ((!y_arg.isSet() && z_arg.isSet())))
89 ERR(
"For equilateral cubes, only x needs to be set. For unequal "
90 "cuboids, all three edge lengths (x/y/z) need to be specified.");
94 double const x_size = x_arg.getValue();
95 double const y_size = (y_arg.isSet()) ? y_arg.getValue() : x_arg.getValue();
96 double const z_size = (z_arg.isSet()) ? z_arg.getValue() : x_arg.getValue();
97 std::array<double, 3>
const cellsize = {x_size, y_size, z_size};
99 std::string
const input_name = input_arg.getValue();
100 std::string
const output_name = output_arg.getValue();
102 if (layer_names.size() < 2)
104 ERR(
"At least two layers are required to create a 3D Mesh");
108 std::vector<std::unique_ptr<MeshLib::Mesh>> layers;
109 layers.reserve(layer_names.size());
110 constexpr double minval = std::numeric_limits<double>::max();
111 constexpr double maxval = std::numeric_limits<double>::lowest();
112 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
116 for (
auto const& layer : layer_names)
121 ERR(
"Input layer '{:s}' not found. Aborting...", layer);
124 layers.emplace_back(mesh);
126 std::vector<MeshLib::Mesh const*> layers_ptr;
127 std::transform(std::begin(layers), std::end(layers),
128 std::back_inserter(layers_ptr),
129 [](
auto const& layer) {
return layer.get(); });
130 bool const dilate = dilate_arg.getValue();
135 ERR(
"The VoxelGrid could not be created.");