OGS
FileIO::GMSH::GMSHPolygonTree Class Reference

Detailed Description

Definition at line 35 of file GMSHPolygonTree.h.

#include <GMSHPolygonTree.h>

Inheritance diagram for FileIO::GMSH::GMSHPolygonTree:
[legend]
Collaboration diagram for FileIO::GMSH::GMSHPolygonTree:
[legend]

Public Member Functions

 GMSHPolygonTree (GeoLib::PolygonWithSegmentMarker *polygon, GMSHPolygonTree *parent, GeoLib::GEOObjects &geo_objs, std::string const &geo_name, GMSHMeshDensityStrategy &mesh_density_strategy)
 
 ~GMSHPolygonTree () override
 
void markSharedSegments ()
 
bool insertStation (GeoLib::Point const *station)
 
void insertPolyline (GeoLib::PolylineWithSegmentMarker *ply)
 
void initMeshDensityStrategy ()
 
void createGMSHPoints (std::vector< GMSHPoint * > &gmsh_pnts) const
 
virtual void writeLineLoop (std::size_t &line_offset, std::size_t &sfc_offset, std::ostream &out, bool const write_physical) const
 
void writeSubPolygonsAsLineConstraints (std::size_t &line_offset, std::size_t sfc_number, std::ostream &out) const
 
virtual void writeLineConstraints (std::size_t &line_offset, std::size_t sfc_number, std::ostream &out) const
 
void writeStations (std::size_t &pnt_id_offset, std::size_t sfc_number, std::ostream &out) const
 
void writeAdditionalPointData (std::size_t &pnt_id_offset, std::size_t sfc_number, std::ostream &out) const
 
- Public Member Functions inherited from GeoLib::SimplePolygonTree
 SimplePolygonTree (Polygon *polygon, SimplePolygonTree *parent)
 
virtual ~SimplePolygonTree ()
 
bool isRoot () const
 
bool isPolygonInside (const SimplePolygonTree *polygon_hierarchy) const
 
void insertSimplePolygonTree (SimplePolygonTree *polygon_hierarchy)
 
Polygon const & polygon () const
 
Polygonpolygon ()
 
const SimplePolygonTreeparent () const
 
std::size_t getNumberOfChildren () const
 
decltype(_children) ::const_iterator begin () const
 
decltype(_children) ::const_iterator end () const
 

Private Member Functions

void getPointsFromSubPolygons (std::vector< GeoLib::Point const * > &pnts) const
 
void getStationsInsideSubPolygons (std::vector< GeoLib::Point const * > &stations) const
 
void checkIntersectionsSegmentExistingPolylines (GeoLib::PolylineWithSegmentMarker *ply, GeoLib::Polyline::SegmentIterator const &seg_it)
 

Private Attributes

GeoLib::GEOObjects_geo_objs
 
std::string const & _geo_name
 
std::vector< GeoLib::Point const * > _stations
 
std::vector< GeoLib::PolylineWithSegmentMarker * > _plys
 
std::vector< GMSHLine * > _gmsh_lines_for_constraints
 
GMSHMeshDensityStrategy_mesh_density_strategy
 

Constructor & Destructor Documentation

◆ GMSHPolygonTree()

FileIO::GMSH::GMSHPolygonTree::GMSHPolygonTree ( GeoLib::PolygonWithSegmentMarker polygon,
GMSHPolygonTree parent,
GeoLib::GEOObjects geo_objs,
std::string const &  geo_name,
GMSHMeshDensityStrategy mesh_density_strategy 
)

Definition at line 30 of file GMSHPolygonTree.cpp.

36 _geo_objs(geo_objs),
37 _geo_name(geo_name),
38 _mesh_density_strategy(mesh_density_strategy)
39{
40}
GMSHMeshDensityStrategy & _mesh_density_strategy
std::string const & _geo_name
GeoLib::GEOObjects & _geo_objs
This class computes and stores the topological relations between polygons. Every node of the SimplePo...
const SimplePolygonTree * parent() const
Polygon const & polygon() const

