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

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

Definition at line 519 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 527 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

Get the current segment (edge).

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

Definition at line 548 of file polygon.H.

References ah_domain_error_if, Aleph::and, Aleph::divide_and_conquer_partition_dp(), Aleph::Vertex::dlink_to_vertex(), Aleph::Dlink::Iterator::get_curr(), Aleph::Polygon::get_first_vertex(), Aleph::Polygon::is_closed(), Aleph::Dlink::Iterator::is_in_last(), Aleph::Vertex::next_vertex(), poly_, and Aleph::Vertex::to_point().

Referenced by Aleph::Polygon::close(), Aleph::Polygon::is_convex(), and TEST_F().

◆ has_curr()

Member Data Documentation

◆ poly_

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

Reference to the polygon being iterated.

Definition at line 521 of file polygon.H.

Referenced by Segment_Iterator(), and get_current_segment().


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