28int main(
int argc,
char* argv[])
31 "Reads a list of 2D unstructured mesh layers and samples them onto a "
32 "structured grid of the same extent. Note, that a large cube size may "
33 "result in an undersampling of the original structure.\nCube sizes are "
34 "defines by x/y/z-parameters. For equilateral cubes, only the "
35 "x-parameter needs to be set.\n\n"
36 "OpenGeoSys-6 software, version " +
39 "Copyright (c) 2012-2024, OpenGeoSys Community "
40 "(http://www.opengeosys.org)",
42 TCLAP::SwitchArg dilate_arg(
44 "assign mat IDs based on single nodes instead of a majority of nodes, "
45 "which can result in a slightly increased voxel grid extent",
49 TCLAP::ValueArg<double> z_arg(
"z",
"cellsize-z",
50 "edge length of cubes in z-direction (depth)",
51 false, 1000,
"floating point number");
54 TCLAP::ValueArg<double> y_arg(
55 "y",
"cellsize-y",
"edge length of cubes in y-direction (latitude)",
56 false, 1000,
"floating point number");
59 TCLAP::ValueArg<double> x_arg(
61 "edge length of cubes in x-direction (longitude) or all directions, if "
62 "y and z are not set",
63 true, 1000,
"floating point number");
66 TCLAP::ValueArg<std::string> output_arg(
67 "o",
"output",
"name of output mesh (*.vtu)",
true,
"",
"string");
70 TCLAP::ValueArg<std::string> input_arg(
72 "name of the input file list containing the paths the all input layers "
73 "in correct order from top to bottom",
76 cmd.parse(argc, argv);
80 if ((y_arg.isSet() && !z_arg.isSet()) ||
81 ((!y_arg.isSet() && z_arg.isSet())))
83 ERR(
"For equilateral cubes, only x needs to be set. For unequal "
84 "cuboids, all three edge lengths (x/y/z) need to be specified.");
88 double const x_size = x_arg.getValue();
89 double const y_size = (y_arg.isSet()) ? y_arg.getValue() : x_arg.getValue();
90 double const z_size = (z_arg.isSet()) ? z_arg.getValue() : x_arg.getValue();
91 std::array<double, 3>
const cellsize = {x_size, y_size, z_size};
93 std::string
const input_name = input_arg.getValue();
94 std::string
const output_name = output_arg.getValue();
96 if (layer_names.size() < 2)
98 ERR(
"At least two layers are required to create a 3D Mesh");
102 std::vector<std::unique_ptr<MeshLib::Mesh>> layers;
103 layers.reserve(layer_names.size());
104 constexpr double minval = std::numeric_limits<double>::max();
105 constexpr double maxval = std::numeric_limits<double>::lowest();
106 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
110 for (
auto const& layer : layer_names)
115 ERR(
"Input layer '{:s}' not found. Aborting...", layer);
118 layers.emplace_back(mesh);
120 std::vector<MeshLib::Mesh const*> layers_ptr;
121 std::transform(std::begin(layers), std::end(layers),
122 std::back_inserter(layers_ptr),
123 [](
auto const& layer) {
return layer.get(); });
124 bool const dilate = dilate_arg.getValue();
129 ERR(
"The VoxelGrid could not be created.");