◆ ~GMSHPolygonTree()

FileIO::GMSH::GMSHPolygonTree::~GMSHPolygonTree ( )
override

Definition at line 42 of file GMSHPolygonTree.cpp.

43{
44 // the polylines are processed also by the children, but the root is
45 // responsible to cleanup up
46 if (isRoot())
47 { // root
49 }
50}
std::vector< GeoLib::PolylineWithSegmentMarker * > _plys
void cleanupVectorElements(std::vector< T * > &items)
Definition: Algorithm.h:300

References _plys, BaseLib::cleanupVectorElements(), and GeoLib::SimplePolygonTree::isRoot().

Member Function Documentation

◆ checkIntersectionsSegmentExistingPolylines()

void FileIO::GMSH::GMSHPolygonTree::checkIntersectionsSegmentExistingPolylines ( GeoLib::PolylineWithSegmentMarker ply,
GeoLib::Polyline::SegmentIterator const &  seg_it 
)
private

Definition at line 212 of file GMSHPolygonTree.cpp.

215{
216 std::size_t const ply_segment_number(seg_it.getSegmentNumber());
218 {
220 for (auto seg_it_p(p->begin()); seg_it_p != p->end(); ++seg_it_p)
221 {
222 GeoLib::Point s; // intersection point
223 if (GeoLib::lineSegmentIntersect(*seg_it, *seg_it_p, s))
224 {
225 const std::size_t pnt_vec_size(pnt_vec.size());
226 // point id of new point in GEOObjects instance
227 const std::size_t pnt_id(
228 pnt_vec.push_back(new GeoLib::Point(s)));
229 if (pnt_vec_size < pnt_vec.size())
230 { // case: new point
231 // modify polyline already in this node
232 p->insertPoint(seg_it_p.getSegmentNumber() + 1, pnt_id);
233 // modify polyline
234 ply->insertPoint(ply_segment_number + 1, pnt_id);
235 }
236 else
237 { // case: point exists already in geometry
238 // check if point is not already in polyline p
239 std::size_t const k(seg_it_p.getSegmentNumber());
240 if (p->getPointID(k) != pnt_id &&
241 p->getPointID(k + 1) != pnt_id)
242 {
243 p->insertPoint(k + 1, pnt_id);
244 }
245 // check if point is not already in polyline ply
246 if (ply->getPointID(ply_segment_number) != pnt_id &&
247 ply->getPointID(ply_segment_number + 1) != pnt_id)
248 {
249 ply->insertPoint(ply_segment_number + 1, pnt_id);
250 }
251 }
252 }
253 }
254 }
255}
const PointVec * getPointVecObj(const std::string &name) const
Definition: GEOObjects.cpp:85
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition: PointVec.h:38
bool insertPoint(std::size_t pos, std::size_t pnt_id) override
std::size_t getPointID(std::size_t const i) const
Definition: Polyline.cpp:160
bool lineSegmentIntersect(GeoLib::LineSegment const &s0, GeoLib::LineSegment const &s1, GeoLib::Point &s)

References _geo_name, _geo_objs, _plys, GeoLib::Polyline::getPointID(), GeoLib::GEOObjects::getPointVecObj(), GeoLib::Polyline::SegmentIterator::getSegmentNumber(), GeoLib::PolylineWithSegmentMarker::insertPoint(), GeoLib::lineSegmentIntersect(), GeoLib::PointVec::push_back(), and GeoLib::TemplateVec< T >::size().

Referenced by insertPolyline().

◆ createGMSHPoints()

void FileIO::GMSH::GMSHPolygonTree::createGMSHPoints ( std::vector< GMSHPoint * > &  gmsh_pnts) const

Method creates the gmsh point data structures - including the mesh density.

Parameters
gmsh_pntsa vector of pointers to instances of class GMSHPoint

Definition at line 291 of file GMSHPolygonTree.cpp.

