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

A vertex in a polygon's doubly-linked vertex list. More...

#include <polygon.H>

Inheritance diagram for Vertex:
[legend]
Collaboration diagram for Vertex:
[legend]

Public Member Functions

 Vertex ()
 Default constructor. Creates a vertex at origin (0, 0).
 
 Vertex (const Point &point)
 Construct a vertex from a Point.
 
 Vertex (const Vertex &vertex)
 Copy constructor.
 
Vertexoperator= (const Vertex &vertex)
 Copy assignment operator.
 
const Vertexprev_vertex () const
 Get the previous vertex in the polygon.
 
const Vertexnext_vertex () const
 Get the next vertex in the polygon.
 

Static Public Member Functions

static Vertexdlink_to_vertex (Dlink *link)
 Convert a Dlink pointer to a Vertex pointer.
 
static const Vertexdlink_to_vertex (const Dlink *link)
 Convert a const Dlink pointer to a const Vertex pointer.
 

Additional Inherited Members

Detailed Description

A vertex in a polygon's doubly-linked vertex list.

The Vertex class combines a 2D point with doubly-linked list capabilities. This allows polygons to store their vertices as an intrusive linked list while each vertex retains full Point functionality.

Design

  • Inherits from Point for geometric coordinates.
  • Inherits from Dlink for doubly-linked list traversal.
  • Provides navigation to adjacent vertices in the polygon.
Note
Vertex objects are typically managed by a Polygon and should not be manually linked/unlinked outside of Polygon's methods.
See also
Polygon

Definition at line 112 of file polygon.H.

Constructor & Destructor Documentation

◆ Vertex() [1/3]

Vertex::Vertex ( )
inline

Default constructor. Creates a vertex at origin (0, 0).

Definition at line 116 of file polygon.H.

◆ Vertex() [2/3]

Vertex::Vertex ( const Point point)
inline

Construct a vertex from a Point.

Parameters
pointThe point to copy coordinates from.

Definition at line 122 of file polygon.H.

◆ Vertex() [3/3]

Vertex::Vertex ( const Vertex vertex)
inline

Copy constructor.

Parameters
vertexThe vertex to copy.
Note
Only copies the Point coordinates; does not copy link state.

Definition at line 129 of file polygon.H.

Member Function Documentation

◆ dlink_to_vertex() [1/2]

static const Vertex * Vertex::dlink_to_vertex ( const Dlink link)
inlinestatic

Convert a const Dlink pointer to a const Vertex pointer.

Parameters
linkPointer to a const Dlink that is actually a Vertex.
Returns
Pointer to the const Vertex.

Definition at line 156 of file polygon.H.

◆ dlink_to_vertex() [2/2]

static Vertex * Vertex::dlink_to_vertex ( Dlink link)
inlinestatic

Convert a Dlink pointer to a Vertex pointer.

Parameters
linkPointer to a Dlink that is actually a Vertex.
Returns
Pointer to the Vertex.
Warning
The caller must ensure that link actually points to a Vertex.

Definition at line 148 of file polygon.H.

Referenced by Polygon::copy_points(), Polygon::delete_points(), Polygon::Segment_Iterator::get_current_segment(), Polygon::Vertex_Iterator::get_current_vertex(), Polygon::get_first_vertex(), Polygon::get_last_vertex(), Polygon::get_next_vertex(), Polygon::get_prev_vertex(), next_vertex(), prev_vertex(), TEST_F(), and TEST_F().

◆ next_vertex()

const Vertex & Vertex::next_vertex ( ) const
inline

Get the next vertex in the polygon.

Returns
Reference to the next vertex.
Exceptions
std::domain_errorIf this is the only vertex in the list.
Precondition
The vertex must be part of a polygon with at least 2 vertices.

Definition at line 179 of file polygon.H.

References ah_domain_error_if, dlink_to_vertex(), Aleph::Dlink::get_next(), Aleph::Dlink::is_empty(), Aleph::Dlink::is_unitarian(), and Aleph::maps().

Referenced by Polygon::Segment_Iterator::get_current_segment(), Polygon::get_next_vertex(), and Aleph::CuttingEarsTriangulation::operator()().

◆ operator=()

Vertex & Vertex::operator= ( const Vertex vertex)
inline

Copy assignment operator.

Parameters
vertexThe vertex to copy.
Returns
Reference to this vertex.
Note
Only copies Point coordinates; does not modify link state.

Definition at line 137 of file polygon.H.

◆ prev_vertex()

const Vertex & Vertex::prev_vertex ( ) const
inline

Get the previous vertex in the polygon.

Returns
Reference to the previous vertex.
Exceptions
std::domain_errorIf this is the only vertex in the list.
Precondition
The vertex must be part of a polygon with at least 2 vertices.

Definition at line 165 of file polygon.H.

References ah_domain_error_if, dlink_to_vertex(), Aleph::Dlink::get_prev(), Aleph::Dlink::is_empty(), Aleph::Dlink::is_unitarian(), and Aleph::maps().

Referenced by Polygon::get_prev_vertex().


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