27 std::string
const& geometry_name,
28 std::string
const& gmsh_binary)
32 WARN(
"Error in createSurface() - Polyline is not closed.");
39 "Error in createSurface() - Polyline consists of less "
40 "than three points and therefore cannot be triangulated.");
45 std::vector<GeoLib::Point*> polyline_points;
48 std::transform(ply_points.begin(), ply_points.end(),
49 std::back_inserter(polyline_points),
50 [](
auto const* p) { return new GeoLib::Point(*p); });
51 std::string ply_name =
"temporary_polyline_name";
52 geo.
addPointVec(std::move(polyline_points), ply_name,
53 std::map<std::string, std::size_t>{});
55 std::make_unique<GeoLib::Polyline>(*geo.
getPointVec(ply_name));
60 std::vector<GeoLib::Polyline*> polylines;
61 polylines.push_back(polyline.release());
69 0.0, 0, geo_names,
false,
false);
72 auto geo_file = std::filesystem::temp_directory_path() /=
74 auto msh_file = std::filesystem::temp_directory_path() /=
80 std::string gmsh_command =
"\"" + gmsh_binary +
81 "\" -2 -algo meshadapt -format vtk -o " +
82 msh_file.string() +
" " + geo_file.string();
84 int const gmsh_return_value = std::system(gmsh_command.c_str());
85 if (gmsh_return_value != 0)
87 WARN(
"Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
91 msh_file.string(),
true );
94 WARN(
"The surface mesh could not be created.");
97 if (!(std::filesystem::remove(geo_file) &&
98 std::filesystem::remove(msh_file)))
100 WARN(
"Could not remove temporary files in createSurface.");
105 std::numeric_limits<double>::epsilon()))
107 WARN(
"The surface mesh could not be converted to a geometry.");
110 std::string merged_geometry_name(
"geometry_with_surfaces");
112 merged_geometry_name);
129 WARN(
"Error in Surface::createSurface() - Polyline is not closed.");
136 "Error in Surface::createSurface() - Polyline consists of less "
137 "than three points and therefore cannot be triangulated.");
142 auto sfc = std::make_unique<GeoLib::Surface>(line.
getPointsVec());
143 auto polygon = std::make_unique<GeoLib::Polygon>(
GeoLib::Polygon(line));
144 std::list<GeoLib::Polygon*>
const& list_of_simple_polygons =
145 polygon->computeListOfSimplePolygons();
147 for (
auto const& simple_polygon : list_of_simple_polygons)
149 std::list<GeoLib::Triangle> triangles;
153 for (
auto const& t : triangles)
155 sfc->addTriangle(t[0], t[1], t[2]);
158 if (sfc->getNumberOfTriangles() == 0)
161 "Surface::createSurface(): Triangulation does not contain any "
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::string writeToString()
Writes the object to a string.
Reads and writes GMSH-files to and from OGS data structures.
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
const std::vector< Point * > * getPointVec(const std::string &name) const
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
void renameGeometry(std::string const &old_name, std::string const &new_name)
bool removePointVec(const std::string &name)
bool removeSurfaceVec(const std::string &name)
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
bool removePolylineVec(const std::string &name)
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::size_t getPointID(std::size_t const i) const
std::size_t getNumberOfPoints() const
std::vector< Point * > const & getPointsVec() const
std::map< std::string, std::size_t > NameIdMap
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
std::string randomString(std::size_t const length)
Returns a random string of the given length containing just a-z,A-Z,0-9.
@ FixedMeshDensity
set the parameter with a fixed value
bool createSurface(GeoLib::Polyline const &ply, GeoLib::GEOObjects &geometries, std::string const &geometry_name, std::string const &gmsh_binary)
std::unique_ptr< GeoLib::Surface > createSurfaceWithEarClipping(GeoLib::Polyline const &line)
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)