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 auto it = std::find_if(_ply_vecs.begin(), _ply_vecs.end(),
226 [&name](PolylineVec const* const v)
227 { return v->getName() == name; });
228 if (it != _ply_vecs.end())
229 {
230 delete *it;
231 _ply_vecs.erase(it);
232 return true;
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 const* 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 const* 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 mergePoints(geo_names, merged_geo_name, pnt_offsets);
389
390 mergePolylines(geo_names, merged_geo_name, pnt_offsets);
391
392 mergeSurfaces(geo_names, merged_geo_name, pnt_offsets);
393
394 return 0;
395}
396
397void GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
398 std::string& merged_geo_name,
399 std::vector<std::size_t>& pnt_offsets)
400{
401 const std::size_t n_geo_names(geo_names.size());
402
403 std::vector<GeoLib::Point*> merged_points;
404 PointVec::NameIdMap merged_pnt_names;
405
406 for (std::size_t j(0); j < n_geo_names; ++j)
407 {
408 GeoLib::PointVec const* const pnt_vec(
409 this->getPointVecObj(geo_names[j]));
410 if (pnt_vec == nullptr)
411 {
412 continue;
413 }
414 auto const& pnts(pnt_vec->getVector());
415
416 // do not consider stations
417 if (dynamic_cast<GeoLib::Station*>(pnts[0]))
418 {
419 continue;
420 }
421
422 std::size_t const n_pnts(pnts.size());
423 for (std::size_t k(0); k < n_pnts; ++k)
424 {
425 merged_points.push_back(
426 new GeoLib::Point(*pnts[k], pnt_offsets[j] + k));
427 std::string const& item_name(pnt_vec->getItemNameByID(k));
428 if (!item_name.empty())
429 {
430 merged_pnt_names.insert(
431 std::make_pair(item_name, pnt_offsets[j] + k));
432 }
433 }
434 if (n_geo_names - 1 > j)
435 {
436 pnt_offsets[j + 1] = n_pnts + pnt_offsets[j];
437 }
438 }
439
440 addPointVec(std::move(merged_points), merged_geo_name,
441 std::move(merged_pnt_names), 1e-6);
442}
443
444void GEOObjects::mergePolylines(std::vector<std::string> const& geo_names,
445 std::string const& merged_geo_name,
446 std::vector<std::size_t> const& pnt_offsets)
447{
448 const std::size_t n_geo_names(geo_names.size());
449 std::vector<std::size_t> ply_offsets(n_geo_names, 0);
450
451 std::vector<GeoLib::Polyline*> merged_polylines;
452 PolylineVec::NameIdMap merged_ply_names;
453
454 auto const& merged_points(getPointVecObj(merged_geo_name)->getVector());
455 std::vector<std::size_t> const& id_map(
456 this->getPointVecObj(merged_geo_name)->getIDMap());
457
458 for (std::size_t j(0); j < n_geo_names; j++)
459 {
460 const std::vector<GeoLib::Polyline*>* plys(
461 this->getPolylineVec(geo_names[j]));
462 if (plys)
463 {
464 std::string tmp_name;
465 for (std::size_t k(0); k < plys->size(); k++)
466 {
467 auto* kth_ply_new(new GeoLib::Polyline(merged_points));
468 GeoLib::Polyline const* const kth_ply_old((*plys)[k]);
469 const std::size_t size_of_kth_ply(
470 kth_ply_old->getNumberOfPoints());
471 // copy point ids from old ply to new ply (considering the
472 // offset)
473 for (std::size_t i(0); i < size_of_kth_ply; i++)
474 {
475 kth_ply_new->addPoint(
476 id_map[pnt_offsets[j] + kth_ply_old->getPointID(i)]);
477 }
478 merged_polylines.push_back(kth_ply_new);
479 if (this->getPolylineVecObj(geo_names[j])
480 ->getNameOfElementByID(k, tmp_name))
481 {
482 merged_ply_names.emplace(tmp_name, ply_offsets[j] + k);
483 }
484 }
485 if (n_geo_names - 1 > j)
486 {
487 ply_offsets[j + 1] = plys->size() + ply_offsets[j];
488 }
489 }
490 }
491
492 if (!merged_polylines.empty())
493 {
494 this->addPolylineVec(std::move(merged_polylines), merged_geo_name,
495 std::move(merged_ply_names));
496 }
497}
498
499void GEOObjects::mergeSurfaces(std::vector<std::string> const& geo_names,
500 std::string const& merged_geo_name,
501 std::vector<std::size_t> const& pnt_offsets)
502{
503 auto const& merged_points(getPointVecObj(merged_geo_name)->getVector());
504 std::vector<std::size_t> const& id_map(
505 this->getPointVecObj(merged_geo_name)->getIDMap());
506
507 const std::size_t n_geo_names(geo_names.size());
508 std::vector<std::size_t> sfc_offsets(n_geo_names, 0);
509 std::vector<GeoLib::Surface*> merged_sfcs;
510 SurfaceVec::NameIdMap merged_sfc_names;
511 for (std::size_t j(0); j < n_geo_names; j++)
512 {
513 const std::vector<GeoLib::Surface*>* sfcs(
514 this->getSurfaceVec(geo_names[j]));
515 if (sfcs)
516 {
517 std::string tmp_name;
518 for (std::size_t k(0); k < sfcs->size(); k++)
519 {
520 auto* kth_sfc_new(new GeoLib::Surface(merged_points));
521 GeoLib::Surface const* const kth_sfc_old((*sfcs)[k]);
522 const std::size_t size_of_kth_sfc(
523 kth_sfc_old->getNumberOfTriangles());
524 // clone surface elements using new ids
525 for (std::size_t i(0); i < size_of_kth_sfc; i++)
526 {
527 const GeoLib::Triangle* tri((*kth_sfc_old)[i]);
528 const std::size_t id0(id_map[pnt_offsets[j] + (*tri)[0]]);
529 const std::size_t id1(id_map[pnt_offsets[j] + (*tri)[1]]);
530 const std::size_t id2(id_map[pnt_offsets[j] + (*tri)[2]]);
531 kth_sfc_new->addTriangle(id0, id1, id2);
532 }
533 merged_sfcs.push_back(kth_sfc_new);
534
535 if (this->getSurfaceVecObj(geo_names[j])
536 ->getNameOfElementByID(k, tmp_name))
537 {
538 merged_sfc_names.emplace(tmp_name, sfc_offsets[j] + k);
539 }
540 }
541 if (n_geo_names - 1 > j)
542 {
543 sfc_offsets[j + 1] = sfcs->size() + sfc_offsets[j];
544 }
545 }
546 }
547 if (!merged_sfcs.empty())
548 {
549 this->addSurfaceVec(std::move(merged_sfcs), merged_geo_name,
550 std::move(merged_sfc_names));
551 }
552}
553
554void GEOObjects::renameGeometry(std::string const& old_name,
555 std::string const& new_name)
556{
557 _callbacks->renameGeometry(old_name, new_name);
558
559 auto rename = [&old_name, &new_name](auto const& container)
560 {
561 auto it = findVectorByName(container, old_name);
562 if (it != container.end())
563 {
564 (*it)->setName(new_name);
565 }
566 };
567
568 rename(_pnt_vecs);
569 rename(_ply_vecs);
570 rename(_sfc_vecs);
571}
572
573void markUnusedPoints(GEOObjects const& geo_objects,
574 std::string const& geo_name,
575 std::vector<bool>& transfer_pnts)
576{
577 GeoLib::PolylineVec const* const ply_obj(
578 geo_objects.getPolylineVecObj(geo_name));
579 if (ply_obj)
580 {
581 std::vector<GeoLib::Polyline*> const& lines(ply_obj->getVector());
582 for (auto* line : lines)
583 {
584 std::size_t const n_pnts(line->getNumberOfPoints());
585 for (std::size_t i = 0; i < n_pnts; ++i)
586 {
587 transfer_pnts[line->getPointID(i)] = false;
588 }
589 }
590 }
591
592 GeoLib::SurfaceVec const* const sfc_obj(
593 geo_objects.getSurfaceVecObj(geo_name));
594 if (sfc_obj)
595 {
596 std::vector<GeoLib::Surface*> const& surfaces = sfc_obj->getVector();
597 for (auto* sfc : surfaces)
598 {
599 std::size_t const n_tri(sfc->getNumberOfTriangles());
600 for (std::size_t i = 0; i < n_tri; ++i)
601 {
602 GeoLib::Triangle const& t = *(*sfc)[i];
603 transfer_pnts[t[0]] = false;
604 transfer_pnts[t[1]] = false;
605 transfer_pnts[t[2]] = false;
606 }
607 }
608 }
609}
610
611int geoPointsToStations(GEOObjects& geo_objects, std::string const& geo_name,
612 std::string& stn_name, bool const only_unused_pnts)
613{
614 GeoLib::PointVec const* const pnt_obj(geo_objects.getPointVecObj(geo_name));
615 if (pnt_obj == nullptr)
616 {
617 ERR("Point vector {:s} not found.", geo_name);
618 return -1;
619 }
620 auto const& pnts = pnt_obj->getVector();
621 if (pnts.empty())
622 {
623 ERR("Point vector {:s} is empty.", geo_name);
624 return -1;
625 }
626 std::size_t const n_pnts(pnts.size());
627 std::vector<bool> transfer_pnts(n_pnts, true);
628 if (only_unused_pnts)
629 {
630 markUnusedPoints(geo_objects, geo_name, transfer_pnts);
631 }
632
633 std::vector<GeoLib::Point*> stations;
634 for (std::size_t i = 0; i < n_pnts; ++i)
635 {
636 if (!transfer_pnts[i])
637 {
638 continue;
639 }
640 std::string name = pnt_obj->getItemNameByID(i);
641 if (name.empty())
642 {
643 name = "Station " + std::to_string(i);
644 }
645 stations.push_back(new GeoLib::Station(pnts[i], name));
646 }
647 if (!stations.empty())
648 {
649 geo_objects.addStationVec(std::move(stations), stn_name);
650 }
651 else
652 {
653 WARN("No points found to convert.");
654 return 1;
655 }
656 return 0;
657}
658
660 const std::string& geo_name,
661 GeoLib::GEOTYPE type,
662 const std::string& geo_obj_name) const
663{
664 GeoLib::GeoObject* geo_obj(nullptr);
665 switch (type)
666 {
668 {
669 GeoLib::PointVec const* pnt_vec(getPointVecObj(geo_name));
670 if (pnt_vec)
671 {
672 geo_obj = const_cast<GeoLib::GeoObject*>(
673 dynamic_cast<GeoLib::GeoObject const*>(
674 pnt_vec->getElementByName(geo_obj_name)));
675 }
676 break;
677 }
679 {
680 GeoLib::PolylineVec const* ply_vec(getPolylineVecObj(geo_name));
681 if (ply_vec)
682 {
683 geo_obj = const_cast<GeoLib::GeoObject*>(
684 dynamic_cast<GeoLib::GeoObject const*>(
685 ply_vec->getElementByName(geo_obj_name)));
686 }
687 break;
688 }
690 {
691 GeoLib::SurfaceVec const* sfc_vec(getSurfaceVecObj(geo_name));
692 if (sfc_vec)
693 {
694 geo_obj = const_cast<GeoLib::GeoObject*>(
695 dynamic_cast<GeoLib::GeoObject const*>(
696 sfc_vec->getElementByName(geo_obj_name)));
697 }
698 break;
699 }
700 default:
701 ERR("GEOObjects::getGeoObject(): geometric type not handled.");
702 return nullptr;
703 };
704
705 if (!geo_obj)
706 {
707 DBUG(
708 "GEOObjects::getGeoObject(): Could not find {:s} '{:s}' in "
709 "geometry.",
711 geo_obj_name);
712 }
713 return geo_obj;
714}
715
717 const std::string& geo_name, const std::string& geo_obj_name) const
718{
719 GeoLib::GeoObject const* geo_obj(
720 getGeoObject(geo_name, GeoLib::GEOTYPE::POINT, geo_obj_name));
721
722 if (!geo_obj)
723 {
724 geo_obj =
725 getGeoObject(geo_name, GeoLib::GEOTYPE::POLYLINE, geo_obj_name);
726 }
727
728 if (!geo_obj)
729 {
730 geo_obj =
731 getGeoObject(geo_name, GeoLib::GEOTYPE::SURFACE, geo_obj_name);
732 }
733
734 if (!geo_obj)
735 {
736 DBUG(
737 "GEOObjects::getGeoObject(): Could not find '{:s}' in geometry "
738 "{:s}.",
739 geo_obj_name, geo_name);
740 }
741 return geo_obj;
742}
743
744std::size_t GEOObjects::exists(const std::string& geometry_name) const
745{
746 if (auto const it = findVectorByName(_pnt_vecs, geometry_name);
747 it != _pnt_vecs.end())
748 {
749 return std::distance(_pnt_vecs.begin(), it);
750 }
751
752 // HACK for enabling conversion of files without loading the associated
753 // geometry
754 if (_pnt_vecs.size() > 0 &&
755 _pnt_vecs[0]->getName() == "conversionTestRun#1")
756 {
757 return 1;
758 }
759
760 return std::numeric_limits<std::size_t>::max();
761}
762
763} // 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:57
void mergeSurfaces(std::vector< std::string > const &geo_names, std::string const &merged_geo_name, std::vector< std::size_t > const &pnt_offsets)
std::size_t exists(const std::string &geometry_name) const
void mergePolylines(std::vector< std::string > const &geo_names, std::string const &merged_geo_name, std::vector< std::size_t > const &pnt_offsets)
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
bool appendSurfaceVec(const std::vector< Surface * > &surfaces, const std::string &name)
const std::vector< Point * > * getPointVec(const std::string &name) const
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()))
const PointVec * getPointVecObj(const std::string &name) const
void renameGeometry(std::string const &old_name, std::string const &new_name)
bool removePointVec(const std::string &name)
bool isUniquePointVecName(std::string &name) const
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.
void mergePoints(std::vector< std::string > const &geo_names, std::string &merged_geo_name, std::vector< std::size_t > &pnt_offsets)
SurfaceVec * getSurfaceVecObj(const std::string &name)
Returns the surface vector with the given name.
Definition GEOObjects.h:208
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
std::vector< PointVec * > _pnt_vecs
Definition GEOObjects.h:367
std::vector< PolylineVec * > _ply_vecs
Definition GEOObjects.h:369
std::unique_ptr< Callbacks > _callbacks
Definition GEOObjects.h:303
void addSurfaceVec(std::vector< Surface * > &&sfc, const std::string &name, SurfaceVec::NameIdMap &&sfc_names)
bool isPntVecUsed(const std::string &name) const
const PolylineVec * getPolylineVecObj(const std::string &name) const
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
void getStationVectorNames(std::vector< std::string > &names) const
Returns the names of all station vectors.
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
bool appendPolylineVec(const std::vector< Polyline * > &polylines, const std::string &name)
std::vector< SurfaceVec * > _sfc_vecs
Definition GEOObjects.h:371
const GeoLib::GeoObject * getGeoObject(const std::string &geo_name, GeoLib::GEOTYPE type, const std::string &geo_obj_name) const
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)
std::string getElementNameByID(const std::string &geometry_name, GeoLib::GEOTYPE type, std::size_t id) const
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition PointVec.h:36
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:40
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:33
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...
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:41
const T * getElementByName(const std::string &name) const
Returns an element with the given name.
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
std::vector< T * > const & getVector() const
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
Definition Triangle.h:27
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:256
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.
auto findVectorByName(Container const &container, std::string const &name)
GEOTYPE
Definition GeoType.h:23
TemplateVec< GeoLib::Surface > SurfaceVec
Definition SurfaceVec.h:28
void markUnusedPoints(GEOObjects const &geo_objects, std::string const &geo_name, std::vector< bool > &transfer_pnts)
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...
Definition PolylineVec.h:27