Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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

Rectangles with real coordinates. More...

#include <ogdf/basic/geometry.h>

+ Inheritance diagram for ogdf::DIntersectableRect:

Public Member Functions

 DIntersectableRect ()=default
 Creates a rectangle with lower left and upper right point (0,0).
 
 DIntersectableRect (const DIntersectableRect &dr)
 Copy constructor.
 
 DIntersectableRect (const DPoint &center, double width, double height)
 Constructs a rectangle from the center point, width and height.
 
 DIntersectableRect (const DPoint &p1, const DPoint &p2)
 Creates a rectangle with lower left point p1 and upper right point p2.
 
 DIntersectableRect (double x1, double y1, double x2, double y2)
 Creates a rectangle with lower left point (x1,y1) and upper right point (x1,y2).
 
double area () const
 Area of the rectangle.
 
DPoint center () const
 Center of the rectangle.
 
double distance (const DIntersectableRect &other) const
 Computes distance between two rectangles.
 
DIntersectableRect intersection (const DIntersectableRect &other) const
 Returns the rectangle resulting from intersection of this and other. Returns a rectangle with zero width and height and center (0,0) if intersection is empty.
 
bool intersects (const DIntersectableRect &rectangle) const
 Tests if this and the argument rectangle intersect.
 
void move (const DPoint &point)
 Moves the rectangle such that its center is at the given point.
 
DIntersectableRectoperator= (const DIntersectableRect &dr)
 Assignment operator.
 
- Public Member Functions inherited from ogdf::DRect
 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.
 

Private Member Functions

void initAreaAndCenter ()
 Normalizes the rectangle.
 

Private Attributes

double m_area = 0.0
 
DPoint m_center
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from ogdf::DRect
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 inherited from ogdf::DRect
DPoint m_p1
 The lower left point of the rectangle.
 
DPoint m_p2
 The upper right point of the rectangle.
 

Detailed Description

Rectangles with real coordinates.

Stores its m_area and m_center and provides methods to compute the intersection with other rectangles.

Definition at line 914 of file geometry.h.

Constructor & Destructor Documentation

◆ DIntersectableRect() [1/5]

ogdf::DIntersectableRect::DIntersectableRect ( )
default

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

◆ DIntersectableRect() [2/5]

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

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

Definition at line 931 of file geometry.h.

◆ DIntersectableRect() [3/5]

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

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

Definition at line 934 of file geometry.h.

◆ DIntersectableRect() [4/5]

ogdf::DIntersectableRect::DIntersectableRect ( const DIntersectableRect dr)
inline

Copy constructor.

Definition at line 938 of file geometry.h.

◆ DIntersectableRect() [5/5]

ogdf::DIntersectableRect::DIntersectableRect ( const DPoint center,
double  width,
double  height 
)
inline

Constructs a rectangle from the center point, width and height.

Definition at line 942 of file geometry.h.

Member Function Documentation

◆ area()

double ogdf::DIntersectableRect::area ( ) const
inline

Area of the rectangle.

Definition at line 961 of file geometry.h.

◆ center()

DPoint ogdf::DIntersectableRect::center ( ) const
inline

Center of the rectangle.

Definition at line 958 of file geometry.h.

◆ distance()

double ogdf::DIntersectableRect::distance ( const DIntersectableRect other) const

Computes distance between two rectangles.

◆ initAreaAndCenter()

void ogdf::DIntersectableRect::initAreaAndCenter ( )
private

Normalizes the rectangle.

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

◆ intersection()

DIntersectableRect ogdf::DIntersectableRect::intersection ( const DIntersectableRect other) const

Returns the rectangle resulting from intersection of this and other. Returns a rectangle with zero width and height and center (0,0) if intersection is empty.

◆ intersects()

bool ogdf::DIntersectableRect::intersects ( const DIntersectableRect rectangle) const

Tests if this and the argument rectangle intersect.

◆ move()

void ogdf::DIntersectableRect::move ( const DPoint point)

Moves the rectangle such that its center is at the given point.

◆ operator=()

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

Assignment operator.

Definition at line 947 of file geometry.h.

Friends And Related Symbol Documentation

◆ operator<<

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

Member Data Documentation

◆ m_area

double ogdf::DIntersectableRect::m_area = 0.0
private

Definition at line 917 of file geometry.h.

◆ m_center

DPoint ogdf::DIntersectableRect::m_center
private

Definition at line 918 of file geometry.h.


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