Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::GenericSegment< PointType > Class Template Reference

Finite line segments. More...

#include <ogdf/basic/geometry.h>

+ Inheritance diagram for ogdf::GenericSegment< PointType >:

Public Member Functions

 GenericSegment ()
 Creates an empty line segment.
 
 GenericSegment (const GenericLine< PointType > &dl)
 Creates a line segment defined by the start and end point of line dl.
 
 GenericSegment (const GenericSegment< PointType > &ds)=default
 Copy constructor.
 
 GenericSegment (const PointType &p1, const PointType &p2)
 Creates a line segment from p1 to p2.
 
 GenericSegment (double x1, double y1, double x2, double y2)
 Creates a line segment from (x1,y1) to (x2,y2).
 
bool contains (const PointType &p) const override
 Returns true iff p lies on this line segment.
 
GenericLine< PointType >::numberType dx () const
 Returns the x-coordinate of the difference (end point - start point).
 
GenericLine< PointType >::numberType dy () const
 Returns the y-coordinate of the difference (end point - start point).
 
const PointTypeend () const
 Returns the end point of the line segment.
 
IntersectionType horIntersection (const double horAxis, double &crossing) const override
 Computes the intersection of this line segment and the horizontal line through y = horAxis.
 
IntersectionType intersection (const GenericSegment< PointType > &segment, PointType &inter, bool endpoints=true) const
 Returns an IntersectionType specifying whether segment and this line segment intersect.
 
double length () const
 Returns the length (Euclidean distance between start and end point) of this line segment.
 
bool operator!= (const GenericSegment< PointType > &dl) const
 Inequality operator.
 
GenericSegmentoperator= (const GenericSegment< PointType > &ds)=default
 Copy assignment operator.
 
bool operator== (const GenericSegment< PointType > &dl) const
 Equality operator.
 
const PointTypestart () const
 Returns the start point of the line segment.
 
IntersectionType verIntersection (const double verAxis, double &crossing) const override
 Computes the intersection between this line segment and the vertical line through x = verAxis.
 
- Public Member Functions inherited from ogdf::GenericLine< PointType >
 GenericLine ()
 Creates an empty line.
 
 GenericLine (const GenericLine< PointType > &dl)
 Copy constructor.
 
 GenericLine (const PointType &p1, const PointType &p2)
 Creates a line through the points p1 and p2.
 
 GenericLine (numberType x1, numberType y1, numberType x2, numberType y2)
 Creates a line through the points (x1,y1) and (x2,y2).
 
virtual bool contains (const DPoint &p) const
 Returns true iff p lies on this line.
 
double det (const GenericLine< PointType > &line) const
 Determines if line is left or right of this line.
 
IntersectionType intersection (const GenericLine< PointType > &line, DPoint &inter) const
 Returns an IntersectionType specifying whether line and this line intersect.
 
bool isHorizontal () const
 Returns true iff this line runs horizontally.
 
bool isVertical () const
 Returns true iff this line runs vertically.
 
bool operator!= (const GenericLine< PointType > &dl) const
 Inequality operator.
 
GenericLine< PointType > & operator= (const GenericLine< PointType > &dl)
 Assignment operator.
 
bool operator== (const GenericLine< PointType > &dl) const
 Equality operator.
 
double slope () const
 Returns the slope of the line.
 
double yAbs () const
 Returns the value y' such that (0,y') lies on the unlimited straight-line defined by this line.
 

Private Member Functions

bool inBoundingRect (const PointType &p, bool includeBorders=true) const
 Returns whether p lies in the rectangle which has m_p1 and m_p2 as opposing corners.
 

Additional Inherited Members

- Public Types inherited from ogdf::GenericLine< PointType >
using numberType = typename PointType::numberType
 
- Protected Member Functions inherited from ogdf::GenericLine< PointType >
numberType dx () const
 Returns the x-coordinate of the difference (second point - first point).
 
numberType dy () const
 Returns the y-coordinate of the difference (second point - first point).
 
- Protected Attributes inherited from ogdf::GenericLine< PointType >
PointType m_p1
 The first point of the line.
 
PointType m_p2
 The second point of the line.
 

Detailed Description

template<class PointType>
class ogdf::GenericSegment< PointType >

Finite line segments.

Definition at line 623 of file geometry.h.

Constructor & Destructor Documentation

◆ GenericSegment() [1/5]

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

Creates an empty line segment.

Definition at line 649 of file geometry.h.

