14 #include <tclap/CmdLine.h>
27 WARN(
"Given polyline is not closed. Close polyline now?");
28 WARN(
"Enter (Y)es for closing the line or (N)o for abort and press ENTER.");
34 int main(
int argc,
char* argv[])
37 "Triangulates the specified polyline in the given geometry file.\n\n"
38 "OpenGeoSys-6 software, version " +
41 "Copyright (c) 2012-2021, OpenGeoSys Community "
42 "(http://www.opengeosys.org)",
44 TCLAP::ValueArg<std::string> input_arg(
45 "i",
"input",
"GML input file (*.gml)",
true,
"",
"string");
46 TCLAP::ValueArg<std::string> output_arg(
47 "o",
"output",
"GML output file (*.gml)",
true,
"",
"string");
48 TCLAP::ValueArg<std::string> name_arg(
49 "n",
"name",
"Name of polyline in given file",
true,
"",
"string");
50 TCLAP::ValueArg<std::string> gmsh_path_arg(
"g",
"gmsh-path",
51 "the path to the gmsh binary",
52 false,
"",
"path as string");
56 cmd.add(gmsh_path_arg);
57 cmd.parse(argc, argv);
59 std::string
const& file_name(input_arg.getValue());
60 std::string
const& polyline_name(name_arg.getValue());
68 ERR(
"Failed to load geometry file.");
72 catch (std::runtime_error
const& err)
74 ERR(
"Failed to read file `{:s}'.", file_name);
75 ERR(
"{:s}", err.what());
88 ERR(
"No polyline found with name '{:s}'. Aborting...", polyline_name);
95 ERR(
"Polyline is not coplanar, no unambiguous triangulation possible. "
103 while (input !=
"y" && input !=
"Y" && input !=
"n" && input !=
"N")
108 if (input ==
"y" || input ==
"Y")
111 INFO(
"Polyline closed.");
119 INFO(
"Creating a surface by triangulation of the polyline ...");
121 gmsh_path_arg.getValue()))
127 WARN(
"\t Creating a surface by triangulation of the polyline failed.");
130 std::size_t
const sfc_id = geo_objects.
getSurfaceVec(geo_name)->size() - 1;
131 std::string
const surface_name(polyline_name +
"_surface");
132 for (std::size_t i = 1;; ++i)
134 std::string
const new_surface_name =
135 (i > 1) ? (surface_name + std::to_string(i)) : surface_name;
Definition of analytical geometry functions.
Definition of the BoostXmlGmlInterface class.
Definition of the GEOObjects class.
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
void WARN(char const *fmt, Args const &... args)
Definition of the PolyLine class.
int main(int argc, char *argv[])
std::string output_question()
std::string writeToString()
Writes the object to a string.
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
SurfaceVec * getSurfaceVecObj(const std::string &name)
Returns the surface vector with the given name.
const PolylineVec * getPolylineVecObj(const std::string &name) const
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
virtual void setNameForElement(std::size_t id, std::string const &name)
Sets the given name for the element of the given ID.
const T * getElementByName(const std::string &name) const
Returns an element with the given name.
int writeStringToFile(std::string content, std::filesystem::path const &file_path)
bool createSurface(GeoLib::Polyline const &ply, GeoLib::GEOObjects &geometries, std::string const &geometry_name, std::string const &gmsh_binary)
GITINFOLIB_EXPORT const std::string ogs_version