292{
293 const std::size_t n_pnts_polygon(polygon().getNumberOfPoints());
294 for (std::size_t k(0); k < n_pnts_polygon - 1; k++)
295 {
296 const std::size_t id(polygon().getPointID(k));
297 GeoLib::Point const* const pnt(polygon().getPoint(k));
298 // if this point was already part of another polyline
299 if (gmsh_pnts[id] != nullptr)
300 {
301 continue;
302 }
303 gmsh_pnts[id] = new GMSHPoint(
305 }
306
307 const std::size_t n_plys(_plys.size());
308 std::stringstream error_messages;
309 error_messages.precision(std::numeric_limits<double>::digits10);
310 for (std::size_t k(0); k < n_plys; k++)
311 {
312 const std::size_t n_pnts_in_ply(_plys[k]->getNumberOfPoints());
313 for (std::size_t j(0); j < n_pnts_in_ply; j++)
314 {
315 if (polygon().isPntInPolygon(*(_plys[k]->getPoint(j))))
316 {
317 const std::size_t id(_plys[k]->getPointID(j));
318 // if this point was already part of another polyline
319 if (gmsh_pnts[id] != nullptr)
320 {
321 continue;
322 }
323 GeoLib::Point const* const pnt(_plys[k]->getPoint(j));
324 gmsh_pnts[id] = new GMSHPoint(
325 *pnt, id,
327 }
328 else
329 {
330 auto const& p = *(_plys[k]->getPoint(j));
331 error_messages << "\n\tpoint with id " << p.getID()
332 << " and coordinates (" << p[0] << ", " << p[1]
333 << ", " << p[2]
334 << ") is outside of the polygon.";
335 }
336 }
337 }
338 if (!parent())
339 {
340 auto const error_message = error_messages.str();
341 if (!error_message.empty())
342 {
343 OGS_FATAL("{}", error_message);
344 }
345 }
346
347 // walk through children
348 for (auto* child : *this)
349 {
350 dynamic_cast<GMSHPolygonTree*>(child)->createGMSHPoints(gmsh_pnts);
351 }
352}
#define OGS_FATAL(...)
Definition: Error.h:26
virtual double getMeshDensityAtPoint(GeoLib::Point const *const) const =0
GMSHPolygonTree(GeoLib::PolygonWithSegmentMarker *polygon, GMSHPolygonTree *parent, GeoLib::GEOObjects &geo_objs, std::string const &geo_name, GMSHMeshDensityStrategy &mesh_density_strategy)
void createGMSHPoints(std::vector< GMSHPoint * > &gmsh_pnts) const

References _mesh_density_strategy, _plys, createGMSHPoints(), FileIO::GMSH::GMSHMeshDensityStrategy::getMeshDensityAtPoint(), OGS_FATAL, GeoLib::SimplePolygonTree::parent(), and GeoLib::SimplePolygonTree::polygon().

Referenced by createGMSHPoints().

◆ getPointsFromSubPolygons()

void FileIO::GMSH::GMSHPolygonTree::getPointsFromSubPolygons ( std::vector< GeoLib::Point const * > &  pnts) const
private

Definition at line 512 of file GMSHPolygonTree.cpp.

514{
515 for (auto const* child : *this)
516 {
517 dynamic_cast<GMSHPolygonTree const*>(child)->getPointsFromSubPolygons(
518 pnts);
519 }
520}
void getPointsFromSubPolygons(std::vector< GeoLib::Point const * > &pnts) const

References getPointsFromSubPolygons().

Referenced by getPointsFromSubPolygons(), and initMeshDensityStrategy().

◆ getStationsInsideSubPolygons()

void FileIO::GMSH::GMSHPolygonTree::getStationsInsideSubPolygons ( std::vector< GeoLib::Point const * > &  stations) const
private

Definition at line 522 of file GMSHPolygonTree.cpp.

524{
525 const std::size_t n_stations(_stations.size());
526 for (std::size_t k(0); k < n_stations; k++)
527 {
528 stations.push_back(_stations[k]);
529 }
530
531 for (auto const* child : *this)
532 {
533 dynamic_cast<GMSHPolygonTree const*>(child)
535 }
536}
std::vector< GeoLib::Point const * > _stations
void getStationsInsideSubPolygons(std::vector< GeoLib::Point const * > &stations) const

References _stations, and getStationsInsideSubPolygons().

Referenced by getStationsInsideSubPolygons(), and initMeshDensityStrategy().

◆ initMeshDensityStrategy()

void FileIO::GMSH::GMSHPolygonTree::initMeshDensityStrategy ( )

Initialize the mesh density strategy with data. In case of GMSHAdaptiveMeshDensity an instance of class QuadTree will be set up with the points within the top level bounding polygon.

Definition at line 257 of file GMSHPolygonTree.cpp.

258{
259 if (auto* adaptive_mesh_density =
260 dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
261 {
262 // collect points
263 std::vector<GeoLib::Point const*> pnts;
264 const std::size_t n_pnts_polygon(polygon().getNumberOfPoints());
265 for (std::size_t k(0); k < n_pnts_polygon; k++)
266 {
267 pnts.push_back(polygon().getPoint(k));
268 }
270
271 const std::size_t n_plys(_plys.size());
272 for (std::size_t k(0); k < n_plys; k++)
273 {
274 const std::size_t n_pnts_in_kth_ply(_plys[k]->getNumberOfPoints());
275 for (std::size_t j(0); j < n_pnts_in_kth_ply; j++)
276 {
277 pnts.push_back(_plys[k]->getPoint(j));
278 }
279 }
280
281 // give collected points to the mesh density strategy
282 adaptive_mesh_density->initialize(pnts);
283 // insert constraints
284 adaptive_mesh_density->addPoints(_stations);
285 std::vector<GeoLib::Point const*> stations;
287 adaptive_mesh_density->addPoints(stations);
288 }
289}

References _mesh_density_strategy, _plys, _stations, getPointsFromSubPolygons(), getStationsInsideSubPolygons(), and GeoLib::SimplePolygonTree::polygon().

◆ insertPolyline()

void FileIO::GMSH::GMSHPolygonTree::insertPolyline ( GeoLib::PolylineWithSegmentMarker ply)

If at least one (end) point (of a line segment) of the polyline is inside the polygon the polyline is inserted to the internal vector of polylines.

Intersection points are inserted into the points vector the polygon and the polyline are based on. The id of the intersection point is inserted in both the polygon and the polyline, i.e. the two intersecting line segments are splitt into four line segment.

Line segments of the polyline that are completely within the polygon are inserted into the internal vector _gmsh_lines_for_constraints. The children of this GMSHPolygonTree node are checked recursively.

Parameters
plythe polyline that should be inserted

Definition at line 102 of file GMSHPolygonTree.cpp.

103{
104 if (!polygon().isPartOfPolylineInPolygon(*ply))
105 {
106 return;
107 }
108
109 // check if polyline segments are inside of the polygon, intersect the
110 // polygon or are part of the boundary of the polygon
111 for (auto* child : *this)
112 {
113 dynamic_cast<GMSHPolygonTree*>(child)->insertPolyline(ply);
114 }
115
116 // calculate possible intersection points between the node polygon and the
117 // given polyline ply
118 // pay attention: loop bound is not fix!
119 GeoLib::Point tmp_pnt;
121 for (auto segment_it(ply->begin()); segment_it != ply->end(); ++segment_it)
122 {
123 if (ply->isSegmentMarked(segment_it.getSegmentNumber()))
124 {
125 continue;
126 }
127
128 if (polygon().containsSegment(*segment_it))
129 {
130 ply->markSegment(segment_it.getSegmentNumber(), true);
131 continue;
132 }
133
134 std::size_t seg_num(0);
135 GeoLib::Point intersection_pnt;
136 while (polygon().getNextIntersectionPointPolygonLine(
137 *segment_it, intersection_pnt, seg_num))
138 {
139 // insert the intersection point to point vector of GEOObjects
140 // instance
141 const std::size_t pnt_vec_size(pnt_vec.size());
142 std::size_t pnt_id(
143 pnt_vec.push_back(new GeoLib::Point(intersection_pnt)));
144 if (pnt_vec_size < pnt_vec.size())
145 { // case: new point
146 // modify the polygon
147 polygon().insertPoint(seg_num + 1, pnt_id);
148 // modify the polyline
149 ply->insertPoint(segment_it.getSegmentNumber(), pnt_id);
150 }
151 else
152 { // case: existing point
153 // check if point id is within the polygon
154 if (!polygon().isPointIDInPolyline(pnt_id))
155 {
156 polygon().insertPoint(seg_num + 1, pnt_id);
157 }
158
159 // check if point id is in polyline
160 if (!ply->isPointIDInPolyline(pnt_id))
161 {
162 ply->insertPoint(segment_it.getSegmentNumber() + 1, pnt_id);
163 }
164 }
165
166 std::size_t tmp_seg_num(seg_num + 1);
167 if (!polygon().getNextIntersectionPointPolygonLine(
168 *segment_it, tmp_pnt, tmp_seg_num))
169 {
170 // check a point of the segment except the end points
171 for (std::size_t i(0); i < 3; i++)
172 {
173 tmp_pnt[i] = ((*segment_it).getBeginPoint()[i] +
174 (*segment_it).getEndPoint()[i]) /
175 2;
176 }
177 if (polygon().isPntInPolygon(tmp_pnt))
178 {
179 ply->markSegment(segment_it.getSegmentNumber(), true);
180 // insert line segment as constraint
182 new GMSHLine((*segment_it).getBeginPoint().getID(),
183 (*segment_it).getEndPoint().getID()));
184 }
185 }
186 seg_num++;
187
188 // check a point of the segment except the end points
189 for (std::size_t i(0); i < 3; i++)
190 {
191 tmp_pnt[i] = ((*segment_it).getBeginPoint()[i] +
192 (*segment_it).getEndPoint()[i]) /
193 2;
194 }
195
197
198 if (polygon().isPntInPolygon(tmp_pnt))
199 {
200 ply->markSegment(segment_it.getSegmentNumber(), true);
201 // insert line segment as constraint
203 new GMSHLine((*segment_it).getBeginPoint().getID(),
204 (*segment_it).getEndPoint().getID()));
205 }
206 }
207 }
208
209 _plys.push_back(ply);
210}
void insertPolyline(GeoLib::PolylineWithSegmentMarker *ply)
void checkIntersectionsSegmentExistingPolylines(GeoLib::PolylineWithSegmentMarker *ply, GeoLib::Polyline::SegmentIterator const &seg_it)
std::vector< GMSHLine * > _gmsh_lines_for_constraints
bool isPntInPolygon(MathLib::Point3d const &pnt) const
Definition: Polygon.cpp:206
bool isSegmentMarked(std::size_t seg_num) const
void markSegment(std::size_t seg_num, bool mark_val=true)
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
Definition: Polyline.cpp:55
SegmentIterator begin() const
Definition: Polyline.h:185
bool isPointIDInPolyline(std::size_t pnt_id) const
Definition: Polyline.cpp:154
SegmentIterator end() const
Definition: Polyline.h:190

References _geo_name, _geo_objs, _gmsh_lines_for_constraints, _plys, GeoLib::Polyline::begin(), checkIntersectionsSegmentExistingPolylines(), GeoLib::Polyline::end(), GeoLib::GEOObjects::getPointVecObj(), GeoLib::Polyline::insertPoint(), GeoLib::PolylineWithSegmentMarker::insertPoint(), insertPolyline(), GeoLib::Polygon::isPntInPolygon(), GeoLib::Polyline::isPointIDInPolyline(), GeoLib::PolylineWithSegmentMarker::isSegmentMarked(), GeoLib::PolylineWithSegmentMarker::markSegment(), GeoLib::SimplePolygonTree::polygon(), GeoLib::PointVec::push_back(), and GeoLib::TemplateVec< T >::size().

Referenced by insertPolyline().

◆ insertStation()

bool FileIO::GMSH::GMSHPolygonTree::insertStation ( GeoLib::Point const *  station)

If the station point is inside the polygon, the method inserts the station into the internal vector of stations. This method works recursive!

Parameters
stationthe station point
Returns
true if the station is inside the polygon

Definition at line 75 of file GMSHPolygonTree.cpp.

76{
77 if (polygon().isPntInPolygon(*station))
78 {
79 // try to insert station into the child nodes
80 for (auto* child : *this)
81 {
82 if (child->polygon().isPntInPolygon(*station))
83 {
84 bool rval(dynamic_cast<GMSHPolygonTree*>(child)->insertStation(
85 station));
86 // stop recursion if sub SimplePolygonTree is a leaf
87 if (rval && child->getNumberOfChildren() == 0)
88 {
89 _stations.push_back(station);
90 }
91 return rval;
92 }
93 }
94 // station did not fit into child nodes -> insert the station into this
95 // node
96 _stations.push_back(station);
97 return true;
98 }
99 return false;
100}
bool insertStation(GeoLib::Point const *station)

References _stations, insertStation(), and GeoLib::SimplePolygonTree::polygon().

Referenced by insertStation().

◆ markSharedSegments()

void FileIO::GMSH::GMSHPolygonTree::markSharedSegments ( )

Mark the segments shared by several polygons.

Definition at line 52 of file GMSHPolygonTree.cpp.

53{
54 if (isRoot())
55 {
56 return;
57 }
58
59 for (auto& child : *this)
60 {
61 std::size_t const n_pnts(child->polygon().getNumberOfPoints());
62 for (std::size_t k(1); k < n_pnts; k++)
63 {
65 polygon().getPointID(k - 1),
66 polygon().getPointID(k)))
67 {
69 .markSegment(k, true);
70 }
71 }
72 }
73}
bool containsEdge(const Polyline &ply, std::size_t id0, std::size_t id1)
Definition: Polyline.cpp:482

