23int main(
int argc,
char* argv[])
26 "Extracts a 2D surface from a 3D input mesh by specifying a normal "
27 "vector and an angle. (The surface normal (0, 0, 0) will extract the "
28 "complete outer boundary of the 3D mesh.)\n"
29 "An extensive documentation can be found at "
30 "https://docs.opengeosys.org/docs/tools/meshing-submeshes/"
32 "OpenGeoSys-6 software, version " +
35 "Copyright (c) 2012-2026, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
38 TCLAP::SwitchArg use_ascii_arg(
"",
"ascii-output",
39 "If the switch is set use ascii instead of "
40 "binary format for data in the vtu output.",
42 cmd.add(use_ascii_arg);
43 TCLAP::ValueArg<double> angle_arg(
45 "tolerated angle (in degrees) between given normal and "
46 "element normal, (min = 0), (max = 360)",
49 TCLAP::ValueArg<double> z(
"z",
"z-component",
"z component of the normal",
50 false, -1.0,
"Z-COMPONENT");
52 TCLAP::ValueArg<double> y(
"y",
"y-component",
"y component of the normal",
53 false, 0,
"Y-COMPONENT");
55 TCLAP::ValueArg<double> x(
"x",
"x-component",
"x component of the normal",
56 false, 0,
"X-COMPONENT");
58 TCLAP::ValueArg<std::string> mesh_out(
59 "o",
"mesh-output-file",
60 "Output (.vtu). The name of the file the surface mesh should be "
62 false,
"",
"OUTPUT_FILE");
64 TCLAP::ValueArg<std::string> mesh_in(
65 "i",
"mesh-input-file",
66 "Input (.vtu). The name of the file containing the input mesh",
true,
70 cmd.add(log_level_arg);
71 cmd.parse(argc, argv);
77 mesh_in.getValue(),
true ));
81 ERR(
"Error reading mesh file.");
85 if (mesh->getDimension() != 3)
87 ERR(
"Surfaces can currently only be extracted from 3D meshes.");
91 INFO(
"Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
92 mesh->getNumberOfElements());
95 Eigen::Vector3d
const dir({x.getValue(), y.getValue(), z.getValue()});
96 double const angle(angle_arg.getValue());
97 std::unique_ptr<MeshLib::Mesh> surface_mesh(
103 std::string out_fname(mesh_out.getValue());
104 if (out_fname.empty())
109 auto const data_mode =
110 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;