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