Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Polygon::Segment_Iterator Class Reference

Iterator over the edges (segments) of a polygon. More...

#include <polygon.H>

Inheritance diagram for Polygon::Segment_Iterator:
[legend]
Collaboration diagram for Polygon::Segment_Iterator:
[legend]

Public Member Functions

 Segment_Iterator (const Polygon &__poly)
 Construct segment iterator from a polygon.
 
bool has_curr () const
 Check if there is a current segment.
 
Segment get_current_segment () const
 Get the current segment (edge).
 

Private Attributes

Polygonpoly
 Reference to the polygon being iterated.
 

Detailed Description

Iterator over the edges (segments) of a polygon.

Provides sequential access to all edges of the polygon. For a closed polygon, this includes the edge from the last vertex back to the first.

for (Polygon::Segment_Iterator it(poly); it.has_curr(); it.next())
{
Segment edge = it.get_current_segment();
std::cout << "Edge: " << edge.to_string() << "\n";
}
Iterator over the edges (segments) of a polygon.
Definition polygon.H:451
Polygon & poly
Reference to the polygon being iterated.
Definition polygon.H:452
bool has_curr() const
Check if there is a current segment.
Definition polygon.H:468
Fundamental segment defined by two points.
Definition point.H:417
DynList< T > maps(const C &c, Op op)
Classic map operation.

Definition at line 450 of file polygon.H.

Constructor & Destructor Documentation

◆ Segment_Iterator()

Polygon::Segment_Iterator::Segment_Iterator ( const Polygon __poly)
inline

Construct segment iterator from a polygon.

Parameters
__polyThe polygon to iterate over.
Exceptions
std::domain_errorIf the polygon has fewer than 2 vertices.

Definition at line 458 of file polygon.H.

References ah_domain_error_if, Aleph::Dlink::is_unitarian_or_empty(), poly, and Polygon::vertex_list.

Member Function Documentation

◆ get_current_segment()

Segment Polygon::Segment_Iterator::get_current_segment ( ) const
inline

Get the current segment (edge).

Returns
The segment from current vertex to the next.
Exceptions
std::domain_errorIf at last vertex of an open polygon.

Definition at line 479 of file polygon.H.

References ah_domain_error_if, Vertex::dlink_to_vertex(), Aleph::get_curr(), Polygon::get_first_vertex(), Polygon::is_closed(), Aleph::maps(), Vertex::next_vertex(), and poly.

Referenced by Polygon::close(), Polygon::contains_to(), and TEST_F().

◆ has_curr()

bool Polygon::Segment_Iterator::has_curr ( ) const
inline

Check if there is a current segment.

Returns
True if a current segment exists.
Note
For open polygons, returns false when at the last vertex.

Definition at line 468 of file polygon.H.

References Aleph::Dlink::Iterator::has_curr(), Polygon::is_closed(), Aleph::maps(), and poly.

Referenced by Polygon::contains_to(), demo_coverage_area(), Aleph::CuttingEarsTriangulation::diagonalie(), Polygon::intersects_with(), TEST_F(), and TEST_F().

Member Data Documentation

◆ poly

Polygon& Polygon::Segment_Iterator::poly
private

Reference to the polygon being iterated.

Definition at line 452 of file polygon.H.

Referenced by Segment_Iterator(), get_current_segment(), and has_curr().


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