35 std::string
const& geometry_name,
36 std::string
const& gmsh_binary)
40 WARN(
"Error in createSurface() - Polyline is not closed.");
47 "Error in createSurface() - Polyline consists of less "
48 "than three points and therefore cannot be triangulated.");
53 auto polyline_points = std::make_unique<std::vector<GeoLib::Point*>>();
56 std::transform(ply_points.begin(), ply_points.end(),
57 std::back_inserter(*polyline_points),
58 [](
auto const* p) { return new GeoLib::Point(*p); });
59 std::string ply_name =
"temporary_polyline_name";
60 geo.addPointVec(std::move(polyline_points), ply_name);
62 std::make_unique<GeoLib::Polyline>(*geo.getPointVec(ply_name));
67 auto polylines = std::make_unique<std::vector<GeoLib::Polyline*>>();
68 polylines->push_back(polyline.release());
69 geo.addPolylineVec(std::move(polylines), ply_name);
72 auto const geo_names = geo.getGeometryNames();
75 0.0, 0, geo_names,
false,
false);
84 std::string gmsh_command =
"\"" + gmsh_binary +
85 "\" -2 -algo meshadapt -format vtk -o " +
86 msh_file.string() +
" " + geo_file.string();
88 int const gmsh_return_value = std::system(gmsh_command.c_str());
89 if (gmsh_return_value != 0)
91 WARN(
"Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
97 WARN(
"The surface mesh could not be created.");
100 if (!(fs::remove(geo_file) && fs::remove(msh_file)))
102 WARN(
"Could not remove temporary files in createSurface.");
107 std::numeric_limits<double>::epsilon()))
109 WARN(
"The surface mesh could not be converted to a geometry.");
112 std::string merged_geometry_name(
"geometry_with_surfaces");
114 merged_geometry_name);
131 WARN(
"Error in Surface::createSurface() - Polyline is not closed.");
138 "Error in Surface::createSurface() - Polyline consists of less "
139 "than three points and therefore cannot be triangulated.");
144 auto sfc = std::make_unique<GeoLib::Surface>(line.
getPointsVec());
145 auto polygon = std::make_unique<GeoLib::Polygon>(
GeoLib::Polygon(line));
146 std::list<GeoLib::Polygon*>
const& list_of_simple_polygons =
147 polygon->computeListOfSimplePolygons();
149 for (
auto const& simple_polygon : list_of_simple_polygons)
151 std::list<GeoLib::Triangle> triangles;
155 for (
auto const& t : triangles)
157 sfc->addTriangle(t[0], t[1], t[2]);
160 if (sfc->getNumberOfTriangles() == 0)
163 "Surface::createSurface(): Triangulation does not contain any "
Definition of the EarClippingTriangulation class.
Definition of the GEOObjects class.
Definition of the Point class.
void WARN(char const *fmt, Args const &... args)
Definition of the Mesh class.
Definition of the Polygon class.
Definition of the PolyLine class.
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.
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 i) const
std::size_t getNumberOfPoints() const
std::vector< Point * > const & getPointsVec() const
Definition of mesh to geometry conversion.
int writeStringToFile(std::string 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 convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)
Definition of readMeshFromFile function.