38 std::vector<GMSHPoint*>
const& points)
40 for (
auto const*
const point : points)
53 double const pnt_density,
double const station_density,
54 std::size_t
const max_pnts_per_leaf,
55 std::vector<std::string>
const& selected_geometries,
bool const rotate,
56 bool const keep_preprocessed_geometry)
60 _selected_geometries(selected_geometries),
62 _keep_preprocessed_geometry(keep_preprocessed_geometry)
64 switch (mesh_density_algorithm)
68 std::make_unique<GMSH::GMSHFixedMeshDensity>(pnt_density);
72 std::make_unique<GMSH::GMSHAdaptiveMeshDensity>(
73 pnt_density, station_density, max_pnts_per_leaf);
89 out <<
"// GMSH input file created by OpenGeoSys "
98 DBUG(
"GMSHInterface::writeGMSHInputFile(): get data from GEOObjects.");
120 auto* merged_pnts(
const_cast<std::vector<GeoLib::Point*>*
>(
124 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not found any points.");
139 for (
auto pnt : *merged_pnts)
145 std::vector<GeoLib::Polyline*>
const* merged_plys(
147 DBUG(
"GMSHInterface::writeGMSHInputFile(): Obtained data.");
151 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not find any polylines.");
159 pnt_vec, *(
const_cast<std::vector<GeoLib::Polyline*>*
>(merged_plys)));
161 std::vector<GeoLib::Polyline*> polygons;
164 for (
auto polyline : *merged_plys)
166 if (!polyline->isClosed())
172 if (polygons.empty())
174 OGS_FATAL(
"GMSHInterface::writeGMSHInputFile(): no polygons found.");
180 polygons.begin(), polygons.end(),
182 [
this](
auto const& polygon)
184 return new GMSH::GMSHPolygonTree(
185 dynamic_cast<GeoLib::PolygonWithSegmentMarker*>(polygon),
186 nullptr, _geo_objs, _gmsh_geo_name, *_mesh_density_strategy);
189 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
190 "detected {:d} polygons.",
195 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
196 "calculated {:d} polygon trees.",
202 polygon_tree->markSharedSegments();
209 std::vector<GeoLib::Point*> gmsh_stations{};
215 for (
auto* station : *stations)
224 if ((*it)->insertStation(gmsh_stations.back()))
233 if (!gmsh_stations.empty())
239 for (
auto polyline : *merged_plys)
241 if (!polyline->isClosed())
245 auto polyline_with_segment_marker =
247 polygon_tree->insertPolyline(polyline_with_segment_marker);
255 polygon_tree->initMeshDensityStrategy();
259 const std::size_t n_merged_pnts(merged_pnts->size());
261 for (std::size_t k(0); k < n_merged_pnts; k++)
270 std::stringstream error_messages;
271 error_messages.precision(std::numeric_limits<double>::max_digits10);
272 for (std::size_t k = 0; k <
_gmsh_pnts.size(); ++k)
277 <<
"The point at (" << *(*merged_pnts)[k]
278 <<
") is not part of a polyline, and won't be used in the "
279 "meshing as a constraint. If you want to include it in the "
280 "mesh please create a observation/measurement station for "
281 "the point and include it additional in the meshing "
285 auto const error_message = error_messages.str();
286 if (!error_message.empty())
300 polygon_tree->writeSubPolygonsAsLineConstraints(
_n_lines,
304 polygon_tree->writeAdditionalPointData(pnt_id_offset,
_n_plane_sfc - 1,
Definition of analytical geometry functions.
Definition of the GEOObjects class.
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Polygon class.
Definition of the PolylineWithSegmentMarker class.
Definition of the Station class.
std::ostringstream out
The stream to write to.
~GMSHInterface() override
bool _write_physical_groups
GMSHInterface(GeoLib::GEOObjects &geo_objs, bool include_stations_as_constraints, GMSH::MeshDensityAlgorithm mesh_density_algorithm, double pnt_density, double station_density, std::size_t max_pnts_per_leaf, std::vector< std::string > const &selected_geometries, bool rotate, bool keep_preprocessed_geometry)
std::string _gmsh_geo_name
bool _keep_preprocessed_geometry
std::unique_ptr< GMSH::GMSHMeshDensityStrategy > _mesh_density_strategy
Eigen::Matrix3d _inverse_rot_mat
std::vector< GMSH::GMSHPoint * > _gmsh_pnts
int writeGMSHInputFile(std::ostream &out)
std::vector< std::string > const & _selected_geometries
GeoLib::GEOObjects & _geo_objs
bool write() override
Writes the object to the internal stream. This method must be implemented by a subclass....
std::list< GMSH::GMSHPolygonTree * > _polygon_tree_list
Container class for geometric objects.
const std::vector< Point * > * getPointVec(const std::string &name) const
const PointVec * getPointVecObj(const std::string &name) const
bool removePointVec(const std::string &name)
bool removeSurfaceVec(const std::string &name)
void addStationVec(std::vector< Point * > &&stations, std::string &name)
Adds a vector of stations with the given name and colour to GEOObjects.
bool removeStationVec(const std::string &name)
Removes the station vector with the given name from GEOObjects.
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
bool appendPolylineVec(const std::vector< Polyline * > &polylines, const std::string &name)
const std::vector< GeoLib::Point * > * getStationVec(const std::string &name) const
Returns the station vector with the given name.
bool removePolylineVec(const std::string &name)
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
A Station (observation site) is basically a Point with some additional information.
void cleanupVectorElements(std::vector< T * > &items)
@ AdaptiveMeshDensity
computing the mesh density employing a QuadTree
@ FixedMeshDensity
set the parameter with a fixed value
static std::ostream & operator<<(std::ostream &os, std::vector< GMSHPoint * > const &points)
void computeAndInsertAllIntersectionPoints(GeoLib::PointVec &pnt_vec, std::vector< GeoLib::Polyline * > &plys)
void rotatePoints(Eigen::Matrix3d const &rot_mat, InputIterator pnts_begin, InputIterator pnts_end)
Eigen::Matrix3d rotatePointsToXY(InputIterator1 p_pnts_begin, InputIterator1 p_pnts_end, InputIterator2 r_pnts_begin, InputIterator2 r_pnts_end)
GITINFOLIB_EXPORT const std::string ogs_version