References GeoLib::containsEdge(), GeoLib::SimplePolygonTree::isRoot(), GeoLib::SimplePolygonTree::parent(), and GeoLib::SimplePolygonTree::polygon().

◆ writeAdditionalPointData()

void FileIO::GMSH::GMSHPolygonTree::writeAdditionalPointData ( std::size_t &  pnt_id_offset,
std::size_t  sfc_number,
std::ostream &  out 
) const

Definition at line 459 of file GMSHPolygonTree.cpp.

462{
463 if (auto* adaptive_mesh_density =
464 dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
465 {
466 std::vector<GeoLib::Point*> steiner_pnts;
467 adaptive_mesh_density->getSteinerPoints(steiner_pnts, 0);
468 const std::size_t n(steiner_pnts.size());
469 for (std::size_t k(0); k < n; k++)
470 {
471 if (polygon().isPntInPolygon(*(steiner_pnts[k])))
472 {
473 out << "Point(" << pnt_id_offset + k << ") = {"
474 << (*(steiner_pnts[k]))[0] << "," << (*(steiner_pnts[k]))[1]
475 << ", 0.0, ";
477 steiner_pnts[k])
478 << "};\n";
479 out << "Point { " << pnt_id_offset + k << " } In Surface { "
480 << sfc_number << " };\n";
481 }
482 delete steiner_pnts[k];
483 }
484 pnt_id_offset += n;
485 }
486
487#ifndef NDEBUG
488 if (auto* adaptive_mesh_density =
489 dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
490 {
491 std::vector<GeoLib::Point*> pnts;
492 std::vector<GeoLib::Polyline*> plys;
493 adaptive_mesh_density->getQuadTreeGeometry(pnts, plys);
494 std::string quad_tree_geo("QuadTree");
495 _geo_objs.addPointVec(std::move(pnts), quad_tree_geo,
497 std::vector<std::size_t> const& id_map(
498 (_geo_objs.getPointVecObj(quad_tree_geo))->getIDMap());
499 for (std::size_t k(0); k < plys.size(); k++)
500 {
501 for (std::size_t j(0); j < plys[k]->getNumberOfPoints(); j++)
502 {
503 (plys[k])->setPointID(j, id_map[(plys[k])->getPointID(j)]);
504 }
505 }
506 _geo_objs.addPolylineVec(std::move(plys), quad_tree_geo,
508 }
509#endif
510}
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
Definition: GEOObjects.cpp:152
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()))
Definition: GEOObjects.cpp:47
std::map< std::string, std::size_t > NameIdMap
Definition: TemplateVec.h:44

References _geo_objs, _mesh_density_strategy, GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), FileIO::GMSH::GMSHMeshDensityStrategy::getMeshDensityAtPoint(), GeoLib::GEOObjects::getPointVecObj(), and GeoLib::SimplePolygonTree::polygon().

