97{
98 DBUG(
"GMSHInterface::writeGMSHInputFile(): get data from GEOObjects.");
99
101 {
102 return 1;
103 }
104
105
107 {
110 {
111 return 2;
112 }
113 }
114 else
115 {
118 }
119
120 auto* merged_pnts(const_cast<std::vector<GeoLib::Point*>*>(
122 if (!merged_pnts)
123 {
124 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not found any points.");
125 return 2;
126 }
127
129 {
130
132
134 }
135 else
136 {
137
139 for (auto pnt : *merged_pnts)
140 {
141 (*pnt)[2] = 0.0;
142 }
143 }
144
145 std::vector<GeoLib::Polyline*> const* merged_plys(
147 DBUG(
"GMSHInterface::writeGMSHInputFile(): Obtained data.");
148
149 if (!merged_plys)
150 {
151 ERR(
"GMSHInterface::writeGMSHInputFile(): Did not find any polylines.");
152 return 2;
153 }
154
155
159 pnt_vec, *(const_cast<std::vector<GeoLib::Polyline*>*>(merged_plys)));
160
161 std::vector<GeoLib::Polyline*> polygons;
162
163
164 for (auto polyline : *merged_plys)
165 {
166 if (!polyline->isClosed())
167 {
168 continue;
169 }
171 }
172 if (polygons.empty())
173 {
174 OGS_FATAL(
"GMSHInterface::writeGMSHInputFile(): no polygons found.");
175 }
176
178
179 std::transform(
180 polygons.begin(), polygons.end(),
182 [this](auto const& polygon)
183 {
184 return new GMSH::GMSHPolygonTree(
185 dynamic_cast<GeoLib::PolygonWithSegmentMarker*>(polygon),
186 nullptr, _geo_objs, _gmsh_geo_name, *_mesh_density_strategy);
187 });
189 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
190 "detected {:d} polygons.",
192
195 "GMSHInterface::writeGMSHInputFile(): Computed topological hierarchy - "
196 "calculated {:d} polygon trees.",
198
199
201 {
202 polygon_tree->markSharedSegments();
203 }
204
205
206
207
208
209 std::vector<GeoLib::Point*> gmsh_stations{};
211 {
213 if (stations)
214 {
215 for (auto* station : *stations)
216 {
217 bool found(false);
220 ++it)
221 {
224 if ((*it)->insertStation(gmsh_stations.back()))
225 {
226 found = true;
227 }
228 }
229 }
230 }
231 }
233 if (!gmsh_stations.empty())
234 {
236 }
237
238
239 for (auto polyline : *merged_plys)
240 {
241 if (!polyline->isClosed())
242 {
244 {
245 auto polyline_with_segment_marker =
247 polygon_tree->insertPolyline(polyline_with_segment_marker);
248 }
249 }
250 }
251
252
254 {
255 polygon_tree->initMeshDensityStrategy();
256 }
257
258
259 const std::size_t n_merged_pnts(merged_pnts->size());
261 for (std::size_t k(0); k < n_merged_pnts; k++)
262 {
264 }
266 {
268 }
269
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)
273 {
275 {
276 error_messages
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 "
282 "process.\n";
283 }
284 }
285 auto const error_message = error_messages.str();
286 if (!error_message.empty())
287 {
289 }
290
291
294
297 {
300 polygon_tree->writeSubPolygonsAsLineConstraints(
_n_lines,
304 polygon_tree->writeAdditionalPointData(pnt_id_offset,
_n_plane_sfc - 1,
306 }
307
309 {
314 }
315
316 return 0;
317}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
bool _write_physical_groups
std::string _gmsh_geo_name
Eigen::Matrix3d _inverse_rot_mat
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 createPolygonTrees(std::list< POLYGONTREETYPE * > &list_of_simple_polygon_hierarchies)
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)