153 return sqrt(dx * dx + dy * dy);
228 os <<
"(" << p.
m_x <<
"," << p.
m_y <<
")";
252template<
class Po
intType>
280 while (iter.
valid()) {
281 len += (*iter).distance(*pred);
315 double DX = 0,
DY = 0;
316 while (iter.
valid()) {
317 DX = (*iter).m_x - (*pred).m_x;
318 DY = (*iter).m_y - (*pred).m_y;
354 for (
iter = next = this->
begin(), ++next; next.
valid() && (this->
size() > 2); ++next) {
355 if (*
iter == *next) {
378 while (
iter.valid()) {
386 if (!
onext.valid()) {
447template<
class Po
intType>
517 return dx() * line.
dy() -
dy() * line.
dx();
608template<
class Po
intType>
611 os <<
"Line: vertical with x = " << line.
m_p1.m_x;
613 os <<
"Line: f(x) = " << line.
slope() <<
"x + " << line.
yAbs();
622template<
class Po
intType>
778template<
class Po
intType>
780 os <<
"Segment-Start: " <<
dl.start() <<
", Segment-End: " <<
dl.end();
844 std::swap(m_p2.
m_x, m_p1.
m_x);
847 std::swap(m_p2.
m_y, m_p1.
m_y);
944 DPoint(center.m_x + width / 2, center.m_y + height / 2)) {};
951 m_center =
dr.m_center;
961 double area()
const {
return m_area; }
1006 m_counterclock =
dop.m_counterclock;
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Declaration of classes used for hashing.
Declaration of doubly linked lists and iterators.
The parameterized class Array implements dynamic arrays of type E.
Rectangles with real coordinates.
DIntersectableRect()=default
Creates a rectangle with lower left and upper right point (0,0).
DPoint center() const
Center of the rectangle.
double area() const
Area of the rectangle.
DIntersectableRect(double x1, double y1, double x2, double y2)
Creates a rectangle with lower left point (x1,y1) and upper right point (x1,y2).
DIntersectableRect(const DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
void move(const DPoint &point)
Moves the rectangle such that its center is at the given point.
friend std::ostream & operator<<(std::ostream &os, const DIntersectableRect &dr)
double distance(const DIntersectableRect &other) const
Computes distance between two rectangles.
DIntersectableRect(const DIntersectableRect &dr)
Copy constructor.
bool intersects(const DIntersectableRect &rectangle) const
Tests if this and the argument rectangle intersect.
DIntersectableRect & operator=(const DIntersectableRect &dr)
Assignment operator.
DIntersectableRect intersection(const DIntersectableRect &other) const
Returns the rectangle resulting from intersection of this and other. Returns a rectangle with zero wi...
void initAreaAndCenter()
Normalizes the rectangle.
DIntersectableRect(const DPoint ¢er, double width, double height)
Constructs a rectangle from the center point, width and height.
Polygons with real coordinates.
DPolygon(const DRect &rect, bool cc=true)
Creates a polgon from a rectangle.
ListIterator< DPoint > insertPoint(const DPoint &p, ListIterator< DPoint > p1, ListIterator< DPoint > p2)
Inserts point p, but just searching from point p1 to p2.
DSegment segment(ListConstIterator< DPoint > it) const
Returns the line segment that starts at position it.
bool counterclock()
Returns true iff points are given in counter-clockwise order.
int getCrossPoints(const DPolygon &p, List< DPoint > &crossPoints) const
Returns the list of intersection points of this polygon with p.
void insertCrossPoint(const DPoint &p)
Inserts point p on every segment (a,b) with p in the open range ]a, b[.
DPolygon & operator=(const DPolygon &dop)
Assignment operator.
DPolygon(bool cc=true)
Creates an empty polygon.
bool containsPoint(DPoint &p) const
Checks wether a Point /a p is inside the Poylgon or not.
bool m_counterclock
If true points are given in conter-clockwise order.
DPolygon & operator=(const DRect &rect)
Assignment operator (for assigning from a rectangle).
DPolygon(const DPolygon &dop)
Copy constructor.
void normalize()
Deletes all points, which are not facets.
ListIterator< DPoint > insertPoint(const DPoint &p)
Inserts point p, that must lie on a polygon segment.
void unify()
Deletes all consecutive points that are equal.
Rectangles with real coordinates.
double parallelDist(const DSegment &d1, const DSegment &d2) const
Computes distance between parallel line segments.
bool operator==(const DRect &dr) const
Equality operator: both rectangles have the same coordinates.
const DSegment bottom() const
Returns the bottom side of the rectangle.
double pointDist(const DPoint &p1, const DPoint &p2) const
Computes distance between two points.
DRect()=default
Creates a rectangle with lower left and upper right point (0,0).
bool intersection(const DSegment &segment) const
Returns true iff segment intersects this DRect.
void normalize()
Normalizes the rectangle.
void xInvert()
Swaps the x-coordinates of the two points.
double height() const
Returns the height of the rectangle.
bool contains(const DPoint &p) const
Returns true iff p lies within this rectangle, modulo the comparison epsilon OGDF_GEOM_ET.
void yInvert()
Swaps the y-coordinates of the two points.
const DSegment right() const
Returns the right side of the rectangle.
const DPoint & p1() const
Returns the lower left point of the rectangle.
const DSegment top() const
Returns the top side of the rectangle.
DRect(const DSegment &dl)
Creates a rectangle defined by the end points of line segment dl.
DPoint m_p2
The upper right point of the rectangle.
friend std::ostream & operator<<(std::ostream &os, const DRect &dr)
bool operator!=(const DRect &dr) const
Inequality operator.
DPoint m_p1
The lower left point of the rectangle.
const DPoint & p2() const
Returns the upper right point of the rectangle.
DRect(double x1, double y1, double x2, double y2)
Creates a rectangle with lower left point (x1,y1) and upper right point (x2,y2).
DRect(const DRect &dr)
Copy constructor.
DRect(const DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
DRect & operator=(const DRect &dr)
Assignment operator.
const DSegment left() const
Returns the left side of the rectangle.
double width() const
Returns the width of the rectangle.
int hash(const IPoint &ip) const
std::enable_if< std::is_integral< T >::value, bool >::type leq(const T &x, const T &y) const
Compare if x is LEQ than y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type geq(const T &x, const T &y) const
Compare if x is GEQ to y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type less(const T &x, const T &y) const
Compare if x is LESS than y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type equal(const T &x, const T &y) const
Compare if x is EQUAL to y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type greater(const T &x, const T &y) const
Compare if x is GREATER than y for integral types.
bool operator!=(const GenericLine< PointType > &dl) const
Inequality operator.
GenericLine< PointType > & operator=(const GenericLine< PointType > &dl)
Assignment operator.
PointType m_p1
The first point of the line.
PointType m_p2
The second point of the line.
numberType dx() const
Returns the x-coordinate of the difference (second point - first point).
virtual IntersectionType verIntersection(const double verAxis, double &crossing) const
Computes the intersection between this line and the vertical line through x = verAxis.
virtual IntersectionType horIntersection(const double horAxis, double &crossing) const
Computes the intersection of this line and the horizontal line through y = horAxis.
numberType dy() const
Returns the y-coordinate of the difference (second point - first point).
double slope() const
Returns the slope of the 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.
GenericLine()
Creates an empty line.
bool isVertical() const
Returns true iff this line runs vertically.
bool isHorizontal() const
Returns true iff this line runs horizontally.
IntersectionType intersection(const GenericLine< PointType > &line, DPoint &inter) const
Returns an IntersectionType specifying whether line and this line intersect.
bool operator==(const GenericLine< PointType > &dl) const
Equality operator.
typename PointType::numberType numberType
double det(const GenericLine< PointType > &line) const
Determines if line is left or right of this line.
double yAbs() const
Returns the value y' such that (0,y') lies on the unlimited straight-line defined by this line.
Parameterized base class for points.
double norm() const
Returns the norm of the point.
T operator*(const GenericPoint< T > &dv) const
Returns the scalar product of this and dv.
GenericPoint< T > & operator*=(T c)
Point-wise multiplies this with c.
GenericPoint< T > & operator/=(T c)
Point-wise divide this by c.
bool operator<(const GenericPoint< T > &p) const
Operator 'less'. Returns true iff the x coordinate of this is less than the x coordinate of p or,...
GenericPoint< T > & operator-=(const GenericPoint< T > &p)
Subtracts p from this.
GenericPoint(T x=0, T y=0)
Creates a generic point (x,y).
double angle(GenericPoint< T > q, GenericPoint< T > r) const
Compute angle (in radians) between vectors.
friend GenericPoint< T > operator*(T c, const GenericPoint< T > &p)
Point-wise multiplies p with c.
GenericPoint< T > & operator+=(const GenericPoint< T > &p)
Adds p to this.
friend GenericPoint< T > operator*(const GenericPoint< T > &p, T c)
Point-wise multiplies p with c.
bool operator==(const GenericPoint< T > &dp) const
Equality operator.
double angleDegrees(GenericPoint< T > q, GenericPoint< T > r) const
Compute angle (in degrees) between vectors.
GenericPoint< T > orthogonal() const
Returns a vector that is orthogonal to this vector.
T determinant(const GenericPoint< T > &dv) const
Returns the determinant of the matrix (this, dv).
double distance(const GenericPoint< T > &p) const
Returns the Euclidean distance between p and this point.
GenericPoint< T > & operator=(const GenericPoint< T > &p)
Assignment operator.
bool operator>(const GenericPoint< T > &p) const
Operator 'greater'. Returns true iff p is less than this.
GenericPoint(const GenericPoint< T > &p)
Copy constructor.
bool operator!=(const GenericPoint< T > &p) const
Inequality operator.
T numberType
The type for coordinates of the point.
friend GenericPoint< T > operator/(const GenericPoint< T > &p, double c)
Point-wise divide p by c.
GenericPoint< T > operator+(const GenericPoint< T > &p) const
Addition of points.
GenericPoint< T > operator-(const GenericPoint< T > &p) const
Subtraction of points.
Polylines with PointType points.
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.
GenericPolyline< PointType > & operator=(const GenericPolyline &pl)
Assignment operator.
GenericPolyline()
Creates an empty polyline.
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 adja...
GenericPolyline(const GenericPolyline< PointType > &pl)
Copy constructor.
void unify()
Deletes all successive points with equal coordinates.
void normalizeUnified(double minAngle)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adja...
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 adja...
bool operator==(const GenericSegment< PointType > &dl) const
Equality operator.
IntersectionType horIntersection(const double horAxis, double &crossing) const override
Computes the intersection of this line segment and the horizontal line through y = horAxis.
GenericSegment()
Creates an empty line segment.
bool operator!=(const GenericSegment< PointType > &dl) const
Inequality operator.
GenericLine< PointType >::numberType dx() const
Returns the x-coordinate of the difference (end point - start point).
double length() const
Returns the length (Euclidean distance between start and end point) of this line segment.
GenericSegment(const GenericSegment< PointType > &ds)=default
Copy constructor.
GenericLine< PointType >::numberType dy() const
Returns the y-coordinate of the difference (end point - start point).
GenericSegment(const PointType &p1, const PointType &p2)
Creates a line segment from p1 to p2.
IntersectionType verIntersection(const double verAxis, double &crossing) const override
Computes the intersection between this line segment and the vertical line through x = verAxis.
const PointType & start() const
Returns the start point of the line segment.
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.
IntersectionType intersection(const GenericSegment< PointType > &segment, PointType &inter, bool endpoints=true) const
Returns an IntersectionType specifying whether segment and this line segment intersect.
GenericSegment & operator=(const GenericSegment< PointType > &ds)=default
Copy assignment operator.
GenericSegment(const GenericLine< PointType > &dl)
Creates a line segment defined by the start and end point of line dl.
const PointType & end() const
Returns the end point of the line segment.
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.
Doubly linked lists (maintaining the length of the list).
void popFront()
Removes the first element from the list.
int size() const
Returns the number of elements in the list.
iterator pushBack(const PointType &x)
Adds element x at the end of the list.
void del(iterator it)
Removes it from the list.
List< E > & operator=(const List< E > &L)
Assignment operator.
iterator pushFront(const PointType &x)
Adds element x at the beginning of the list.
void popBack()
Removes the last element from the list.
Encapsulates a pointer to a list element.
bool valid() const
Returns true iff the iterator points to an element.
iterator begin()
Returns an iterator to the first element of the list.
int pos(const_iterator it) const
Returns the position (starting with 0) of iterator it in the list.
reverse_iterator rbegin()
Returns an iterator to the last element of the list.
bool empty() const
Returns true iff the list is empty.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
constexpr double pi
The constant .
double radiansToDegrees(const double &angleInRadians)
Converts an angle from radians to degrees.
The namespace for all OGDF objects.
IntersectionType
Determines the type of intersection of two geometric objects.
@ SinglePoint
Two geometric objects intersect in a single point.
@ None
Two geometric objects do not intersect.
@ Overlapping
Two geometric objects intersect in infinitely many points.
int orientation(const DPoint &p, const DPoint &q, const DPoint &r)
GenericPoint< double > DPoint
Representing two-dimensional point with real coordinates.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Orientation
Determines the orientation in hierarchical layouts.
@ rightToLeft
Edges are oriented from right to left.
@ bottomToTop
Edges are oriented from bottom to top.
@ leftToRight
Edges are oriented from left to right.
@ topToBottom
Edges are oriented from top to bottom.
const EpsilonTest OGDF_GEOM_ET