31int main(
int argc,
char* argv[])
34 "Reads a list of 2D unstructured mesh layers and samples them onto a "
35 "structured grid of the same extent. Note, that a large cube size may "
36 "result in an undersampling of the original structure.\nCube sizes are "
37 "defines by x/y/z-parameters. For equilateral cubes, only the "
38 "x-parameter needs to be set.\n\n"
39 "OpenGeoSys-6 software, version " +
42 "Copyright (c) 2012-2024, OpenGeoSys Community "
43 "(http://www.opengeosys.org)",
45 TCLAP::SwitchArg dilate_arg(
47 "assign mat IDs based on single nodes instead of a majority of nodes, "
48 "which can result in a slightly increased voxel grid extent",
52 TCLAP::ValueArg<double> z_arg(
"z",
"cellsize-z",
53 "edge length of cubes in z-direction (depth)",
54 false, 1000,
"floating point number");
57 TCLAP::ValueArg<double> y_arg(
58 "y",
"cellsize-y",
"edge length of cubes in y-direction (latitude)",
59 false, 1000,
"floating point number");
62 TCLAP::ValueArg<double> x_arg(
64 "edge length of cubes in x-direction (longitude) or all directions, if "
65 "y and z are not set",
66 true, 1000,
"floating point number");
69 TCLAP::ValueArg<std::string> output_arg(
70 "o",
"output",
"name of output mesh (*.vtu)",
true,
"",
"string");
73 TCLAP::ValueArg<std::string> input_arg(
75 "name of the input file list containing the paths the all input layers "
76 "in correct order from top to bottom",
79 cmd.parse(argc, argv);
82 MPI_Init(&argc, &argv);
85 if ((y_arg.isSet() && !z_arg.isSet()) ||
86 ((!y_arg.isSet() && z_arg.isSet())))
88 ERR(
"For equilateral cubes, only x needs to be set. For unequal "
89 "cuboids, all three edge lengths (x/y/z) need to be specified.");
96 double const x_size = x_arg.getValue();
97 double const y_size = (y_arg.isSet()) ? y_arg.getValue() : x_arg.getValue();
98 double const z_size = (z_arg.isSet()) ? z_arg.getValue() : x_arg.getValue();
99 std::array<double, 3>
const cellsize = {x_size, y_size, z_size};
101 std::string
const input_name = input_arg.getValue();
102 std::string
const output_name = output_arg.getValue();
104 if (layer_names.size() < 2)
106 ERR(
"At least two layers are required to create a 3D Mesh");
113 std::vector<std::unique_ptr<MeshLib::Mesh>> layers;
114 layers.reserve(layer_names.size());
115 constexpr double minval = std::numeric_limits<double>::max();
116 constexpr double maxval = std::numeric_limits<double>::lowest();
117 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
121 for (
auto const& layer : layer_names)
126 ERR(
"Input layer '{:s}' not found. Aborting...", layer);
132 layers.emplace_back(mesh);
134 std::vector<MeshLib::Mesh const*> layers_ptr;
135 std::transform(std::begin(layers), std::end(layers),
136 std::back_inserter(layers_ptr),
137 [](
auto const& layer) {
return layer.get(); });
138 bool const dilate = dilate_arg.getValue();
143 ERR(
"The VoxelGrid could not be created.");