# OpenGraph DrawingFramework

v. 2022.02 (Dogwood)

ogdf::GenericPolyline< PointType > Class Template Reference

Polylines with PointType points. More...

#include <ogdf/basic/geometry.h>

Inheritance diagram for ogdf::GenericPolyline< PointType >:

## Public Member Functions

GenericPolyline ()
Creates an empty polyline. More...

GenericPolyline (const GenericPolyline< PointType > &pl)
Copy constructor. More...

GenericPolyline (const List< PointType > &pl)
Creates a polyline using the list of points pl. More...

double length () const
Returns the Euclidean length of the polyline. More...

void normalize (double minAngle=Math::pi)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points. More...

void normalize (PointType src, PointType tgt, double minAngle=Math::pi)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points. More...

GenericPolyline< PointType > & operator= (const GenericPolyline &pl)
Assignment operator. More...

DPoint position (const double fraction, double len=-1.0) const
Returns a point on the polyline which is fraction * len away from the start point. More...

void unify ()
Deletes all successive points with equal coordinates. More...

Public Member Functions inherited from ogdf::List< PointType >
List ()
Constructs an empty doubly linked list. More...

List (const List< PointType > &L)
Constructs a doubly linked list that is a copy of L. More...

List (List< PointType > &&L)
Constructs a doubly linked list containing the elements of L (move semantics). More...

List (std::initializer_list< PointType > init)
Constructs a doubly linked list containing the elements in init. More...

int size () const
Returns the number of elements in the list. More...

const ListPure< PointType > & getListPure () const
Conversion to const ListPure. More...

List< PointType > & operator= (const List< PointType > &L)
Assignment operator. More...

List< PointType > & operator= (List< PointType > &&L)
Assignment operator (move semantics). More...

bool operator== (const List< PointType > &L) const
Equality operator. More...

bool operator!= (const List< PointType > &L) const
Inequality operator. More...

iterator pushFront (const PointType &x)
Adds element x at the beginning of the list. More...

iterator emplaceFront (Args &&... args)
Adds a new element at the beginning of the list. More...

iterator pushBack (const PointType &x)
Adds element x at the end of the list. More...

iterator emplaceBack (Args &&... args)
Adds a new element at the end of the list. More...

iterator insert (const PointType &x, iterator it, Direction dir=Direction::after)
Inserts element x before or after it. More...

iterator insertBefore (const PointType &x, iterator it)
Inserts element x before it. More...

iterator insertAfter (const PointType &x, iterator it)
Inserts element x after it. More...

void popFront ()
Removes the first element from the list. More...

PointType popFrontRet ()
Removes the first element from the list and returns it. More...

void popBack ()
Removes the last element from the list. More...

PointType popBackRet ()
Removes the last element from the list and returns it. More...

void del (iterator it)
Removes it from the list. More...

bool removeFirst (const PointType &x)
Removes the first occurrence of x (if any) from the list. More...

void clear ()
Removes all elements from the list. More...

void moveToFront (iterator it, List< PointType > &L2)
Moves it to the begin of the list. More...

void moveToBack (iterator it, List< PointType > &L2)
Moves it to the end of the list. More...

void moveToSucc (iterator it, List< PointType > &L2, iterator itBefore)
Moves it after itBefore. More...

void moveToPrec (iterator it, List< PointType > &L2, iterator itAfter)
Moves it before itAfter. More...

void conc (List< PointType > &L2)
Appends L2 to this list and makes L2 empty. More...

void concFront (List< PointType > &L2)
Prepends L2 to this list and makes L2 empty. More...

void swap (List< PointType > &other)
Exchanges the contents of this list and other in constant time. More...

void split (iterator it, List< PointType > &L1, List< PointType > &L2, Direction dir=Direction::before)
Splits the list at element it into lists L1 and L2. More...

## Protected Member Functions

void normalizeUnified (double minAngle)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points. More...

## Detailed Description

### template<class PointType> class ogdf::GenericPolyline< PointType >

Polylines with PointType points.

This class represents polylines by a list of PointType points. Such polylines are, e.g., used in layouts for representing bend point lists. Note that in this case, only the bend points are in the list and neither the start nor the end point.

