27template <
typename Container>
30 return std::find_if(container.begin(), container.end(),
31 [&name](
auto const* vector)
32 { return vector->getName() == name; });
36 std::string
const& geo_name,
37 std::vector<bool>& transfer_pnts);
56 "GEOObjects::addPointVec(): Failed to create PointVec, because "
57 "there aren't any points in the given vector.");
61 std::move(pnt_id_name_map),
73 const std::string& name)
const
75 std::size_t
const idx = this->
exists(name);
76 if (idx != std::numeric_limits<std::size_t>::max())
81 DBUG(
"GEOObjects::getPointVec() - No entry found with name '{:s}'.", name);
87 std::size_t
const idx = this->
exists(name);
88 if (idx != std::numeric_limits<std::size_t>::max())
93 DBUG(
"GEOObjects::getPointVecObj() - No entry found with name '{:s}'.",
103 "GEOObjects::removePointVec() - There are still Polylines or "
104 "Surfaces depending on these points.");
110 if ((*it)->getName() == name)
118 DBUG(
"GEOObjects::removePointVec() - No entry found with name '{:s}'.",
134 const std::string& name)
const
140 return p->getName() == name &&
145 return &(*it)->getVector();
147 DBUG(
"GEOObjects::getStationVec() - No entry found with name '{:s}'.",
153 std::string
const& name,
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());
167 new PolylineVec(name, std::move(lines), std::move(ply_names)));
172 const std::string& name)
181 for (
auto* polyline : polylines)
183 (*polyline_vec_it)->push_back(polyline);
190 const std::string& name)
const
193 for (std::size_t i = 0; i < size; i++)
201 DBUG(
"GEOObjects::getPolylineVec() - No entry found with name '{:s}'.",
209 for (std::size_t i = 0; i < size; i++)
217 DBUG(
"GEOObjects::getPolylineVecObj() - No entry found with name '{:s}'.",
227 { return v->getName() == name; });
235 DBUG(
"GEOObjects::removePolylineVec() - No entry found with name '{:s}'.",
241 const std::string& name,
245 new SurfaceVec(name, std::move(sfc), std::move(sfc_names)));
250 const std::string& name)
253 if (surface_vec_to_append_it !=
_sfc_vecs.end())
255 for (
auto& surface : surfaces)
257 (*surface_vec_to_append_it)->push_back(surface);
265 std::vector<GeoLib::Surface*> sfc(begin(surfaces), end(surfaces));
271 const std::string& name)
const
276 return &(*surface_vec_it)->getVector();
278 DBUG(
"GEOObjects::getSurfaceVec() - No entry found with name '{:s}'.",
294 DBUG(
"GEOObjects::removeSurfaceVec() - No entry found with name '{:s}'.",
304 return *surface_vec_it;
306 DBUG(
"GEOObjects::getSurfaceVecObj() - No entry found with name '{:s}'.",
316 if (unique_name != name)
337 names.push_back(point->getName());
344 std::vector<std::string> names;
349 names.push_back(point->getName());
357 std::size_t
id)
const
377 std::string& merged_geo_name)
379 const std::size_t n_geo_names(geo_names.size());
386 std::vector<std::size_t> pnt_offsets(n_geo_names, 0);
388 mergePoints(geo_names, merged_geo_name, pnt_offsets);
398 std::string& merged_geo_name,
399 std::vector<std::size_t>& pnt_offsets)
401 const std::size_t n_geo_names(geo_names.size());
403 std::vector<GeoLib::Point*> merged_points;
406 for (std::size_t j(0); j < n_geo_names; ++j)
410 if (pnt_vec ==
nullptr)
422 std::size_t
const n_pnts(pnts.size());
423 for (std::size_t k(0); k < n_pnts; ++k)
425 merged_points.push_back(
428 if (!item_name.empty())
430 merged_pnt_names.insert(
431 std::make_pair(item_name, pnt_offsets[j] + k));
434 if (n_geo_names - 1 > j)
436 pnt_offsets[j + 1] = n_pnts + pnt_offsets[j];
440 addPointVec(std::move(merged_points), merged_geo_name,
441 std::move(merged_pnt_names), 1e-6);
445 std::string
const& merged_geo_name,
446 std::vector<std::size_t>
const& pnt_offsets)
448 const std::size_t n_geo_names(geo_names.size());
449 std::vector<std::size_t> ply_offsets(n_geo_names, 0);
451 std::vector<GeoLib::Polyline*> merged_polylines;
454 auto const& merged_points(
getPointVecObj(merged_geo_name)->getVector());
455 std::vector<std::size_t>
const& id_map(
458 for (std::size_t j(0); j < n_geo_names; j++)
460 const std::vector<GeoLib::Polyline*>* plys(
464 std::string tmp_name;
465 for (std::size_t k(0); k < plys->size(); k++)
469 const std::size_t size_of_kth_ply(
473 for (std::size_t i(0); i < size_of_kth_ply; i++)
475 kth_ply_new->addPoint(
476 id_map[pnt_offsets[j] + kth_ply_old->
getPointID(i)]);
478 merged_polylines.push_back(kth_ply_new);
480 ->getNameOfElementByID(k, tmp_name))
482 merged_ply_names.emplace(tmp_name, ply_offsets[j] + k);
485 if (n_geo_names - 1 > j)
487 ply_offsets[j + 1] = plys->size() + ply_offsets[j];
492 if (!merged_polylines.empty())
494 this->
addPolylineVec(std::move(merged_polylines), merged_geo_name,
495 std::move(merged_ply_names));
500 std::string
const& merged_geo_name,
501 std::vector<std::size_t>
const& pnt_offsets)
503 auto const& merged_points(
getPointVecObj(merged_geo_name)->getVector());
504 std::vector<std::size_t>
const& id_map(
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;
511 for (std::size_t j(0); j < n_geo_names; j++)
513 const std::vector<GeoLib::Surface*>* sfcs(
517 std::string tmp_name;
518 for (std::size_t k(0); k < sfcs->size(); k++)
522 const std::size_t size_of_kth_sfc(
525 for (std::size_t i(0); i < size_of_kth_sfc; 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);
533 merged_sfcs.push_back(kth_sfc_new);
536 ->getNameOfElementByID(k, tmp_name))
538 merged_sfc_names.emplace(tmp_name, sfc_offsets[j] + k);
541 if (n_geo_names - 1 > j)
543 sfc_offsets[j + 1] = sfcs->size() + sfc_offsets[j];
547 if (!merged_sfcs.empty())
550 std::move(merged_sfc_names));
555 std::string
const& new_name)
557 _callbacks->renameGeometry(old_name, new_name);
559 auto rename = [&old_name, &new_name](
auto const& container)
562 if (it != container.end())
564 (*it)->setName(new_name);
574 std::string
const& geo_name,
575 std::vector<bool>& transfer_pnts)
581 std::vector<GeoLib::Polyline*>
const& lines(ply_obj->
getVector());
582 for (
auto* line : lines)
584 std::size_t
const n_pnts(line->getNumberOfPoints());
585 for (std::size_t i = 0; i < n_pnts; ++i)
587 transfer_pnts[line->getPointID(i)] =
false;
596 std::vector<GeoLib::Surface*>
const& surfaces = sfc_obj->
getVector();
597 for (
auto* sfc : surfaces)
599 std::size_t
const n_tri(sfc->getNumberOfTriangles());
600 for (std::size_t i = 0; i < n_tri; ++i)
603 transfer_pnts[t[0]] =
false;
604 transfer_pnts[t[1]] =
false;
605 transfer_pnts[t[2]] =
false;
612 std::string& stn_name,
bool const only_unused_pnts)
615 if (pnt_obj ==
nullptr)
617 ERR(
"Point vector {:s} not found.", geo_name);
623 ERR(
"Point vector {:s} is empty.", geo_name);
626 std::size_t
const n_pnts(pnts.size());
627 std::vector<bool> transfer_pnts(n_pnts,
true);
628 if (only_unused_pnts)
633 std::vector<GeoLib::Point*> stations;
634 for (std::size_t i = 0; i < n_pnts; ++i)
636 if (!transfer_pnts[i])
643 name =
"Station " + std::to_string(i);
647 if (!stations.empty())
653 WARN(
"No points found to convert.");
660 const std::string& geo_name,
662 const std::string& geo_obj_name)
const
701 ERR(
"GEOObjects::getGeoObject(): geometric type not handled.");
708 "GEOObjects::getGeoObject(): Could not find {:s} '{:s}' in "
717 const std::string& geo_name,
const std::string& geo_obj_name)
const
737 "GEOObjects::getGeoObject(): Could not find '{:s}' in geometry "
739 geo_obj_name, geo_name);
749 return std::distance(
_pnt_vecs.begin(), it);
755 _pnt_vecs[0]->getName() ==
"conversionTestRun#1")
760 return std::numeric_limits<std::size_t>::max();
Definition of the GEOObjects class.
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Station class.
Container class for geometric objects.
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.
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
std::vector< PolylineVec * > _ply_vecs
std::unique_ptr< Callbacks > _callbacks
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
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...
std::string const & getItemNameByID(std::size_t id) const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::size_t getPointID(std::size_t const i) const
std::size_t getNumberOfPoints() const
A Station (observation site) is basically a Point with some additional information.
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
std::size_t getNumberOfTriangles() const
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
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 ...
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)
std::string convertGeoTypeToString(GEOTYPE geo_type)
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)
TemplateVec< GeoLib::Surface > SurfaceVec
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...