Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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.
 
 GenericPolyline (const GenericPolyline< PointType > &pl)
 Copy constructor.
 
 GenericPolyline (const List< PointType > &pl)
 Creates a polyline using the list of points pl.
 
double length () const
 Returns the Euclidean length of the polyline.
 
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.
 
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.
 
GenericPolyline< PointType > & operator= (const GenericPolyline &pl)
 Assignment operator.
 
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.
 
void unify ()
 Deletes all successive points with equal coordinates.
 
- Public Member Functions inherited from ogdf::List< PointType >
 List ()
 Constructs an empty doubly linked list.
 
 List (const List< PointType > &L)
 Constructs a doubly linked list that is a copy of L.
 
 List (List< PointType > &&L)
 Constructs a doubly linked list containing the elements of L (move semantics).
 
 List (std::initializer_list< PointType > init)
 Constructs a doubly linked list containing the elements in init.
 
int size () const
 Returns the number of elements in the list.
 
const ListPure< PointType > & getListPure () const
 Conversion to const ListPure.
 
List< PointType > & operator= (const List< PointType > &L)
 Assignment operator.
 
List< PointType > & operator= (List< PointType > &&L)
 Assignment operator (move semantics).
 
bool operator== (const List< PointType > &L) const
 Equality operator.
 
bool operator!= (const List< PointType > &L) const
 Inequality operator.
 
iterator pushFront (const PointType &x)
 Adds element x at the beginning of the list.
 
iterator emplaceFront (Args &&... args)
 Adds a new element at the beginning of the list.
 
iterator pushBack (const PointType &x)
 Adds element x at the end of the list.
 
iterator emplaceBack (Args &&... args)
 Adds a new element at the end of the list.
 
iterator insert (const PointType &x, iterator it, Direction dir=Direction::after)
 Inserts element x before or after it.
 
iterator insertBefore (const PointType &x, iterator it)
 Inserts element x before it.
 
iterator insertAfter (const PointType &x, iterator it)
 Inserts element x after it.
 
void popFront ()
 Removes the first element from the list.
 
PointType popFrontRet ()
 Removes the first element from the list and returns it.
 
void popBack ()
 Removes the last element from the list.
 
PointType popBackRet ()
 Removes the last element from the list and returns it.
 
void del (iterator it)
 Removes it from the list.
 
bool removeFirst (const PointType &x)
 Removes the first occurrence of x (if any) from the list.
 
void clear ()
 Removes all elements from the list.
 
void moveToFront (iterator it, List< PointType > &L2)
 Moves it to the begin of the list.
 
void moveToBack (iterator it, List< PointType > &L2)
 Moves it to the end of the list.
 
void moveToSucc (iterator it, List< PointType > &L2, iterator itBefore)
 Moves it after itBefore.
 
void moveToPrec (iterator it, List< PointType > &L2, iterator itAfter)
 Moves it before itAfter.
 
void conc (List< PointType > &L2)
 Appends L2 to this list and makes L2 empty.
 
void concFront (List< PointType > &L2)
 Prepends L2 to this list and makes L2 empty.
 
void swap (List< PointType > &other)
 Exchanges the contents of this list and other in constant time.
 
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.
 

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.
 

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 253 of file geometry.h.

Constructor & Destructor Documentation

◆ GenericPolyline() [1/3]

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

Creates an empty polyline.

Definition at line 256 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 259 of file geometry.h.

◆ GenericPolyline() [3/3]

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

Copy constructor.

Definition at line 262 of file geometry.h.

Member Function Documentation

◆ length()

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

Returns the Euclidean length of the polyline.

Definition at line 271 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
minAnglein [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 420 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
minAnglein [0..Pi] is a lower bound for the smaller angle between two line segments such that the Point between them is still removed.
srcis used as a point that comes before all points in this polyline.
tgtis used as a point that comes after all points in this polyline.

Definition at line 430 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
minAnglein [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 370 of file geometry.h.

◆ operator=()

Assignment operator.

Definition at line 265 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
fractiondefines the fraction of len to be considered.
lenis the given length, or the length of the polyline if len < 0.

Definition at line 296 of file geometry.h.

◆ unify()

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

Deletes all successive points with equal coordinates.

Definition at line 349 of file geometry.h.


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