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) ::iterator begin ()
 
decltype(_children) ::iterator end ()
 
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 29 of file GMSHPolygonTree.cpp.

35  _geo_objs(geo_objs),
36  _geo_name(geo_name),
37  _mesh_density_strategy(mesh_density_strategy)
38 {
39 }
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 41 of file GMSHPolygonTree.cpp.

42 {
43  // the polylines are processed also by the children, but the root is
44  // responsible to cleanup up
45  if (isRoot())
46  { // root
47  for (auto* polyline : _plys)
48  {
49  delete polyline;
50  }
51  }
52 }
std::vector< GeoLib::PolylineWithSegmentMarker * > _plys

References _plys, 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 214 of file GMSHPolygonTree.cpp.

217 {
218  std::size_t const ply_segment_number(seg_it.getSegmentNumber());
220  {
222  for (auto seg_it_p(p->begin()); seg_it_p != p->end(); ++seg_it_p)
223  {
224  GeoLib::Point s; // intersection point
225  if (GeoLib::lineSegmentIntersect(*seg_it, *seg_it_p, s))
226  {
227  const std::size_t pnt_vec_size(pnt_vec.size());
228  // point id of new point in GEOObjects instance
229  const std::size_t pnt_id(
230  pnt_vec.push_back(new GeoLib::Point(s)));
231  if (pnt_vec_size < pnt_vec.size())
232  { // case: new point
233  // modify polyline already in this node
234  p->insertPoint(seg_it_p.getSegmentNumber() + 1, pnt_id);
235  // modify polyline
236  ply->insertPoint(ply_segment_number + 1, pnt_id);
237  }
238  else
239  { // case: point exists already in geometry
240  // check if point is not already in polyline p
241  std::size_t const k(seg_it_p.getSegmentNumber());
242  if (p->getPointID(k) != pnt_id &&
243  p->getPointID(k + 1) != pnt_id)
244  {
245  p->insertPoint(k + 1, pnt_id);
246  }
247  // check if point is not already in polyline ply
248  if (ply->getPointID(ply_segment_number) != pnt_id &&
249  ply->getPointID(ply_segment_number + 1) != pnt_id)
250  {
251  ply->insertPoint(ply_segment_number + 1, pnt_id);
252  }
253  }
254  }
255  }
256  }
257 }
const PointVec * getPointVecObj(const std::string &name) const
Definition: GEOObjects.cpp:84
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 i) const
Definition: Polyline.cpp:159
bool lineSegmentIntersect(GeoLib::LineSegment const &s0, GeoLib::LineSegment const &s1, GeoLib::Point &s)
static const double 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(), MathLib::s, 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 293 of file GMSHPolygonTree.cpp.

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

◆ getPointsFromSubPolygons()

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

Definition at line 513 of file GMSHPolygonTree.cpp.

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

Referenced by initMeshDensityStrategy().

◆ getStationsInsideSubPolygons()

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

Definition at line 523 of file GMSHPolygonTree.cpp.

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

References _stations.

Referenced by 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 259 of file GMSHPolygonTree.cpp.

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

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 104 of file GMSHPolygonTree.cpp.

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

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(), GeoLib::Polygon::isPntInPolygon(), GeoLib::Polyline::isPointIDInPolyline(), GeoLib::PolylineWithSegmentMarker::isSegmentMarked(), GeoLib::PolylineWithSegmentMarker::markSegment(), GeoLib::SimplePolygonTree::polygon(), GeoLib::PointVec::push_back(), and GeoLib::TemplateVec< T >::size().

◆ 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 77 of file GMSHPolygonTree.cpp.

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

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

◆ markSharedSegments()

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

Mark the segments shared by several polygons.

Definition at line 54 of file GMSHPolygonTree.cpp.

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

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 461 of file GMSHPolygonTree.cpp.

464 {
465  if (auto* adaptive_mesh_density =
466  dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
467  {
468  std::vector<GeoLib::Point*> steiner_pnts;
469  adaptive_mesh_density->getSteinerPoints(steiner_pnts, 0);
470  const std::size_t n(steiner_pnts.size());
471  for (std::size_t k(0); k < n; k++)
472  {
473  if (polygon().isPntInPolygon(*(steiner_pnts[k])))
474  {
475  out << "Point(" << pnt_id_offset + k << ") = {"
476  << (*(steiner_pnts[k]))[0] << "," << (*(steiner_pnts[k]))[1]
477  << ", 0.0, ";
479  steiner_pnts[k])
480  << "};\n";
481  out << "Point { " << pnt_id_offset + k << " } In Surface { "
482  << sfc_number << " };\n";
483  }
484  delete steiner_pnts[k];
485  }
486  pnt_id_offset += n;
487  }
488 
489 #ifndef NDEBUG
490  if (auto* adaptive_mesh_density =
491  dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
492  {
493  auto pnts = std::make_unique<std::vector<GeoLib::Point*>>();
494  auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>();
495  adaptive_mesh_density->getQuadTreeGeometry(*pnts, *plys);
496  std::string quad_tree_geo("QuadTree");
497  _geo_objs.addPointVec(std::move(pnts), quad_tree_geo);
498  std::vector<std::size_t> const& id_map(
499  (_geo_objs.getPointVecObj(quad_tree_geo))->getIDMap());
500  for (std::size_t k(0); k < plys->size(); k++)
501  {
502  for (std::size_t j(0); j < (*plys)[k]->getNumberOfPoints(); j++)
503  {
504  ((*plys)[k])
505  ->setPointID(j, id_map[((*plys)[k])->getPointID(j)]);
506  }
507  }
508  _geo_objs.addPolylineVec(std::move(plys), quad_tree_geo);
509  }
510 #endif
511 }
void addPointVec(std::unique_ptr< std::vector< Point * >> points, std::string &name, std::unique_ptr< std::map< std::string, std::size_t >> pnt_id_name_map=nullptr, double eps=std::sqrt(std::numeric_limits< double >::epsilon()))
Definition: GEOObjects.cpp:51
void addPolylineVec(std::unique_ptr< std::vector< Polyline * >> lines, const std::string &name, std::unique_ptr< std::map< std::string, std::size_t >> ply_names=nullptr)
Definition: GEOObjects.cpp:150

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 392 of file GMSHPolygonTree.cpp.

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

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 356 of file GMSHPolygonTree.cpp.

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

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 444 of file GMSHPolygonTree.cpp.

447 {
448  for (auto const* station : _stations)
449  {
450  out << "Point(" << pnt_id_offset << ") = {" << (*station)[0] << ", "
451  << (*station)[1] << ", 0.0, "
453  << "}; // Station "
454  << static_cast<GeoLib::Station const*>(station)->getName() << " \n";
455  out << "Point { " << pnt_id_offset << " } In Surface { " << sfc_number
456  << " };\n";
457  ++pnt_id_offset;
458  }
459 }
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 418 of file GMSHPolygonTree.cpp.

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

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

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: