OGS
SimplePolygonTree.cpp
Go to the documentation of this file.
1 
15 #include "SimplePolygonTree.h"
16 
17 namespace GeoLib
18 {
20  SimplePolygonTree* parent)
21  : _node_polygon(polygon), _parent(parent)
22 {
23 }
24 
26 {
27  for (auto* child : _children)
28  {
29  delete child;
30  }
31 }
32 
34 {
35  return _parent == nullptr;
36 }
37 
39  const SimplePolygonTree* polygon_hierarchy) const
40 {
41  return _node_polygon->isPolylineInPolygon(polygon_hierarchy->polygon());
42 }
43 
45 {
46  return _parent;
47 }
48 
50  SimplePolygonTree* polygon_hierarchy)
51 {
52  Polygon const& polygon = polygon_hierarchy->polygon();
53  bool nfound(true);
54  for (auto* child : _children)
55  {
56  if (child->polygon().isPolylineInPolygon(polygon))
57  {
58  child->insertSimplePolygonTree(polygon_hierarchy);
59  nfound = false;
60  break;
61  }
62  }
63  if (nfound)
64  {
65  _children.push_back(polygon_hierarchy);
66  polygon_hierarchy->_parent = this;
67  }
68 }
69 
71 {
72  return *_node_polygon;
73 }
75 {
76  return *_node_polygon;
77 }
78 
79 } // end namespace GeoLib
Definition of the SimplePolygonTree class.
bool isPolylineInPolygon(const Polyline &ply) const
Definition: Polygon.cpp:215
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