31int main(
int argc,
char* argv[])
34 "Extracts a 2D surface from a 3D input mesh by specifying a normal "
35 "vector and an angle. (The surface normal (0, 0, 0) will extract the "
36 "complete outer boundary of the 3D mesh.)\n"
37 "An extensive documentation can be found at "
38 "https://docs.opengeosys.org/docs/tools/meshing-submeshes/"
40 "OpenGeoSys-6 software, version " +
43 "Copyright (c) 2012-2025, OpenGeoSys Community "
44 "(http://www.opengeosys.org)",
46 TCLAP::SwitchArg use_ascii_arg(
"",
"ascii-output",
47 "If the switch is set use ascii instead of "
48 "binary format for data in the vtu output.",
50 cmd.add(use_ascii_arg);
51 TCLAP::ValueArg<double> angle_arg(
53 "tolerated angle (in degrees) between given normal and "
54 "element normal, (min = 0), (max = 360)",
57 TCLAP::ValueArg<double> z(
"z",
"z-component",
"z component of the normal",
58 false, -1.0,
"Z-COMPONENT");
60 TCLAP::ValueArg<double> y(
"y",
"y-component",
"y component of the normal",
61 false, 0,
"Y-COMPONENT");
63 TCLAP::ValueArg<double> x(
"x",
"x-component",
"x component of the normal",
64 false, 0,
"X-COMPONENT");
66 TCLAP::ValueArg<std::string> mesh_out(
67 "o",
"mesh-output-file",
68 "Output (.vtu). The name of the file the surface mesh should be "
70 false,
"",
"OUTPUT_FILE");
72 TCLAP::ValueArg<std::string> mesh_in(
73 "i",
"mesh-input-file",
74 "Input (.vtu). The name of the file containing the input mesh",
true,
78 cmd.add(log_level_arg);
79 cmd.parse(argc, argv);
85 mesh_in.getValue(),
true ));
89 ERR(
"Error reading mesh file.");
93 if (mesh->getDimension() != 3)
95 ERR(
"Surfaces can currently only be extracted from 3D meshes.");
99 INFO(
"Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
100 mesh->getNumberOfElements());
103 Eigen::Vector3d
const dir({x.getValue(), y.getValue(), z.getValue()});
104 double const angle(angle_arg.getValue());
105 std::unique_ptr<MeshLib::Mesh> surface_mesh(
111 std::string out_fname(mesh_out.getValue());
112 if (out_fname.empty())
117 auto const data_mode =
118 use_ascii_arg.getValue() ? vtkXMLWriter::Ascii : vtkXMLWriter::Binary;