OGS
GeoLib::SimplePolygonTree Class Reference

Detailed Description

This class computes and stores the topological relations between polygons. Every node of the SimplePolygonTree represents a polygon. A child node c of a parent node p mean that the polygon represented by c is contained in the polygon represented by p.

Definition at line 30 of file SimplePolygonTree.h.

#include <SimplePolygonTree.h>

Inheritance diagram for GeoLib::SimplePolygonTree:
[legend]
Collaboration diagram for GeoLib::SimplePolygonTree:
[legend]

Public Member Functions

 SimplePolygonTree (Polygon *polygon, SimplePolygonTree *parent)
 
virtual ~SimplePolygonTree ()
 
bool isRoot () const
 
bool isPolygonInside (const SimplePolygonTree *polygon_hierarchy) const
 
void insertSimplePolygonTree (SimplePolygonTree *polygon_hierarchy)
 
Polygon const & polygon () const
 
Polygonpolygon ()
 
const SimplePolygonTreeparent () const
 
std::size_t getNumberOfChildren () const
 
decltype(_children) ::const_iterator begin () const
 
decltype(_children) ::const_iterator end () const
 

Private Attributes

Polygon_node_polygon
 
std::list< SimplePolygonTree * > _children
 
SimplePolygonTree_parent
 

Constructor & Destructor Documentation

◆ SimplePolygonTree()

GeoLib::SimplePolygonTree::SimplePolygonTree ( Polygon * polygon,
SimplePolygonTree * parent )

Creates a node of a tree containing a simple polygon.

Parameters
polygonthe polygon represented by this tree node
parentpointer to the parent node within the tree or nullptr (if SimplePolygonTree node is the root node of the tree)

Definition at line 21 of file SimplePolygonTree.cpp.

24{
25}
const SimplePolygonTree * parent() const
Polygon const & polygon() const
SimplePolygonTree * _parent

◆ ~SimplePolygonTree()

GeoLib::SimplePolygonTree::~SimplePolygonTree ( )
virtual

Destructor: Attention: does not destroy the polygon!

Definition at line 27 of file SimplePolygonTree.cpp.

28{
29 for (auto const* child : _children)
30 {
31 delete child;
32 }
33}
std::list< SimplePolygonTree * > _children

References _children.

Member Function Documentation

◆ begin()

decltype(_children) ::const_iterator GeoLib::SimplePolygonTree::begin ( ) const
inline

Definition at line 79 of file SimplePolygonTree.h.

80 {
81 return _children.begin();
82 }

References _children.

◆ end()

decltype(_children) ::const_iterator GeoLib::SimplePolygonTree::end ( ) const
inline

Definition at line 83 of file SimplePolygonTree.h.

83{ return _children.end(); }

References _children.

◆ getNumberOfChildren()

std::size_t GeoLib::SimplePolygonTree::getNumberOfChildren ( ) const
inline

returns the number of children

Definition at line 59 of file SimplePolygonTree.h.

59{ return _children.size(); }

References _children.

◆ insertSimplePolygonTree()

void GeoLib::SimplePolygonTree::insertSimplePolygonTree ( SimplePolygonTree * polygon_hierarchy)

Either insert the given SimplePolygonTree in one of the existing children or as a new child.

Definition at line 51 of file SimplePolygonTree.cpp.

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}

References _children, _parent, and polygon().

◆ isPolygonInside()

bool GeoLib::SimplePolygonTree::isPolygonInside ( const SimplePolygonTree * polygon_hierarchy) const

Definition at line 40 of file SimplePolygonTree.cpp.

42{
43 return _node_polygon->isPolylineInPolygon(polygon_hierarchy->polygon());
44}
bool isPolylineInPolygon(const Polyline &ply) const
Definition Polygon.cpp:332

References _node_polygon, GeoLib::Polygon::isPolylineInPolygon(), and polygon().

◆ isRoot()

bool GeoLib::SimplePolygonTree::isRoot ( ) const

Checks if the polygon represented by the given polygon tree node is inside this node polygon.

Definition at line 35 of file SimplePolygonTree.cpp.

36{
37 return _parent == nullptr;
38}

References _parent.

Referenced by FileIO::GMSH::GMSHPolygonTree::~GMSHPolygonTree(), FileIO::GMSH::GMSHPolygonTree::markSharedSegments(), and FileIO::GMSH::GMSHPolygonTree::writeSubPolygonsAsLineConstraints().

◆ parent()

const SimplePolygonTree * GeoLib::SimplePolygonTree::parent ( ) const

◆ polygon() [1/2]

Polygon & GeoLib::SimplePolygonTree::polygon ( )

Definition at line 69 of file SimplePolygonTree.cpp.

70{
71 return *_node_polygon;
72}

References _node_polygon.

◆ polygon() [2/2]

Member Data Documentation

◆ _children

std::list<SimplePolygonTree*> GeoLib::SimplePolygonTree::_children
private

list of polygons (represented by SimplePolygonTree nodes) contained in the _node_polygon

Definition at line 71 of file SimplePolygonTree.h.

Referenced by ~SimplePolygonTree(), begin(), end(), getNumberOfChildren(), and insertSimplePolygonTree().

◆ _node_polygon

Polygon* GeoLib::SimplePolygonTree::_node_polygon
private

the polygon this node stands for

Definition at line 65 of file SimplePolygonTree.h.

Referenced by isPolygonInside(), polygon(), and polygon().

◆ _parent

SimplePolygonTree* GeoLib::SimplePolygonTree::_parent
private

the polygon represented by this node is contained in the polygon represented by the parent node in the tree

Definition at line 76 of file SimplePolygonTree.h.

Referenced by insertSimplePolygonTree(), isRoot(), and parent().


The documentation for this class was generated from the following files: