27 std::string
const& geo_name,
28 std::vector<bool>& transfer_pnts);
53 std::unique_ptr<std::map<std::string, std::size_t>>
58 if (!points || points->empty())
61 "GEOObjects::addPointVec(): Failed to create PointVec, because "
62 "there aren't any points in the given vector.");
66 std::move(pnt_id_name_map),
72 const std::string&
name)
const
74 std::size_t
const idx = this->
exists(name);
75 if (idx != std::numeric_limits<std::size_t>::max())
80 DBUG(
"GEOObjects::getPointVec() - No entry found with name '{:s}'.",
name);
86 std::size_t
const idx = this->
exists(name);
87 if (idx != std::numeric_limits<std::size_t>::max())
92 DBUG(
"GEOObjects::getPointVecObj() - No entry found with name '{:s}'.",
102 "GEOObjects::removePointVec() - There are still Polylines or "
103 "Surfaces depending on these points.");
109 if ((*it)->getName() ==
name)
117 DBUG(
"GEOObjects::removePointVec() - No entry found with name '{:s}'.",
132 const std::string&
name)
const
138 return p->getName() ==
name &&
143 return (*it)->getVector();
145 DBUG(
"GEOObjects::getStationVec() - No entry found with name '{:s}'.",
151 std::unique_ptr<std::vector<Polyline*>> lines,
152 const std::string&
name,
153 std::unique_ptr<std::map<std::string, std::size_t>>
157 for (
auto it(lines->begin()); it != lines->end();)
159 if ((*it)->getNumberOfPoints() < 2)
162 it = lines->erase(it_erase);
181 const std::string&
name)
186 for (idx = 0; idx <
_ply_vecs.size() && nfound; idx++)
197 std::size_t n_plys(polylines.size());
199 for (std::size_t k(0); k < n_plys; k++)
211 const std::string&
name)
const
214 for (std::size_t i = 0; i < size; i++)
222 DBUG(
"GEOObjects::getPolylineVec() - No entry found with name '{:s}'.",
230 for (std::size_t i = 0; i < size; i++)
238 DBUG(
"GEOObjects::getPolylineVecObj() - No entry found with name '{:s}'.",
248 if ((*it)->getName() ==
name)
256 DBUG(
"GEOObjects::removePolylineVec() - No entry found with name '{:s}'.",
262 std::unique_ptr<std::vector<Surface*>> sfc,
263 const std::string&
name,
264 std::unique_ptr<std::map<std::string, std::size_t>>
273 const std::string&
name)
278 for (idx = 0; idx <
_sfc_vecs.size() && nfound; idx++)
289 std::size_t n_sfcs(surfaces.size());
291 for (std::size_t k(0); k < n_sfcs; k++)
301 auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(begin(surfaces),
308 const std::string&
name)
const
311 for (std::size_t i = 0; i < size; i++)
318 DBUG(
"GEOObjects::getSurfaceVec() - No entry found with name '{:s}'.",
328 if ((*it)->getName() ==
name)
336 DBUG(
"GEOObjects::removeSurfaceVec() - No entry found with name '{:s}'.",
344 for (std::size_t i = 0; i < size; i++)
351 DBUG(
"GEOObjects::getSurfaceVecObj() - No entry found with name '{:s}'.",
361 if (unique_name !=
name)
374 if (polyline->getName() ==
name)
381 if (surface->getName() ==
name)
396 names.push_back(point->getName());
403 std::vector<std::string> names;
408 names.push_back(point->getName());
416 std::size_t
id)
const
436 std::string& merged_geo_name)
438 const std::size_t n_geo_names(geo_names.size());
445 std::vector<std::size_t> pnt_offsets(n_geo_names, 0);
447 if (!
mergePoints(geo_names, merged_geo_name, pnt_offsets))
460 std::string& merged_geo_name,
461 std::vector<std::size_t>& pnt_offsets)
463 const std::size_t n_geo_names(geo_names.size());
465 auto merged_points = std::make_unique<std::vector<GeoLib::Point*>>();
466 auto merged_pnt_names =
467 std::make_unique<std::map<std::string, std::size_t>>();
469 for (std::size_t j(0); j < n_geo_names; ++j)
473 if (pnt_vec ==
nullptr)
477 const std::vector<GeoLib::Point*>* pnts(pnt_vec->
getVector());
489 std::size_t
const n_pnts(pnts->size());
490 for (std::size_t k(0); k < n_pnts; ++k)
492 merged_points->push_back(
495 if (!item_name.empty())
497 merged_pnt_names->insert(
498 std::make_pair(item_name, pnt_offsets[j] + k));
501 if (n_geo_names - 1 > j)
503 pnt_offsets[j + 1] = n_pnts + pnt_offsets[j];
507 addPointVec(std::move(merged_points), merged_geo_name,
508 std::move(merged_pnt_names), 1e-6);
513 std::string
const& merged_geo_name,
514 std::vector<std::size_t>
const& pnt_offsets)
516 const std::size_t n_geo_names(geo_names.size());
517 std::vector<std::size_t> ply_offsets(n_geo_names, 0);
519 auto merged_polylines = std::make_unique<std::vector<GeoLib::Polyline*>>();
520 auto merged_ply_names =
521 std::make_unique<std::map<std::string, std::size_t>>();
523 std::vector<GeoLib::Point*>
const* merged_points(
525 std::vector<std::size_t>
const& id_map(
528 for (std::size_t j(0); j < n_geo_names; j++)
530 const std::vector<GeoLib::Polyline*>* plys(
534 std::string tmp_name;
535 for (std::size_t k(0); k < plys->size(); k++)
539 const std::size_t size_of_kth_ply(
543 for (std::size_t i(0); i < size_of_kth_ply; i++)
545 kth_ply_new->addPoint(
546 id_map[pnt_offsets[j] + kth_ply_old->
getPointID(i)]);
548 merged_polylines->push_back(kth_ply_new);
550 ->getNameOfElementByID(k, tmp_name))
552 merged_ply_names->insert(
553 std::pair<std::string, std::size_t>(
554 tmp_name, ply_offsets[j] + k));
557 if (n_geo_names - 1 > j)
559 ply_offsets[j + 1] = plys->size() + ply_offsets[j];
564 if (!merged_polylines->empty())
566 this->
addPolylineVec(std::move(merged_polylines), merged_geo_name,
567 std::move(merged_ply_names));
572 std::string
const& merged_geo_name,
573 std::vector<std::size_t>
const& pnt_offsets)
575 std::vector<GeoLib::Point*>
const* merged_points(
577 std::vector<std::size_t>
const& id_map(
580 const std::size_t n_geo_names(geo_names.size());
581 std::vector<std::size_t> sfc_offsets(n_geo_names, 0);
582 auto merged_sfcs = std::make_unique<std::vector<GeoLib::Surface*>>();
583 auto merged_sfc_names =
584 std::make_unique<std::map<std::string, std::size_t>>();
585 for (std::size_t j(0); j < n_geo_names; j++)
587 const std::vector<GeoLib::Surface*>* sfcs(
591 std::string tmp_name;
592 for (std::size_t k(0); k < sfcs->size(); k++)
596 const std::size_t size_of_kth_sfc(
599 for (std::size_t i(0); i < size_of_kth_sfc; i++)
602 const std::size_t id0(id_map[pnt_offsets[j] + (*tri)[0]]);
603 const std::size_t id1(id_map[pnt_offsets[j] + (*tri)[1]]);
604 const std::size_t id2(id_map[pnt_offsets[j] + (*tri)[2]]);
605 kth_sfc_new->addTriangle(id0, id1, id2);
607 merged_sfcs->push_back(kth_sfc_new);
610 ->getNameOfElementByID(k, tmp_name))
612 merged_sfc_names->insert(
613 std::pair<std::string, std::size_t>(
614 tmp_name, sfc_offsets[j] + k));
617 if (n_geo_names - 1 > j)
619 sfc_offsets[j + 1] = sfcs->size() + sfc_offsets[j];
623 if (!merged_sfcs->empty())
626 std::move(merged_sfc_names));
631 std::string
const& new_name)
633 _callbacks->renameGeometry(old_name, new_name);
636 if (pnt_vec->getName() == old_name)
638 pnt_vec->setName(new_name);
644 if (ply_vec->getName() == old_name)
646 ply_vec->setName(new_name);
652 if (sfc_vec->getName() == old_name)
654 sfc_vec->setName(new_name);
661 std::string
const& geo_name,
662 std::vector<bool>& transfer_pnts)
668 std::vector<GeoLib::Polyline*>
const& lines(*ply_obj->
getVector());
669 for (
auto* line : lines)
671 std::size_t
const n_pnts(line->getNumberOfPoints());
672 for (std::size_t i = 0; i < n_pnts; ++i)
674 transfer_pnts[line->getPointID(i)] =
false;
683 std::vector<GeoLib::Surface*>
const& surfaces = *sfc_obj->
getVector();
684 for (
auto* sfc : surfaces)
686 std::size_t
const n_tri(sfc->getNumberOfTriangles());
687 for (std::size_t i = 0; i < n_tri; ++i)
690 transfer_pnts[t[0]] =
false;
691 transfer_pnts[t[1]] =
false;
692 transfer_pnts[t[2]] =
false;
699 std::string& stn_name,
bool const only_unused_pnts)
702 if (pnt_obj ==
nullptr)
704 ERR(
"Point vector {:s} not found.", geo_name);
707 std::vector<GeoLib::Point*>
const& pnts = *pnt_obj->
getVector();
710 ERR(
"Point vector {:s} is empty.", geo_name);
713 std::size_t
const n_pnts(pnts.size());
714 std::vector<bool> transfer_pnts(n_pnts,
true);
715 if (only_unused_pnts)
720 auto stations = std::make_unique<std::vector<GeoLib::Point*>>();
721 for (std::size_t i = 0; i < n_pnts; ++i)
723 if (!transfer_pnts[i])
730 name =
"Station " + std::to_string(i);
734 if (!stations->empty())
740 WARN(
"No points found to convert.");
747 const std::string& geo_name,
749 const std::string& geo_obj_name)
const
788 ERR(
"GEOObjects::getGeoObject(): geometric type not handled.");
795 "GEOObjects::getGeoObject(): Could not find {:s} '{:s}' in "
804 const std::string& geo_name,
const std::string& geo_obj_name)
const
824 "GEOObjects::getGeoObject(): Could not find '{:s}' in geometry "
826 geo_obj_name, geo_name);
833 std::size_t
const size(
_pnt_vecs.size());
834 for (std::size_t i = 0; i < size; i++)
849 return std::numeric_limits<std::size_t>::max();
Definition of the GEOObjects class.
void ERR(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
void WARN(char const *fmt, Args const &... 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.
bool appendSurfaceVec(const std::vector< Surface * > &surfaces, const std::string &name)
void addStationVec(std::unique_ptr< std::vector< Point * >> stations, std::string &name)
Adds a vector of stations with the given name and colour to GEOObjects.
void addSurfaceVec(std::unique_ptr< std::vector< Surface * >> sfc, const std::string &name, std::unique_ptr< std::map< std::string, std::size_t >> sfc_names=nullptr)
const std::vector< Point * > * getPointVec(const std::string &name) const
const PointVec * getPointVecObj(const std::string &name) const
void renameGeometry(std::string const &old_name, std::string const &new_name)
bool mergePoints(std::vector< std::string > const &geo_names, std::string &merged_geo_name, std::vector< std::size_t > &pnt_offsets)
bool removePointVec(const std::string &name)
bool isUniquePointVecName(std::string &name) const
bool removeSurfaceVec(const std::string &name)
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()))
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
SurfaceVec * getSurfaceVecObj(const std::string &name)
Returns the surface vector with the given name.
bool isPntVecUsed(const std::string &name) const
Checks if the point vector with the given name is referenced in a polyline- or surface vector.
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
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)
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
Returns the geo object for a geometric item of the given name and type for the associated geometry.
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 deletin...
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 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...
const std::vector< T * > * getVector() const
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
const T * getElementByName(const std::string &name) const
Returns an element with the given name.
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
TemplateVec< GeoLib::Polyline > PolylineVec
class PolylineVec encapsulate a std::vector of Polylines additional one can give the vector of polyli...
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.
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.
void markUnusedPoints(GEOObjects const &geo_objects, std::string const &geo_name, std::vector< bool > &transfer_pnts)
TemplateVec< GeoLib::Surface > SurfaceVec