◆ writeLineConstraints()

void FileIO::GMSH::GMSHPolygonTree::writeLineConstraints ( std::size_t &  line_offset,
std::size_t  sfc_number,
std::ostream &  out 
) const
virtual

Definition at line 390 of file GMSHPolygonTree.cpp.

393{
394 for (auto polyline : _plys)
395 {
396 const std::size_t n_pnts(polyline->getNumberOfPoints());
397 std::size_t first_pnt_id(polyline->getPointID(0));
398 for (std::size_t k(1); k < n_pnts; k++)
399 {
400 auto const second_pnt_id = polyline->getPointID(k);
401 if (polyline->isSegmentMarked(k - 1) &&
402 polygon().isPntInPolygon(*(polyline->getPoint(k))) &&
403 !GeoLib::containsEdge(polygon(), first_pnt_id, second_pnt_id))
404 {
405 out << "Line(" << line_offset + k - 1 << ") = {" << first_pnt_id
406 << "," << second_pnt_id << "};\n";
407 out << "Line { " << line_offset + k - 1 << " } In Surface { "
408 << sfc_number << " };\n";
409 }
410 first_pnt_id = second_pnt_id;
411 }
412 line_offset += n_pnts;
413 }
414}

References _plys, GeoLib::containsEdge(), and GeoLib::SimplePolygonTree::polygon().

◆ writeLineLoop()

void FileIO::GMSH::GMSHPolygonTree::writeLineLoop ( std::size_t &  line_offset,
std::size_t &  sfc_offset,
std::ostream &  out,
bool const  write_physical 
) const
virtual

Definition at line 354 of file GMSHPolygonTree.cpp.

357{
358 const std::size_t n_pnts(polygon().getNumberOfPoints());
359 for (std::size_t k(1), first_pnt_id(polygon().getPointID(0)); k < n_pnts;
360 k++)
361 {
362 std::size_t const second_pnt_id = polygon().getPointID(k);
363 out << "Line(" << line_offset + k - 1 << ") = {" << first_pnt_id << ","
364 << second_pnt_id << "};\n";
365 first_pnt_id = second_pnt_id;
366 }
367 out << "Line Loop(" << line_offset + n_pnts - 1 << ") = {";
368 for (std::size_t k(0); k < n_pnts - 2; k++)
369 {
370 out << line_offset + k << ",";
371 }
372 out << line_offset + n_pnts - 2 << "};\n";
373 out << "Plane Surface(" << sfc_offset << ") = {" << line_offset + n_pnts - 1
374 << "};\n";
375 if (write_physical)
376 {
377 out << "Physical Curve(" << sfc_offset << ") = {";
378 for (std::size_t k(0); k < n_pnts - 2; k++)
379 {
380 out << line_offset + k << ",";
381 }
382 out << line_offset + n_pnts - 2 << "};\n";
383 out << "Physical Surface(" << sfc_offset << ") = {" << sfc_offset
384 << "};\n";
385 }
386 line_offset += n_pnts;
387 sfc_offset++;
388}