◆ GenericSegment() [2/5]

template<class PointType >
ogdf::GenericSegment< PointType >::GenericSegment ( const PointType p1,
const PointType p2 
)
inline

Creates a line segment from p1 to p2.

Definition at line 652 of file geometry.h.

◆ GenericSegment() [3/5]

template<class PointType >
ogdf::GenericSegment< PointType >::GenericSegment ( const GenericLine< PointType > &  dl)
inlineexplicit

Creates a line segment defined by the start and end point of line dl.

Definition at line 655 of file geometry.h.

◆ GenericSegment() [4/5]

template<class PointType >
ogdf::GenericSegment< PointType >::GenericSegment ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

Creates a line segment from (x1,y1) to (x2,y2).

Definition at line 658 of file geometry.h.

◆ GenericSegment() [5/5]

template<class PointType >
ogdf::GenericSegment< PointType >::GenericSegment ( const GenericSegment< PointType > &  ds)
default

Copy constructor.

Member Function Documentation

◆ contains()

template<class PointType >
bool ogdf::GenericSegment< PointType >::contains ( const PointType p) const
inlineoverride

Returns true iff p lies on this line segment.

Definition at line 727 of file geometry.h.

◆ dx()

Returns the x-coordinate of the difference (end point - start point).

Definition at line 682 of file geometry.h.

◆ dy()

Returns the y-coordinate of the difference (end point - start point).

Definition at line 685 of file geometry.h.

◆ end()

template<class PointType >
const PointType & ogdf::GenericSegment< PointType >::end ( ) const
inline

Returns the end point of the line segment.

Definition at line 679 of file geometry.h.

◆ horIntersection()

template<class PointType >
IntersectionType ogdf::GenericSegment< PointType >::horIntersection ( const double  horAxis,
double crossing 
) const
inlineoverridevirtual

Computes the intersection of this line segment and the horizontal line through y = horAxis.

Parameters
horAxisdefines the horizontal line.
crossingis assigned the x-coordinate of the intersection point.
Returns
the IntersectionType of the intersection between this line segment and horAxis.

Reimplemented from ogdf::GenericLine< PointType >.

Definition at line 743 of file geometry.h.

◆ inBoundingRect()

template<class PointType >
bool ogdf::GenericSegment< PointType >::inBoundingRect ( const PointType p,
bool  includeBorders = true 
) const
inlineprivate

Returns whether p lies in the rectangle which has m_p1 and m_p2 as opposing corners.

Parameters
pis the point to be tested.
includeBordersdetermines whether true is also returned when lies on the borders of the rectangle given by m_p1 and m_p2.

Definition at line 632 of file geometry.h.

◆ intersection()

template<class PointType >
IntersectionType ogdf::GenericSegment< PointType >::intersection ( const GenericSegment< PointType > &  segment,
PointType inter,
bool  endpoints = true 
) const
inline

Returns an IntersectionType specifying whether segment and this line segment intersect.

Parameters
segmentis the second line segment.
interis assigned an intersection point if IntersectionType::SinglePoint or IntersectionType::Overlapping is returned.
endpointsdetermines if common endpoints are treated as potential intersection points.

Definition at line 697 of file geometry.h.

◆ length()

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

Returns the length (Euclidean distance between start and end point) of this line segment.

Definition at line 732 of file geometry.h.

◆ operator!=()

template<class PointType >
bool ogdf::GenericSegment< PointType >::operator!= ( const GenericSegment< PointType > &  dl) const
inline

Inequality operator.

Definition at line 673 of file geometry.h.

◆ operator=()

Copy assignment operator.

◆ operator==()

Equality operator.

Definition at line 668 of file geometry.h.

◆ start()

template<class PointType >
const PointType & ogdf::GenericSegment< PointType >::start ( ) const
inline

Returns the start point of the line segment.

Definition at line 676 of file geometry.h.

◆ verIntersection()

template<class PointType >
IntersectionType ogdf::GenericSegment< PointType >::verIntersection ( const double  verAxis,
double crossing 
) const
inlineoverridevirtual

Computes the intersection between this line segment and the vertical line through x = verAxis.

Parameters
verAxisdefines the vertical line.
crossingis assigned the y-coordinate of the intersection point.
Returns
the IntersectionType of the intersection between this line segment and verAxis.

Reimplemented from ogdf::GenericLine< PointType >.

Definition at line 764 of file geometry.h.


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