OGS
SimplePolygonTree.cpp
Go to the documentation of this file.
1
15#include "SimplePolygonTree.h"
16
17#include <range/v3/algorithm/find_if.hpp>
18
19namespace GeoLib
20{
22 SimplePolygonTree* parent)
23 : _node_polygon(polygon), _parent(parent)
24{
25}
26
28{
29 for (auto const* child : _children)
30 {
31 delete child;
32 }
33}
34
36{
37 return _parent == nullptr;
38}
39
41 const SimplePolygonTree* polygon_hierarchy) const
42{
43 return _node_polygon->isPolylineInPolygon(polygon_hierarchy->polygon());
44}
45
47{
48 return _parent;
49}
50
52 SimplePolygonTree* polygon_hierarchy)
53{
54 auto const child = ranges::find_if(
55 _children, [&p = polygon_hierarchy->polygon()](auto const* c)
56 { return c->polygon().isPolylineInPolygon(p); });
57
58 if (child != std::end(_children))
59 {
60 (*child)->insertSimplePolygonTree(polygon_hierarchy);
61 }
62 else
63 {
64 _children.push_back(polygon_hierarchy);
65 polygon_hierarchy->_parent = this;
66 }
67}
68
74{
75 return *_node_polygon;
76}
77
78} // end namespace GeoLib
Definition of the SimplePolygonTree class.
bool isPolylineInPolygon(const Polyline &ply) const
Definition Polygon.cpp:332
This class computes and stores the topological relations between polygons. Every node of the SimplePo...
std::list< SimplePolygonTree * > _children
bool isPolygonInside(const SimplePolygonTree *polygon_hierarchy) const
SimplePolygonTree(Polygon *polygon, SimplePolygonTree *parent)
const SimplePolygonTree * parent() const
void insertSimplePolygonTree(SimplePolygonTree *polygon_hierarchy)
Polygon const & polygon() const
SimplePolygonTree * _parent