Definition at line 263 of file geometry.h.

## ◆ GenericPolyline() [1/3]

template<class PointType >
 ogdf::GenericPolyline< PointType >::GenericPolyline ( )
inline

Creates an empty polyline.

Definition at line 266 of file geometry.h.

## ◆ GenericPolyline() [2/3]

template<class PointType >
 ogdf::GenericPolyline< PointType >::GenericPolyline ( const List< PointType > & pl )
inline

Creates a polyline using the list of points pl.

Definition at line 269 of file geometry.h.

## ◆ GenericPolyline() [3/3]

template<class PointType >
 ogdf::GenericPolyline< PointType >::GenericPolyline ( const GenericPolyline< PointType > & pl )
inline

Copy constructor.

Definition at line 272 of file geometry.h.

## ◆ length()

template<class PointType >
 double ogdf::GenericPolyline< PointType >::length ( ) const
inline

Returns the Euclidean length of the polyline.

Definition at line 281 of file geometry.h.

## ◆ normalize() [1/2]

template<class PointType >
 void ogdf::GenericPolyline< PointType >::normalize ( double minAngle = Math::pi )
inline

Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points.

How straight the line has to be depends on minAngle. If this parameter is omitted, only points on completely straight lines are removed.

In each iteration look at three points of the polyline, the middle one being a candidate for deletion. If it is deleted, advance in the polyline by one point. If it is not deleted, go back in the polyline by one point (the deletion might have lead to a greater angle between the points before and behind the deleted one). Repeat this process until the end of the polyline is reached.

Parameters
 minAngle in [0..Pi] is a lower bound for the smaller angle between two line segments such that the Point between them is still removed.

Definition at line 418 of file geometry.h.

## ◆ normalize() [2/2]

template<class PointType >
 void ogdf::GenericPolyline< PointType >::normalize ( PointType src, PointType tgt, double minAngle = Math::pi )
inline

Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points.

How straight the line has to be depends on minAngle. If this parameter is omitted, only points on completely straight lines are removed.

In each iteration look at three points of the polyline, the middle one being a candidate for deletion. If it is deleted, advance in the polyline by one point. If it is not deleted, go back in the polyline by one point (the deletion might have lead to a greater angle between the points before and behind the deleted one). Repeat this process until the end of the polyline is reached.

Parameters
 minAngle in [0..Pi] is a lower bound for the smaller angle between two line segments such that the Point between them is still removed. src is used as a point that comes before all points in this polyline. tgt is used as a point that comes after all points in this polyline.

Definition at line 428 of file geometry.h.

## ◆ normalizeUnified()

template<class PointType >
 void ogdf::GenericPolyline< PointType >::normalizeUnified ( double minAngle )
inlineprotected

Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adjacent points.

How straight the line has to be depends on minAngle. If this parameter is omitted, only points on completely straight lines are removed.

In each iteration look at three points of the polyline, the middle one being a candidate for deletion. If it is deleted, advance in the polyline by one point. If it is not deleted, go back in the polyline by one point (the deletion might have lead to a greater angle between the points before and behind the deleted one). Repeat this process until the end of the polyline is reached.

Parameters
 minAngle in [0..Pi] is a lower bound for the smaller angle between two line segments such that the Point between them is still removed.
Precondition
This polyline must be unified using ogdf::GenericPolyline<PointType>::unify().

Definition at line 373 of file geometry.h.

## ◆ operator=()

template<class PointType >
 GenericPolyline& ogdf::GenericPolyline< PointType >::operator= ( const GenericPolyline< PointType > & pl )
inline

Assignment operator.

Definition at line 275 of file geometry.h.

## ◆ position()

template<class PointType >
 DPoint ogdf::GenericPolyline< PointType >::position ( const double fraction, double len = -1.0 ) const
inline

Returns a point on the polyline which is fraction * len away from the start point.

Parameters
 fraction defines the fraction of len to be considered. len is the given length, or the length of the polyline if len < 0.

Definition at line 306 of file geometry.h.

## ◆ unify()

template<class PointType >
 void ogdf::GenericPolyline< PointType >::unify ( )
inline

Deletes all successive points with equal coordinates.

Definition at line 355 of file geometry.h.

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