24{
25 TCLAP::CmdLine cmd(
26 "Sets the property value of a mesh element to a given new value iff at "
27 "least one node of the element is within a polygonal region that is "
28 "given by a polygon. The documentation is available at "
29 "https://docs.opengeosys.org/docs/tools/model-preparation/"
30 "set-properties-in-polygonal-region.\n\n"
31 "OpenGeoSys-6 software, version " +
33 ".\n"
34 "Copyright (c) 2012-2026, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37 TCLAP::ValueArg<std::string> mesh_out(
38 "o", "mesh-output-file",
39 "Output. The name of the file the mesh will be written to, format "
40 "depends on "
41 "the given file name extension",
42 true, "", "OUTPUT_FILE");
43 cmd.add(mesh_out);
44 TCLAP::ValueArg<std::string> polygon_name_arg(
45 "p", "polygon-name", "name of polygon in the geometry", true, "",
46 "string");
47 cmd.add(polygon_name_arg);
48 TCLAP::ValueArg<std::string> geometry_fname(
49 "g", "geometry",
50 "Input (.gli | .gml). The name of the file containing the input "
51 "geometry",
52 true, "", "INPUT_FILE");
53 cmd.add(geometry_fname);
54 TCLAP::SwitchArg any_of_arg(
55 "", "any_of",
56 "all nodes of an element has to be inside the polygon (default "
57 "behaviour without switch) or any node of an element has to be inside "
58 "(switch is given)",
59 false);
60 cmd.add(any_of_arg);
61 TCLAP::ValueArg<char> char_property_arg(
62 "c", "char-property-value", "new property value (data type char)",
63 false, 'A', "CHAR_PROPERTY_VALUE");
64 cmd.add(char_property_arg);
65 TCLAP::ValueArg<int> int_property_arg("i", "int-property-value",
66 "new property value (data type int)",
67 false, 0, "INT_PROPERTY_VALUE");
68 cmd.add(int_property_arg);
69 TCLAP::ValueArg<std::string> property_name_arg(
70 "n", "property-name", "name of property in the mesh", false,
71 "MaterialIDs", "PROPERTY_NAME");
72 cmd.add(property_name_arg);
73 TCLAP::ValueArg<int> restrict_arg(
74 "r", "restrict-to-MaterialID",
75 "Restrict resetting the property to the material id", false, -1,
76 "RESTRICT_MATERIAL_ID");
77 cmd.add(restrict_arg);
78 TCLAP::ValueArg<std::string> mesh_in(
79 "m", "mesh-input-file",
80 "Input (.vtu | .vtk | .msh). The name of the file containing the input "
81 "mesh",
82 true, "", "INPUT_FILE");
83 cmd.add(mesh_in);
84 TCLAP::ValueArg<std::string> gmsh_path_arg(
85 "", "gmsh-path", "Input (.msh). The path to the input binary", false,
86 "", "INPUT_FILE");
87 cmd.add(gmsh_path_arg);
89 cmd.add(log_level_arg);
90 cmd.parse(argc, argv);
91
94
95
98 gmsh_path_arg.getValue());
99
101
102
103
105 if (!plys)
106 {
107 ERR(
"Could not get vector of polylines out of geometry '{:s}'.",
108 geo_name);
109 return EXIT_FAILURE;
110 }
111
112
114 plys->getElementByName(polygon_name_arg.getValue()));
115 if (!ply)
116 {
117 ERR(
"Polyline '{:s}' not found.", polygon_name_arg.getValue());
118 return EXIT_FAILURE;
119 }
120
121
122 if (!ply->isClosed())
123 {
124 ERR(
"Polyline '{:s}' is not closed, i.e. does not describe a region.",
125 polygon_name_arg.getValue());
126 return EXIT_FAILURE;
127 }
128
130
131
132 auto mesh = std::unique_ptr<MeshLib::Mesh>(
134 if (!mesh)
135 {
136
137 return EXIT_FAILURE;
138 }
139 std::string const& property_name(property_name_arg.getValue());
140
141 if (char_property_arg.isSet())
142 {
144 *mesh, polygon, property_name, char_property_arg.getValue(),
145 restrict_arg.getValue(), any_of_arg.getValue());
146 }
147
148 if (int_property_arg.isSet())
149 {
151 *mesh, polygon, property_name, int_property_arg.getValue(),
152 restrict_arg.getValue(), any_of_arg.getValue());
153 }
154
156
158
159 return EXIT_SUCCESS;
160}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const PolylineVec * getPolylineVecObj(const std::string &name) const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)