OGS
PointVec.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "AABB.h"
23 #include "OctTree.h"
24 #include "Point.h"
25 #include "TemplateVec.h"
26 
27 namespace GeoLib
28 {
37 class PointVec final : public TemplateVec<Point>
38 {
39 public:
41  enum class PointType
42  {
43  POINT = 0,
44  STATION = 1
45  };
46 
67  PointVec(const std::string& name,
68  std::unique_ptr<std::vector<Point*>>
69  points,
70  std::unique_ptr<std::map<std::string, std::size_t>> name_id_map =
71  nullptr,
73  double rel_eps = std::numeric_limits<double>::epsilon());
74 
83  std::size_t push_back(Point* pnt);
84 
90  void push_back(Point* pnt, std::string const* const name) override;
91 
95  PointType getType() const { return _type; }
96 
97  const std::vector<std::size_t>& getIDMap() const { return _pnt_id_map; }
98 
99  const GeoLib::AABB& getAABB() const;
100 
101  std::string const& getItemNameByID(std::size_t id) const;
102 
103  void setNameForElement(std::size_t id, std::string const& name) override;
104 
111 
112 private:
117  void correctNameIDMapping();
118 
119  PointVec(PointVec&&) = delete;
120  PointVec(const PointVec&) = delete;
121  PointVec() = delete;
122  PointVec& operator=(const PointVec& rhs) = delete;
123  PointVec& operator=(PointVec&& rhs) = delete;
124 
136  std::size_t uniqueInsert(Point* pnt);
137 
140 
145  std::vector<std::size_t> _pnt_id_map;
146 
149  std::vector<std::string> _id_to_name_map;
150 
152  double _rel_eps;
153  std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 16>> _oct_tree;
154 };
155 } // namespace GeoLib
Definition of the AABB class.
Implementation of the OctTree class.
Definition of the GeoLib::TemplateVec class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition: PointVec.h:38
std::vector< std::string > _id_to_name_map
Definition: PointVec.h:149
const GeoLib::AABB & getAABB() const
double _rel_eps
Definition: PointVec.h:152
PointType getType() const
Definition: PointVec.h:95
PointType _type
Definition: PointVec.h:139
std::unique_ptr< GeoLib::OctTree< GeoLib::Point, 16 > > _oct_tree
Definition: PointVec.h:153
std::vector< std::size_t > _pnt_id_map
Definition: PointVec.h:145
std::size_t uniqueInsert(Point *pnt)
Definition: PointVec.cpp:161
void setNameForElement(std::size_t id, std::string const &name) override
Sets the given name for the element of the given ID.
Definition: PointVec.cpp:249
std::size_t push_back(Point *pnt)
Definition: PointVec.cpp:129
const std::vector< std::size_t > & getIDMap() const
Definition: PointVec.h:97
std::string const & getItemNameByID(std::size_t id) const
Definition: PointVec.cpp:244
PointVec(const PointVec &)=delete
PointType
Signals if the vector contains object of type Point or Station.
Definition: PointVec.h:42
PointVec & operator=(const PointVec &rhs)=delete
void correctNameIDMapping()
Definition: PointVec.cpp:201
PointVec(PointVec &&)=delete
void resetInternalDataStructures()
Definition: PointVec.cpp:255
PointVec & operator=(PointVec &&rhs)=delete
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
Definition: TemplateVec.h:40