References GeoLib::Polyline::getPointID(), and GeoLib::SimplePolygonTree::polygon().

◆ writeStations()

void FileIO::GMSH::GMSHPolygonTree::writeStations ( std::size_t &  pnt_id_offset,
std::size_t  sfc_number,
std::ostream &  out 
) const

Definition at line 442 of file GMSHPolygonTree.cpp.

445{
446 for (auto const* station : _stations)
447 {
448 out << "Point(" << pnt_id_offset << ") = {" << (*station)[0] << ", "
449 << (*station)[1] << ", 0.0, "
451 << "}; // Station "
452 << static_cast<GeoLib::Station const*>(station)->getName() << " \n";
453 out << "Point { " << pnt_id_offset << " } In Surface { " << sfc_number
454 << " };\n";
455 ++pnt_id_offset;
456 }
457}
std::string getName(std::string const &line)
Returns the name/title from the "Zone"-description.
virtual double getMeshDensityAtStation(GeoLib::Point const *const) const =0
A Station (observation site) is basically a Point with some additional information.
Definition: Station.h:37

References _mesh_density_strategy, _stations, FileIO::GMSH::GMSHMeshDensityStrategy::getMeshDensityAtStation(), and getName().

◆ writeSubPolygonsAsLineConstraints()

void FileIO::GMSH::GMSHPolygonTree::writeSubPolygonsAsLineConstraints ( std::size_t &  line_offset,
std::size_t  sfc_number,
std::ostream &  out 
) const

