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 {
29 
38 class PointVec final : public TemplateVec<Point>
39 {
40 public:
42  enum class PointType
43  {
44  POINT = 0,
45  STATION = 1
46  };
47 
68  PointVec(const std::string& name,
69  std::unique_ptr<std::vector<Point*>>
70  points,
71  std::unique_ptr<std::map<std::string, std::size_t>> name_id_map =
72  nullptr,
74  double rel_eps = std::numeric_limits<double>::epsilon());
75 
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 private:
115  void correctNameIDMapping();
116 
118  // compiler does not create a (possible unwanted) copy constructor
119  PointVec (const PointVec &);
121  // compiler does not create a (possible unwanted) standard constructor
123 
125  // this way the compiler does not create a (possible unwanted) assignment operator
127 
139  std::size_t uniqueInsert (Point* pnt);
140 
143 
148  std::vector<std::size_t> _pnt_id_map;
149 
152  std::vector<std::string> _id_to_name_map;
153 
155  double _rel_eps;
156  std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 16>> _oct_tree;
157 };
158 } // 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 deletin...
Definition: PointVec.h:39
std::vector< std::string > _id_to_name_map
Definition: PointVec.h:152
const GeoLib::AABB & getAABB() const
double _rel_eps
Definition: PointVec.h:155
PointType getType() const
Definition: PointVec.h:95
PointType _type
Definition: PointVec.h:142
std::unique_ptr< GeoLib::OctTree< GeoLib::Point, 16 > > _oct_tree
Definition: PointVec.h:156
std::vector< std::size_t > _pnt_id_map
Definition: PointVec.h:148
std::size_t uniqueInsert(Point *pnt)
Definition: PointVec.cpp:161
PointVec(const PointVec &)
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 & operator=(const PointVec &rhs)
PointType
Signals if the vector contains object of type Point or Station.
Definition: PointVec.h:43
void correctNameIDMapping()
Definition: PointVec.cpp:201
void resetInternalDataStructures()
Definition: PointVec.cpp:255
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
Definition: TemplateVec.h:40