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

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

#include <polygon.H>

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

Public Member Functions

 Segment_Iterator (const Polygon &poly)
 Construct a 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

Polygon & poly_
 Reference to the polygon being iterated.
 

Additional Inherited Members

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:521
bool has_curr() const
Check if there is a current segment.
Definition polygon.H:538
Represents a line segment between two points.
Definition point.H:837
std::string to_string() const
Returns a string representation of the segment, e.g., "(x1,y1)(x2,y2)".
Definition point.H:1414

Definition at line 520 of file polygon.H.

Constructor & Destructor Documentation

◆ Segment_Iterator()

Aleph::Polygon::Segment_Iterator::Segment_Iterator ( const Polygon &  poly)
inline

Construct a 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 528 of file polygon.H.

References ah_domain_error_if, Aleph::Dlink::is_unitarian_or_empty(), poly_, and Aleph::Polygon::vertex_list_.

Member Function Documentation

◆ get_current_segment()

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

◆ has_curr()

Member Data Documentation

◆ poly_

Polygon& Aleph::Polygon::Segment_Iterator::poly_
private

Reference to the polygon being iterated.

Definition at line 522 of file polygon.H.

Referenced by Segment_Iterator(), and get_current_segment().


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