OGS
GEOObjects.cpp
Go to the documentation of this file.
1
15#include "GEOObjects.h"
16
17#include "BaseLib/Algorithm.h"
18#include "BaseLib/Logging.h"
19#include "BaseLib/StringTools.h"
20#include "Station.h"
21#include "Triangle.h"
22
23namespace GeoLib
24{
27template <typename Container>
28auto findVectorByName(Container const& container, std::string const& name)
29{
30 return std::find_if(container.begin(), container.end(),
31 [&name](auto const* vector)
32 { return vector->getName() == name; });
33}
34
35void markUnusedPoints(GEOObjects const& geo_objects,
36 std::string const& geo_name,
37 std::vector<bool>& transfer_pnts);
38
39GEOObjects::GEOObjects() = default;
40
42{
43 // delete all SurfaceVecs, PolylineVec, and PointVecs
45}
46
47void GEOObjects::addPointVec(std::vector<Point*>&& points,
48 std::string& name,
49 PointVec::NameIdMap&& pnt_id_name_map,
50 double const eps)
51{
53 if (points.empty())
54 {
55 DBUG(
56 "GEOObjects::addPointVec(): Failed to create PointVec, because "
57 "there aren't any points in the given vector.");
58 return;
59 }
60 _pnt_vecs.push_back(new PointVec(name, std::move(points),
61 std::move(pnt_id_name_map),
63 _callbacks->addPointVec(name);
64}
65
66void GEOObjects::addPointVec(std::vector<Point*>&& points, std::string& name,
67 double const eps)
68{
69 addPointVec(std::move(points), name, {}, eps);
70}
71
72const std::vector<Point*>* GEOObjects::getPointVec(
73 const std::string& name) const
74{
75 std::size_t const idx = this->exists(name);
76 if (idx != std::numeric_limits<std::size_t>::max())
77 {
78 return &_pnt_vecs[idx]->getVector();
79 }
80
81 DBUG("GEOObjects::getPointVec() - No entry found with name '{:s}'.", name);
82 return nullptr;
83}
84
85const PointVec* GEOObjects::getPointVecObj(const std::string& name) const
86{
87 std::size_t const idx = this->exists(name);
88 if (idx != std::numeric_limits<std::size_t>::max())
89 {
90 return _pnt_vecs[idx];
91 }
92
93 DBUG("GEOObjects::getPointVecObj() - No entry found with name '{:s}'.",
94 name);
95 return nullptr;
96}
97
98bool GEOObjects::removePointVec(std::string const& name)
99{
100 if (isPntVecUsed(name))
101 {
102 DBUG(
103 "GEOObjects::removePointVec() - There are still Polylines or "
104 "Surfaces depending on these points.");
105 return false;
106 }
107
108 for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it)
109 {
110 if ((*it)->getName() == name)
111 {
112 _callbacks->removePointVec(name);
113 delete *it;
114 _pnt_vecs.erase(it);
115 return true;
116 }
117 }
118 DBUG("GEOObjects::removePointVec() - No entry found with name '{:s}'.",
119 name);
120 return false;
121}
122
123void GEOObjects::addStationVec(std::vector<Point*>&& stations,
124 std::string& name)
125{
127 _pnt_vecs.push_back(new PointVec(name, std::move(stations),
130 _callbacks->addStationVec(name);
131}
132
133const std::vector<GeoLib::Point*>* GEOObjects::getStationVec(
134 const std::string& name) const
135{
136 auto const it =
137 std::find_if(begin(_pnt_vecs), end(_pnt_vecs),
138 [&name](PointVec const* const p)
139 {
140 return p->getName() == name &&
141 p->getType() == PointVec::PointType::STATION;
142 });
143 if (it != end(_pnt_vecs))
144 {
145 return &(*it)->getVector();
146 }
147 DBUG("GEOObjects::getStationVec() - No entry found with name '{:s}'.",
148 name);
149 return nullptr;
150}
151
152void GEOObjects::addPolylineVec(std::vector<Polyline*>&& lines,
153 std::string const& name,
154 PolylineVec::NameIdMap&& ply_names)
155{
156 auto lines_end = std::remove_if(
157 lines.begin(), lines.end(),
158 [](auto const* polyline) { return polyline->getNumberOfPoints() < 2; });
159 lines.erase(lines_end, lines.end());
160
161 if (lines.empty())
162 {
163 return;
164 }
165
166 _ply_vecs.push_back(
167 new PolylineVec(name, std::move(lines), std::move(ply_names)));
168 _callbacks->addPolylineVec(name);
169}
170
171bool GEOObjects::appendPolylineVec(const std::vector<Polyline*>& polylines,
172 const std::string& name)
173{
174 // find an already existing PolylineVec object the given polylines will be
175 // appended to
176 auto polyline_vec_it = findVectorByName(_ply_vecs, name);
177 if (polyline_vec_it == _ply_vecs.end())
178 {
179 return false;
180 }
181 for (auto* polyline : polylines)
182 {
183 (*polyline_vec_it)->push_back(polyline);
184 }
185 _callbacks->appendPolylineVec(name);
186 return true;
187}
188
189const std::vector<Polyline*>* GEOObjects::getPolylineVec(
190 const std::string& name) const
191{
192 std::size_t size(_ply_vecs.size());
193 for (std::size_t i = 0; i < size; i++)
194 {
195 if (_ply_vecs[i]->getName() == name)
196 {
197 return &_ply_vecs[i]->getVector();
198 }
199 }
200
201 DBUG("GEOObjects::getPolylineVec() - No entry found with name '{:s}'.",
202 name);
203 return nullptr;
204}
205
206const PolylineVec* GEOObjects::getPolylineVecObj(const std::string& name) const
207{
208 std::size_t size(_ply_vecs.size());
209 for (std::size_t i = 0; i < size; i++)
210 {
211 if (_ply_vecs[i]->getName() == name)
212 {
213 return _ply_vecs[i];
214 }
215 }
216
217 DBUG("GEOObjects::getPolylineVecObj() - No entry found with name '{:s}'.",
218 name);
219 return nullptr;
220}
221
222bool GEOObjects::removePolylineVec(std::string const& name)
223{
224 _callbacks->removePolylineVec(name);
225 for (auto it = _ply_vecs.begin(); it != _ply_vecs.end(); ++it)
226 {
227 if ((*it)->getName() == name)
228 {
229 delete *it;
230 _ply_vecs.erase(it);
231 return true;
232 }
233 }
234
235 DBUG("GEOObjects::removePolylineVec() - No entry found with name '{:s}'.",
236 name);
237 return false;
238}
239
240void GEOObjects::addSurfaceVec(std::vector<Surface*>&& sfc,
241 const std::string& name,
242 SurfaceVec::NameIdMap&& sfc_names)
243{
244 _sfc_vecs.push_back(
245 new SurfaceVec(name, std::move(sfc), std::move(sfc_names)));
246 _callbacks->addSurfaceVec(name);
247}
248
249bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces,
250 const std::string& name)
251{
252 auto surface_vec_to_append_it = findVectorByName(_sfc_vecs, name);
253 if (surface_vec_to_append_it != _sfc_vecs.end())
254 {
255 for (auto& surface : surfaces)
256 {
257 (*surface_vec_to_append_it)->push_back(surface);
258 }
259 _callbacks->appendSurfaceVec(name);
260 return true;
261 }
262
263 // the copy is needed because addSurfaceVec is passing it to SurfaceVec
264 // ctor, which needs write access to the surface vector.
265 std::vector<GeoLib::Surface*> sfc(begin(surfaces), end(surfaces));
266 addSurfaceVec(std::move(sfc), name, SurfaceVec::NameIdMap{});
267 return false;
268}
269
270const std::vector<Surface*>* GEOObjects::getSurfaceVec(
271 const std::string& name) const
272{
273 auto surface_vec_it = findVectorByName(_sfc_vecs, name);
274 if (surface_vec_it != _sfc_vecs.end())
275 {
276 return &(*surface_vec_it)->getVector();
277 }
278 DBUG("GEOObjects::getSurfaceVec() - No entry found with name '{:s}'.",
279 name);
280 return nullptr;
281}
282
283bool GEOObjects::removeSurfaceVec(const std::string& name)
284{
285 _callbacks->removeSurfaceVec(name);
286 auto const it = findVectorByName(_sfc_vecs, name);
287 if (it != _sfc_vecs.end())
288 {
289 delete *it;
290 _sfc_vecs.erase(it);
291 return true;
292 }
293
294 DBUG("GEOObjects::removeSurfaceVec() - No entry found with name '{:s}'.",
295 name);
296 return false;
297}
298
299const SurfaceVec* GEOObjects::getSurfaceVecObj(const std::string& name) const
300{
301 auto surface_vec_it = findVectorByName(_sfc_vecs, name);
302 if (surface_vec_it != _sfc_vecs.end())
303 {
304 return *surface_vec_it;
305 }
306 DBUG("GEOObjects::getSurfaceVecObj() - No entry found with name '{:s}'.",
307 name);
308 return nullptr;
309}
310
311bool GEOObjects::isUniquePointVecName(std::string& name) const
312{
313 std::vector<std::string> const existing_names = getGeometryNames();
314 auto const& unique_name = BaseLib::getUniqueName(existing_names, name);
315
316 if (unique_name != name)
317 {
318 name = unique_name;
319 return false;
320 }
321 return true;
322}
323
324bool GEOObjects::isPntVecUsed(const std::string& name) const
325{
326 // search for dependent PolylineVecs or SurfaceVecs
327 return findVectorByName(_ply_vecs, name) != _ply_vecs.end() ||
328 findVectorByName(_sfc_vecs, name) != _sfc_vecs.end();
329}
330
331void GEOObjects::getStationVectorNames(std::vector<std::string>& names) const
332{
333 for (auto point : _pnt_vecs)
334 {
335 if (point->getType() == PointVec::PointType::STATION)
336 {
337 names.push_back(point->getName());
338 }
339 }
340}
341
342std::vector<std::string> GEOObjects::getGeometryNames() const
343{
344 std::vector<std::string> names;
345 for (auto point : _pnt_vecs)
346 {
347 if (point->getType() == PointVec::PointType::POINT)
348 {
349 names.push_back(point->getName());
350 }
351 }
352 return names;
353}
354
355std::string GEOObjects::getElementNameByID(const std::string& geometry_name,
356 GeoLib::GEOTYPE type,
357 std::size_t id) const
358{
359 std::string name;
360 switch (type)
361 {
363 this->getPointVecObj(geometry_name)->getNameOfElementByID(id, name);
364 break;
366 this->getPolylineVecObj(geometry_name)
367 ->getNameOfElementByID(id, name);
368 break;
370 this->getSurfaceVecObj(geometry_name)
371 ->getNameOfElementByID(id, name);
372 }
373 return name;
374}
375
376int GEOObjects::mergeGeometries(std::vector<std::string> const& geo_names,
377 std::string& merged_geo_name)
378{
379 const std::size_t n_geo_names(geo_names.size());
380
381 if (n_geo_names < 2)
382 {
383 return 2;
384 }
385
386 std::vector<std::size_t> pnt_offsets(n_geo_names, 0);
387
388 if (!mergePoints(geo_names, merged_geo_name, pnt_offsets))
389 {
390 return 1;
391 }
392
393 mergePolylines(geo_names, merged_geo_name, pnt_offsets);
394
395 mergeSurfaces(geo_names, merged_geo_name, pnt_offsets);
396
397 return 0;
398}
399
400bool GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
401 std::string& merged_geo_name,
402 std::vector<std::size_t>& pnt_offsets)
403{
404 const std::size_t n_geo_names(geo_names.size());
405
406 std::vector<GeoLib::Point*> merged_points;
407 PointVec::NameIdMap merged_pnt_names;
408
409 for (std::size_t j(0); j < n_geo_names; ++j)
410 {
411 GeoLib::PointVec const* const pnt_vec(
412 this->getPointVecObj(geo_names[j]));
413 if (pnt_vec == nullptr)
414 {
415 continue;
416 }
417 auto const& pnts(pnt_vec->getVector());
418
419 // do not consider stations
420 if (dynamic_cast<GeoLib::Station*>(pnts[0]))
421 {
422 continue;
423 }
424
425 std::size_t const n_pnts(pnts.size());
426 for (std::size_t k(0); k < n_pnts; ++k)
427 {
428 merged_points.push_back(
429 new GeoLib::Point(*pnts[k], pnt_offsets[j] + k));
430 std::string const& item_name(pnt_vec->getItemNameByID(k));
431 if (!item_name.empty())
432 {
433 merged_pnt_names.insert(
434 std::make_pair(item_name, pnt_offsets[j] + k));
435 }
436 }
437 if (n_geo_names - 1 > j)
438 {
439 pnt_offsets[j + 1] = n_pnts + pnt_offsets[j];
440 }
441 }
442
443 addPointVec(std::move(merged_points), merged_geo_name,
444 std::move(merged_pnt_names), 1e-6);
445 return true;
446}
447
448void GEOObjects::mergePolylines(std::vector<std::string> const& geo_names,
449 std::string const& merged_geo_name,
450 std::vector<std::size_t> const& pnt_offsets)
451{
452 const std::size_t n_geo_names(geo_names.size());
453 std::vector<std::size_t> ply_offsets(n_geo_names, 0);
454
455 std::vector<GeoLib::Polyline*> merged_polylines;
456 PolylineVec::NameIdMap merged_ply_names;
457
458 auto const& merged_points(getPointVecObj(merged_geo_name)->getVector());
459 std::vector<std::size_t> const& id_map(
460 this->getPointVecObj(merged_geo_name)->getIDMap());
461
462 for (std::size_t j(0); j < n_geo_names; j++)
463 {
464 const std::vector<GeoLib::Polyline*>* plys(
465 this->getPolylineVec(geo_names[j]));
466 if (plys)
467 {
468 std::string tmp_name;
469 for (std::size_t k(0); k < plys->size(); k++)
470 {
471 auto* kth_ply_new(new GeoLib::Polyline(merged_points));
472 GeoLib::Polyline const* const kth_ply_old((*plys)[k]);
473 const std::size_t size_of_kth_ply(
474 kth_ply_old->getNumberOfPoints());
475 // copy point ids from old ply to new ply (considering the
476 // offset)
477 for (std::size_t i(0); i < size_of_kth_ply; i++)
478 {
479 kth_ply_new->addPoint(
480 id_map[pnt_offsets[j] + kth_ply_old->getPointID(i)]);
481 }
482 merged_polylines.push_back(kth_ply_new);
483 if (this->getPolylineVecObj(geo_names[j])
484 ->getNameOfElementByID(k, tmp_name))
485 {
486 merged_ply_names.emplace(tmp_name, ply_offsets[j] + k);
487 }
488 }
489 if (n_geo_names - 1 > j)
490 {
491 ply_offsets[j + 1] = plys->size() + ply_offsets[j];
492 }
493 }
494 }
495
496 if (!merged_polylines.empty())
497 {
498 this->addPolylineVec(std::move(merged_polylines), merged_geo_name,
499 std::move(merged_ply_names));
500 }
501}
502
503void GEOObjects::mergeSurfaces(std::vector<std::string> const& geo_names,
504 std::string const& merged_geo_name,
505 std::vector<std::size_t> const& pnt_offsets)
506{
507 auto const& merged_points(getPointVecObj(merged_geo_name)->getVector());
508 std::vector<std::size_t> const& id_map(
509 this->getPointVecObj(merged_geo_name)->getIDMap());
510
511 const std::size_t n_geo_names(geo_names.size());
512 std::vector<std::size_t> sfc_offsets(n_geo_names, 0);
513 std::vector<GeoLib::Surface*> merged_sfcs;
514 SurfaceVec::NameIdMap merged_sfc_names;
515 for (std::size_t j(0); j < n_geo_names; j++)
516 {
517 const std::vector<GeoLib::Surface*>* sfcs(
518 this->getSurfaceVec(geo_names[j]));
519 if (sfcs)
520 {
521 std::string tmp_name;
522 for (std::size_t k(0); k < sfcs->size(); k++)
523 {
524 auto* kth_sfc_new(new GeoLib::Surface(merged_points));
525 GeoLib::Surface const* const kth_sfc_old((*sfcs)[k]);
526 const std::size_t size_of_kth_sfc(
527 kth_sfc_old->getNumberOfTriangles());
528 // clone surface elements using new ids
529 for (std::size_t i(0); i < size_of_kth_sfc; i++)
530 {
531 const GeoLib::Triangle* tri((*kth_sfc_old)[i]);
532 const std::size_t id0(id_map[pnt_offsets[j] + (*tri)[0]]);
533 const std::size_t id1(id_map[pnt_offsets[j] + (*tri)[1]]);
534 const std::size_t id2(id_map[pnt_offsets[j] + (*tri)[2]]);
535 kth_sfc_new->addTriangle(id0, id1, id2);
536 }
537 merged_sfcs.push_back(kth_sfc_new);
538
539 if (this->getSurfaceVecObj(geo_names[j])
540 ->getNameOfElementByID(k, tmp_name))
541 {
542 merged_sfc_names.emplace(tmp_name, sfc_offsets[j] + k);
543 }
544 }
545 if (n_geo_names - 1 > j)
546 {
547 sfc_offsets[j + 1] = sfcs->size() + sfc_offsets[j];
548 }
549 }
550 }
551 if (!merged_sfcs.empty())
552 {
553 this->addSurfaceVec(std::move(merged_sfcs), merged_geo_name,
554 std::move(merged_sfc_names));
555 }
556}
557
558void GEOObjects::renameGeometry(std::string const& old_name,
559 std::string const& new_name)
560{
561 _callbacks->renameGeometry(old_name, new_name);
562
563 auto rename = [&old_name, &new_name](auto const& container)
564 {
565 auto it = findVectorByName(container, old_name);
566 if (it != container.end())
567 {
568 (*it)->setName(new_name);
569 }
570 };
571
572 rename(_pnt_vecs);
573 rename(_ply_vecs);
574 rename(_sfc_vecs);
575}
576
577void markUnusedPoints(GEOObjects const& geo_objects,
578 std::string const& geo_name,
579 std::vector<bool>& transfer_pnts)
580{
581 GeoLib::PolylineVec const* const ply_obj(
582 geo_objects.getPolylineVecObj(geo_name));
583 if (ply_obj)
584 {
585 std::vector<GeoLib::Polyline*> const& lines(ply_obj->getVector());
586 for (auto* line : lines)
587 {
588 std::size_t const n_pnts(line->getNumberOfPoints());
589 for (std::size_t i = 0; i < n_pnts; ++i)
590 {
591 transfer_pnts[line->getPointID(i)] = false;
592 }
593 }
594 }
595
596 GeoLib::SurfaceVec const* const sfc_obj(
597 geo_objects.getSurfaceVecObj(geo_name));
598 if (sfc_obj)
599 {
600 std::vector<GeoLib::Surface*> const& surfaces = sfc_obj->getVector();
601 for (auto* sfc : surfaces)
602 {
603 std::size_t const n_tri(sfc->getNumberOfTriangles());
604 for (std::size_t i = 0; i < n_tri; ++i)
605 {
606 GeoLib::Triangle const& t = *(*sfc)[i];
607 transfer_pnts[t[0]] = false;
608 transfer_pnts[t[1]] = false;
609 transfer_pnts[t[2]] = false;
610 }
611 }
612 }
613}
614
615int geoPointsToStations(GEOObjects& geo_objects, std::string const& geo_name,
616 std::string& stn_name, bool const only_unused_pnts)
617{
618 GeoLib::PointVec const* const pnt_obj(geo_objects.getPointVecObj(geo_name));
619 if (pnt_obj == nullptr)
620 {
621 ERR("Point vector {:s} not found.", geo_name);
622 return -1;
623 }
624 auto const& pnts = pnt_obj->getVector();
625 if (pnts.empty())
626 {
627 ERR("Point vector {:s} is empty.", geo_name);
628 return -1;
629 }
630 std::size_t const n_pnts(pnts.size());
631 std::vector<bool> transfer_pnts(n_pnts, true);
632 if (only_unused_pnts)
633 {
634 markUnusedPoints(geo_objects, geo_name, transfer_pnts);
635 }
636
637 std::vector<GeoLib::Point*> stations;
638 for (std::size_t i = 0; i < n_pnts; ++i)
639 {
640 if (!transfer_pnts[i])
641 {
642 continue;
643 }
644 std::string name = pnt_obj->getItemNameByID(i);
645 if (name.empty())
646 {
647 name = "Station " + std::to_string(i);
648 }
649 stations.push_back(new GeoLib::Station(pnts[i], name));
650 }
651 if (!stations.empty())
652 {
653 geo_objects.addStationVec(std::move(stations), stn_name);
654 }
655 else
656 {
657 WARN("No points found to convert.");
658 return 1;
659 }
660 return 0;
661}
662
664 const std::string& geo_name,
665 GeoLib::GEOTYPE type,
666 const std::string& geo_obj_name) const
667{
668 GeoLib::GeoObject* geo_obj(nullptr);
669 switch (type)
670 {
672 {
673 GeoLib::PointVec const* pnt_vec(getPointVecObj(geo_name));
674 if (pnt_vec)
675 {
676 geo_obj = const_cast<GeoLib::GeoObject*>(
677 dynamic_cast<GeoLib::GeoObject const*>(
678 pnt_vec->getElementByName(geo_obj_name)));
679 }
680 break;
681 }
683 {
684 GeoLib::PolylineVec const* ply_vec(getPolylineVecObj(geo_name));
685 if (ply_vec)
686 {
687 geo_obj = const_cast<GeoLib::GeoObject*>(
688 dynamic_cast<GeoLib::GeoObject const*>(
689 ply_vec->getElementByName(geo_obj_name)));
690 }
691 break;
692 }
694 {
695 GeoLib::SurfaceVec const* sfc_vec(getSurfaceVecObj(geo_name));
696 if (sfc_vec)
697 {
698 geo_obj = const_cast<GeoLib::GeoObject*>(
699 dynamic_cast<GeoLib::GeoObject const*>(
700 sfc_vec->getElementByName(geo_obj_name)));
701 }
702 break;
703 }
704 default:
705 ERR("GEOObjects::getGeoObject(): geometric type not handled.");
706 return nullptr;
707 };
708
709 if (!geo_obj)
710 {
711 DBUG(
712 "GEOObjects::getGeoObject(): Could not find {:s} '{:s}' in "
713 "geometry.",
715 geo_obj_name);
716 }
717 return geo_obj;
718}
719
721 const std::string& geo_name, const std::string& geo_obj_name) const
722{
723 GeoLib::GeoObject const* geo_obj(
724 getGeoObject(geo_name, GeoLib::GEOTYPE::POINT, geo_obj_name));
725
726 if (!geo_obj)
727 {
728 geo_obj =
729 getGeoObject(geo_name, GeoLib::GEOTYPE::POLYLINE, geo_obj_name);
730 }
731
732 if (!geo_obj)
733 {
734 geo_obj =
735 getGeoObject(geo_name, GeoLib::GEOTYPE::SURFACE, geo_obj_name);
736 }
737
738 if (!geo_obj)
739 {
740 DBUG(
741 "GEOObjects::getGeoObject(): Could not find '{:s}' in geometry "
742 "{:s}.",
743 geo_obj_name, geo_name);
744 }
745 return geo_obj;
746}
747
748std::size_t GEOObjects::exists(const std::string& geometry_name) const
749{
750 std::size_t const size(_pnt_vecs.size());
751 auto const it = findVectorByName(_pnt_vecs, geometry_name);
752 if (it != _pnt_vecs.end())
753 {
754 return std::distance(_pnt_vecs.begin(), it);
755 }
756
757 // HACK for enabling conversion of files without loading the associated
758 // geometry
759 if (size > 0 && _pnt_vecs[0]->getName() == "conversionTestRun#1")
760 {
761 return 1;
762 }
763
764 return std::numeric_limits<std::size_t>::max();
765}
766
767} // namespace GeoLib
Definition of the GEOObjects class.
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:30
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:45
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:40
Definition of the Station class.
Definition of string helper functions.
std::string getName(std::string const &line)
Returns the name/title from the "Zone"-description.
Container class for geometric objects.
Definition: GEOObjects.h:61
void mergeSurfaces(std::vector< std::string > const &geo_names, std::string const &merged_geo_name, std::vector< std::size_t > const &pnt_offsets)
Definition: GEOObjects.cpp:503
std::size_t exists(const std::string &geometry_name) const
Definition: GEOObjects.cpp:748
void mergePolylines(std::vector< std::string > const &geo_names, std::string const &merged_geo_name, std::vector< std::size_t > const &pnt_offsets)
Definition: GEOObjects.cpp:448
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
Definition: GEOObjects.cpp:342
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
Definition: GEOObjects.cpp:152
bool appendSurfaceVec(const std::vector< Surface * > &surfaces, const std::string &name)
Definition: GEOObjects.cpp:249
const std::vector< Point * > * getPointVec(const std::string &name) const
Definition: GEOObjects.cpp:72
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
const PointVec * getPointVecObj(const std::string &name) const
Definition: GEOObjects.cpp:85
void renameGeometry(std::string const &old_name, std::string const &new_name)
Definition: GEOObjects.cpp:558
bool mergePoints(std::vector< std::string > const &geo_names, std::string &merged_geo_name, std::vector< std::size_t > &pnt_offsets)
Definition: GEOObjects.cpp:400
bool removePointVec(const std::string &name)
Definition: GEOObjects.cpp:98
bool isUniquePointVecName(std::string &name) const
Definition: GEOObjects.cpp:311
bool removeSurfaceVec(const std::string &name)
Definition: GEOObjects.cpp:283
void addStationVec(std::vector< Point * > &&stations, std::string &name)
Adds a vector of stations with the given name and colour to GEOObjects.
Definition: GEOObjects.cpp:123
SurfaceVec * getSurfaceVecObj(const std::string &name)
Returns the surface vector with the given name.
Definition: GEOObjects.h:211
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
Definition: GEOObjects.cpp:270
std::vector< PointVec * > _pnt_vecs
Definition: GEOObjects.h:363
std::vector< PolylineVec * > _ply_vecs
Definition: GEOObjects.h:365
std::unique_ptr< Callbacks > _callbacks
Definition: GEOObjects.h:298
void addSurfaceVec(std::vector< Surface * > &&sfc, const std::string &name, SurfaceVec::NameIdMap &&sfc_names)
Definition: GEOObjects.cpp:240
bool isPntVecUsed(const std::string &name) const
Checks if the point vector with the given name is referenced in a polyline- or surface vector.
Definition: GEOObjects.cpp:324
const PolylineVec * getPolylineVecObj(const std::string &name) const
Definition: GEOObjects.cpp:206
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
Definition: GEOObjects.cpp:376
void getStationVectorNames(std::vector< std::string > &names) const
Returns the names of all station vectors.
Definition: GEOObjects.cpp:331
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
Definition: GEOObjects.cpp:189
bool appendPolylineVec(const std::vector< Polyline * > &polylines, const std::string &name)
Definition: GEOObjects.cpp:171
std::vector< SurfaceVec * > _sfc_vecs
Definition: GEOObjects.h:367
const GeoLib::GeoObject * getGeoObject(const std::string &geo_name, GeoLib::GEOTYPE type, const std::string &geo_obj_name) const
Returns the geo object for a geometric item of the given name and type for the associated geometry.
Definition: GEOObjects.cpp:663
const std::vector< GeoLib::Point * > * getStationVec(const std::string &name) const
Returns the station vector with the given name.
Definition: GEOObjects.cpp:133
bool removePolylineVec(const std::string &name)
Definition: GEOObjects.cpp:222
std::string getElementNameByID(const std::string &geometry_name, GeoLib::GEOTYPE type, std::size_t id) const
Definition: GEOObjects.cpp:355
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition: PointVec.h:38
std::string const & getItemNameByID(std::size_t id) const
Definition: PointVec.cpp:248
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition: Polyline.h:42
std::size_t getPointID(std::size_t const i) const
Definition: Polyline.cpp:160
std::size_t getNumberOfPoints() const
Definition: Polyline.cpp:109
A Station (observation site) is basically a Point with some additional information.
Definition: Station.h:37
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Definition: Surface.h:34
std::size_t getNumberOfTriangles() const
Definition: Surface.cpp:82
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
Definition: TemplateVec.h:41
std::map< std::string, std::size_t > NameIdMap
Definition: TemplateVec.h:44
const T * getElementByName(const std::string &name) const
Returns an element with the given name.
Definition: TemplateVec.h:130
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
Definition: TemplateVec.h:151
std::vector< T * > const & getVector() const
Definition: TemplateVec.h:109
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
Definition: Triangle.h:26
GEOTYPE
Definition: GeoType.h:25
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...
Definition: PolylineVec.h:29
std::string getUniqueName(std::vector< std::string > const &existing_names, std::string const &input_name)
Append '-' and a number such that the name is unique.
void cleanupVectorElements(std::vector< T * > &items)
Definition: Algorithm.h:300
std::string convertGeoTypeToString(GEOTYPE geo_type)
Definition: GeoType.cpp:23
int geoPointsToStations(GEOObjects &geo_objects, std::string const &geo_name, std::string &stn_name, bool const only_unused_pnts)
Constructs a station-vector based on the points of a given geometry.
Definition: GEOObjects.cpp:615
auto findVectorByName(Container const &container, std::string const &name)
Definition: GEOObjects.cpp:28
void markUnusedPoints(GEOObjects const &geo_objects, std::string const &geo_name, std::vector< bool > &transfer_pnts)
Definition: GEOObjects.cpp:577
TemplateVec< GeoLib::Surface > SurfaceVec
Definition: SurfaceVec.h:27