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 std::vector<GeoLib::Point*> polyline_points;
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,
61 std::map<std::string, std::size_t>{});
63 std::make_unique<GeoLib::Polyline>(*geo.
getPointVec(ply_name));
68 std::vector<GeoLib::Polyline*> polylines;
69 polylines.push_back(polyline.release());
77 0.0, 0, geo_names,
false,
false);
80 auto geo_file = std::filesystem::temp_directory_path() /=
82 auto msh_file = std::filesystem::temp_directory_path() /=
88 std::string gmsh_command =
"\"" + gmsh_binary +
89 "\" -2 -algo meshadapt -format vtk -o " +
90 msh_file.string() +
" " + geo_file.string();
92 int const gmsh_return_value = std::system(gmsh_command.c_str());
93 if (gmsh_return_value != 0)
95 WARN(
"Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
99 msh_file.string(),
true );
102 WARN(
"The surface mesh could not be created.");
105 if (!(std::filesystem::remove(geo_file) &&
106 std::filesystem::remove(msh_file)))
108 WARN(
"Could not remove temporary files in createSurface.");
113 std::numeric_limits<double>::epsilon()))
115 WARN(
"The surface mesh could not be converted to a geometry.");
118 std::string merged_geometry_name(
"geometry_with_surfaces");
120 merged_geometry_name);
137 WARN(
"Error in Surface::createSurface() - Polyline is not closed.");
144 "Error in Surface::createSurface() - Polyline consists of less "
145 "than three points and therefore cannot be triangulated.");
150 auto sfc = std::make_unique<GeoLib::Surface>(line.
getPointsVec());
151 auto polygon = std::make_unique<GeoLib::Polygon>(
GeoLib::Polygon(line));
152 std::list<GeoLib::Polygon*>
const& list_of_simple_polygons =
153 polygon->computeListOfSimplePolygons();
155 for (
auto const& simple_polygon : list_of_simple_polygons)
157 std::list<GeoLib::Triangle> triangles;
161 for (
auto const& t : triangles)
163 sfc->addTriangle(t[0], t[1], t[2]);
166 if (sfc->getNumberOfTriangles() == 0)
169 "Surface::createSurface(): Triangulation does not contain any "
Definition of the EarClippingTriangulation class.
Definition of the GEOObjects class.
Definition of the Point class.
void WARN(fmt::format_string< Args... > fmt, Args &&... 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.
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
Definition of mesh to geometry conversion.
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)
Definition of readMeshFromFile function.