Definition at line 416 of file GMSHPolygonTree.cpp.

418{
419 for (auto* child : *this)
420 {
421 dynamic_cast<GMSHPolygonTree*>(child)
422 ->writeSubPolygonsAsLineConstraints(line_offset, sfc_number, out);
423 }
424
425 if (!isRoot())
426 {
427 const std::size_t n_pnts(polygon().getNumberOfPoints());
428 std::size_t first_pnt_id(polygon().getPointID(0));
429 for (std::size_t k(1); k < n_pnts; k++)
430 {
431 auto const second_pnt_id = polygon().getPointID(k);
432 out << "Line(" << line_offset + k - 1 << ") = {" << first_pnt_id
433 << "," << second_pnt_id << "};\n";
434 first_pnt_id = second_pnt_id;
435 out << "Line { " << line_offset + k - 1 << " } In Surface { "
436 << sfc_number << " };\n";
437 }
438 line_offset += n_pnts;
439 }
440}
void writeSubPolygonsAsLineConstraints(std::size_t &line_offset, std::size_t sfc_number, std::ostream &out) const

References GeoLib::Polyline::getPointID(), GeoLib::SimplePolygonTree::isRoot(), GeoLib::SimplePolygonTree::polygon(), and writeSubPolygonsAsLineConstraints().

Referenced by writeSubPolygonsAsLineConstraints().

Member Data Documentation

◆ _geo_name

std::string const& FileIO::GMSH::GMSHPolygonTree::_geo_name
private

◆ _geo_objs

GeoLib::GEOObjects& FileIO::GMSH::GMSHPolygonTree::_geo_objs
private

◆ _gmsh_lines_for_constraints

std::vector<GMSHLine*> FileIO::GMSH::GMSHPolygonTree::_gmsh_lines_for_constraints
private

Definition at line 103 of file GMSHPolygonTree.h.

Referenced by insertPolyline().

◆ _mesh_density_strategy

GMSHMeshDensityStrategy& FileIO::GMSH::GMSHPolygonTree::_mesh_density_strategy
private

◆ _plys

◆ _stations

std::vector<GeoLib::Point const*> FileIO::GMSH::GMSHPolygonTree::_stations
private

The documentation for this class was generated from the following files: