OGS
SimplePolygonTree.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <list>
18
19// GeoLib
20#include "Polygon.h"
21
22namespace GeoLib
23{
31{
32public:
40 virtual ~SimplePolygonTree();
45 bool isRoot() const;
46
47 bool isPolygonInside(const SimplePolygonTree* polygon_hierarchy) const;
51 void insertSimplePolygonTree(SimplePolygonTree* polygon_hierarchy);
52
53 Polygon const& polygon() const;
55
56 const SimplePolygonTree* parent() const;
57
59 std::size_t getNumberOfChildren() const { return _children.size(); }
60
61private:
66
71 std::list<SimplePolygonTree*> _children;
77
78public:
79 decltype(_children)::const_iterator begin() const
80 {
81 return _children.begin();
82 }
83 decltype(_children)::const_iterator end() const { return _children.end(); }
84};
85
89template <typename POLYGONTREETYPE>
91 std::list<POLYGONTREETYPE*>& list_of_simple_polygon_hierarchies)
92{
93 for (auto it0 = list_of_simple_polygon_hierarchies.begin();
94 it0 != list_of_simple_polygon_hierarchies.end();
95 ++it0)
96 {
97 auto it1 = list_of_simple_polygon_hierarchies.begin();
98 while (it1 != list_of_simple_polygon_hierarchies.end())
99 {
100 if (it0 == it1)
101 { // don't check same polygons
102 ++it1;
103 // skip test if it1 points to the end after increment
104 if (it1 == list_of_simple_polygon_hierarchies.end())
105 {
106 break;
107 }
108 }
109 if ((*it0)->isPolygonInside(*it1))
110 {
111 (*it0)->insertSimplePolygonTree(*it1);
112 it1 = list_of_simple_polygon_hierarchies.erase(it1);
113 }
114 else
115 {
116 ++it1;
117 }
118 }
119 }
120}
121
122} // end namespace GeoLib
Definition of the Polygon class.
This class computes and stores the topological relations between polygons. Every node of the SimplePo...
std::list< SimplePolygonTree * > _children
decltype(_children) ::const_iterator end() const
bool isPolygonInside(const SimplePolygonTree *polygon_hierarchy) const
SimplePolygonTree(Polygon *polygon, SimplePolygonTree *parent)
const SimplePolygonTree * parent() const
void insertSimplePolygonTree(SimplePolygonTree *polygon_hierarchy)
decltype(_children) ::const_iterator begin() const
std::size_t getNumberOfChildren() const
Polygon const & polygon() const
SimplePolygonTree * _parent
void createPolygonTrees(std::list< POLYGONTREETYPE * > &list_of_simple_polygon_hierarchies)