29int main(
int argc,
char* argv[])
32 "Reads a list of 2D unstructured mesh layers and samples them onto a "
33 "structured grid of the same extent. Note, that a large cube size may "
34 "result in an undersampling of the original structure.\nCube sizes are "
35 "defines by x/y/z-parameters. For equilateral cubes, only the "
36 "x-parameter needs to be set.\n\n"
37 "OpenGeoSys-6 software, version " +
40 "Copyright (c) 2012-2025, OpenGeoSys Community "
41 "(http://www.opengeosys.org)",
43 TCLAP::SwitchArg dilate_arg(
45 "assign mat IDs based on single nodes instead of a majority of nodes, "
46 "which can result in a slightly increased voxel grid extent",
50 TCLAP::ValueArg<double> z_arg(
52 "edge length of cubes in z-direction (depth), "
54 false, 1000,
"CELLSIZE-Z");
57 TCLAP::ValueArg<double> y_arg(
59 "edge length of cubes in y-direction (latitude), "
61 false, 1000,
"CELLSIZE-Y");
64 TCLAP::ValueArg<double> x_arg(
66 "edge length of cubes in x-direction (longitude) or all directions, if "
67 "y and z are not set, (min = 0)",
68 true, 1000,
"CELLSIZE-X");
71 TCLAP::ValueArg<std::string> output_arg(
72 "o",
"output",
"Output (.vtu). Name of output mesh file",
true,
"",
76 TCLAP::ValueArg<std::string> input_arg(
78 "Input (.vtu). Name of the input file list containing the paths the "
80 "in correct order from top to bottom",
81 true,
"",
"INPUT_FILE_LIST");
85 cmd.add(log_level_arg);
87 cmd.parse(argc, argv);
92 if ((y_arg.isSet() && !z_arg.isSet()) ||
93 ((!y_arg.isSet() && z_arg.isSet())))
95 ERR(
"For equilateral cubes, only x needs to be set. For unequal "
96 "cuboids, all three edge lengths (x/y/z) need to be specified.");
100 double const x_size = x_arg.getValue();
101 double const y_size = (y_arg.isSet()) ? y_arg.getValue() : x_arg.getValue();
102 double const z_size = (z_arg.isSet()) ? z_arg.getValue() : x_arg.getValue();
103 std::array<double, 3>
const cellsize = {x_size, y_size, z_size};
105 std::string
const input_name = input_arg.getValue();
106 std::string
const output_name = output_arg.getValue();
108 if (layer_names.size() < 2)
110 ERR(
"At least two layers are required to create a 3D Mesh");
114 std::vector<std::unique_ptr<MeshLib::Mesh>> layers;
115 layers.reserve(layer_names.size());
116 constexpr double minval = std::numeric_limits<double>::max();
117 constexpr double maxval = std::numeric_limits<double>::lowest();
118 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
122 for (
auto const& layer : layer_names)
127 ERR(
"Input layer '{:s}' not found. Aborting...", layer);
130 layers.emplace_back(mesh);
132 std::vector<MeshLib::Mesh const*> layers_ptr;
133 std::transform(std::begin(layers), std::end(layers),
134 std::back_inserter(layers_ptr),
135 [](
auto const& layer) {
return layer.get(); });
136 bool const dilate = dilate_arg.getValue();
141 ERR(
"The VoxelGrid could not be created.");