Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::DRect Class Reference

Rectangles with real coordinates. More...

#include <ogdf/basic/geometry.h>

+ Inheritance diagram for ogdf::DRect:

Public Member Functions

 DRect ()=default
 Creates a rectangle with lower left and upper right point (0,0).
 
 DRect (const DPoint &p1, const DPoint &p2)
 Creates a rectangle with lower left point p1 and upper right point p2.
 
 DRect (const DRect &dr)
 Copy constructor.
 
 DRect (const DSegment &dl)
 Creates a rectangle defined by the end points of line segment dl.
 
 DRect (double x1, double y1, double x2, double y2)
 Creates a rectangle with lower left point (x1,y1) and upper right point (x2,y2).
 
virtual ~DRect ()=default
 
const DSegment bottom () const
 Returns the bottom side of the rectangle.
 
bool contains (const DPoint &p) const
 Returns true iff p lies within this rectangle, modulo the comparison epsilon OGDF_GEOM_ET.
 
double height () const
 Returns the height of the rectangle.
 
bool intersection (const DSegment &segment) const
 Returns true iff segment intersects this DRect.
 
const DSegment left () const
 Returns the left side of the rectangle.
 
void normalize ()
 Normalizes the rectangle.
 
bool operator!= (const DRect &dr) const
 Inequality operator.
 
DRectoperator= (const DRect &dr)
 Assignment operator.
 
bool operator== (const DRect &dr) const
 Equality operator: both rectangles have the same coordinates.
 
const DPointp1 () const
 Returns the lower left point of the rectangle.
 
const DPointp2 () const
 Returns the upper right point of the rectangle.
 
const DSegment right () const
 Returns the right side of the rectangle.
 
const DSegment top () const
 Returns the top side of the rectangle.
 
double width () const
 Returns the width of the rectangle.
 
void xInvert ()
 Swaps the x-coordinates of the two points.
 
void yInvert ()
 Swaps the y-coordinates of the two points.
 

Protected Member Functions

double parallelDist (const DSegment &d1, const DSegment &d2) const
 Computes distance between parallel line segments.
 
double pointDist (const DPoint &p1, const DPoint &p2) const
 Computes distance between two points.
 

Protected Attributes

DPoint m_p1
 The lower left point of the rectangle.
 
DPoint m_p2
 The upper right point of the rectangle.
 

Friends

std::ostream & operator<< (std::ostream &os, const DRect &dr)
 

Detailed Description

Rectangles with real coordinates.

Definition at line 790 of file geometry.h.

Constructor & Destructor Documentation

◆ DRect() [1/5]

ogdf::DRect::DRect ( )
default

Creates a rectangle with lower left and upper right point (0,0).

◆ DRect() [2/5]

ogdf::DRect::DRect ( const DPoint p1,
const DPoint p2 
)
inline

Creates a rectangle with lower left point p1 and upper right point p2.

Definition at line 802 of file geometry.h.

◆ DRect() [3/5]

ogdf::DRect::DRect ( const DRect dr)
inline

Copy constructor.

Definition at line 805 of file geometry.h.

◆ DRect() [4/5]

ogdf::DRect::DRect ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

Creates a rectangle with lower left point (x1,y1) and upper right point (x2,y2).

Definition at line 808 of file geometry.h.

◆ DRect() [5/5]

ogdf::DRect::DRect ( const DSegment dl)
inlineexplicit

Creates a rectangle defined by the end points of line segment dl.

Definition at line 811 of file geometry.h.

◆ ~DRect()

virtual ogdf::DRect::~DRect ( )
virtualdefault

Member Function Documentation

◆ bottom()

const DSegment ogdf::DRect::bottom ( ) const
inline

Returns the bottom side of the rectangle.

Definition at line 873 of file geometry.h.

◆ contains()

bool ogdf::DRect::contains ( const DPoint p) const
inline

Returns true iff p lies within this rectangle, modulo the comparison epsilon OGDF_GEOM_ET.

Definition at line 884 of file geometry.h.

◆ height()

double ogdf::DRect::height ( ) const
inline

Returns the height of the rectangle.

Definition at line 834 of file geometry.h.

◆ intersection()

bool ogdf::DRect::intersection ( const DSegment segment) const
inline

Returns true iff segment intersects this DRect.

Definition at line 890 of file geometry.h.

◆ left()

const DSegment ogdf::DRect::left ( ) const
inline

Returns the left side of the rectangle.

Definition at line 868 of file geometry.h.

◆ normalize()

void ogdf::DRect::normalize ( )
inline

Normalizes the rectangle.

Makes sure that the lower left point lies below and left of the upper right point.

Definition at line 842 of file geometry.h.

◆ operator!=()

bool ogdf::DRect::operator!= ( const DRect dr) const
inline

Inequality operator.

Definition at line 819 of file geometry.h.

◆ operator=()

DRect & ogdf::DRect::operator= ( const DRect dr)
inline

Assignment operator.

Definition at line 822 of file geometry.h.

◆ operator==()

bool ogdf::DRect::operator== ( const DRect dr) const
inline

Equality operator: both rectangles have the same coordinates.

Definition at line 816 of file geometry.h.

◆ p1()

const DPoint & ogdf::DRect::p1 ( ) const
inline

Returns the lower left point of the rectangle.

Definition at line 852 of file geometry.h.

◆ p2()

const DPoint & ogdf::DRect::p2 ( ) const
inline

Returns the upper right point of the rectangle.

Definition at line 855 of file geometry.h.

◆ parallelDist()

double ogdf::DRect::parallelDist ( const DSegment d1,
const DSegment d2 
) const
protected

Computes distance between parallel line segments.

◆ pointDist()

double ogdf::DRect::pointDist ( const DPoint p1,
const DPoint p2 
) const
inlineprotected

Computes distance between two points.

Definition at line 903 of file geometry.h.

◆ right()

const DSegment ogdf::DRect::right ( ) const
inline

Returns the right side of the rectangle.

Definition at line 863 of file geometry.h.

◆ top()

const DSegment ogdf::DRect::top ( ) const
inline

Returns the top side of the rectangle.

Definition at line 858 of file geometry.h.

◆ width()

double ogdf::DRect::width ( ) const
inline

Returns the width of the rectangle.

Definition at line 831 of file geometry.h.

◆ xInvert()

void ogdf::DRect::xInvert ( )
inline

Swaps the x-coordinates of the two points.

Definition at line 881 of file geometry.h.

◆ yInvert()

void ogdf::DRect::yInvert ( )
inline

Swaps the y-coordinates of the two points.

Definition at line 878 of file geometry.h.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const DRect dr 
)
friend

Member Data Documentation

◆ m_p1

DPoint ogdf::DRect::m_p1
protected

The lower left point of the rectangle.

Definition at line 794 of file geometry.h.

◆ m_p2

DPoint ogdf::DRect::m_p2
protected

The upper right point of the rectangle.

Definition at line 795 of file geometry.h.


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