26int main(
int argc,
char* argv[])
29 "Creates a boundary representation for a layered 3D mesh in "
30 "*.smesh-format. This boundary representation can be used with the "
31 "TetGen Tetrahedral Mesh Generator to create 3D meshes of the given "
32 "geometry at arbitrary resolutions and with varying properties. "
33 "Details on command line switches and possible parametrisation can be "
34 "found in the TetGen User's Manual. Supported raster formats are "
35 "ArcGIS ascii rasters (*.asc), Surfer Grids (*.grd) and XYZ raster "
37 "Only input meshes consisting of line and triangle elements are "
38 "currently supported as mapping of quads might result in invalid mesh "
40 "OpenGeoSys-6 software, version " +
43 "Copyright (c) 2012-2026, OpenGeoSys Community "
44 "(http://www.opengeosys.org)",
47 TCLAP::SwitchArg use_ascii_arg(
"",
"ascii_output",
48 "Write VTU output in ASCII format.");
49 cmd.add(use_ascii_arg);
51 double min_thickness(std::numeric_limits<double>::epsilon());
52 TCLAP::ValueArg<double> min_thickness_arg(
54 "The minimum thickness of a layer to be integrated at any given "
56 false, min_thickness,
"MIN_THICKNESS");
57 cmd.add(min_thickness_arg);
59 TCLAP::ValueArg<std::string> raster_path_arg(
61 "Input (.vtu). An ascii-file containing a list of raster files, "
64 true,
"",
"INPUT_FILE_LIST");
65 cmd.add(raster_path_arg);
67 TCLAP::ValueArg<std::string> mesh_out_arg(
68 "o",
"output-mesh-file",
69 "Output (.smesh). The file name of the resulting 3D mesh",
true,
"",
71 cmd.add(mesh_out_arg);
73 TCLAP::ValueArg<std::string> mesh_arg(
74 "i",
"input-mesh-file",
75 "Input (.vtu | .msh). The file name of the 2D input mesh",
true,
"",
80 cmd.add(log_level_arg);
82 cmd.parse(argc, argv);
87 if (min_thickness_arg.isSet())
89 min_thickness = min_thickness_arg.getValue();
90 if (min_thickness < 0)
92 ERR(
"Minimum layer thickness must be non-negative value.");
97 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
99 mesh_arg.getValue(),
true ));
102 ERR(
"Error reading mesh '{:s}'.", mesh_arg.getValue());
105 if (sfc_mesh->getDimension() != 2)
107 ERR(
"Input mesh must be a 2D mesh.");
112 std::vector<std::string> raster_paths =
114 if (raster_paths.size() < 2)
116 ERR(
"At least two raster files needed to create 3D mesh.");
119 std::reverse(raster_paths.begin(), raster_paths.end());
121 std::string output_name(mesh_out_arg.getValue());
124 output_name.append(
".smesh");
131 if (!lv.
createLayers(*sfc_mesh, *rasters, min_thickness))
133 ERR(
"Creating the layers was erroneous.");
139 ERR(
"The raster files are not accessible.");
142 std::unique_ptr<MeshLib::Mesh> tg_mesh =
143 lv.
getMesh(
"BoundaryRepresentation");
144 if (tg_mesh !=
nullptr)
149 INFO(
"Smesh was successfully written.");
153 ERR(
"The tetgen-smesh could not be created.");