|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
137 const double dx2 =
r.m_x -
m_x, dy2 =
r.m_y -
m_y;
140 if ((dx1 == 0 && dy1 == 0) || (dx2 == 0 && dy2 == 0)) {
144 double phi = std::atan2(dy2, dx2) - std::atan2(dy1, dx1);
161 return sqrt(dx * dx + dy * dy);
236 os <<
"(" << p.
m_x <<
"," << p.
m_y <<
")";
260 template<
class Po
intType>
285 pred = iter = this->
begin();
288 while (iter.
valid()) {
289 len += (*iter).distance(*pred);
315 double pos = len * fraction;
319 pred = iter = this->
begin();
323 double DX = 0, DY = 0;
324 while (iter.
valid()) {
325 DX = (*iter).m_x - (*pred).m_x;
326 DY = (*iter).m_y - (*pred).m_y;
327 seglen = sqrt(DX * DX + DY * DY);
337 p = *(this->rbegin());
343 double segpos = seglen + pos - liter;
345 double dx = DX * segpos / seglen;
346 double dy = DY * segpos / seglen;
362 for (iter = next = this->
begin(), ++next; next.
valid() && (this->
size() > 2); ++next) {
363 if (*iter == *next) {
382 double maxAngle = 2 *
Math::pi - minAngle;
386 while (iter.
valid()) {
394 if (!onext.
valid()) {
397 double phi = (*next).angle(*iter, *onext);
402 if (iter != this->
begin()) {
455 template<
class Po
intType>
482 :
GenericLine(PointType(x1, y1), PointType(x2, y2)) { }
525 return dx() * line.
dy() -
dy() * line.
dx();
569 double dx2p = p.
m_x -
m_p1.m_x;
570 double dy2p = p.
m_y -
m_p1.m_y;
593 crossing = (
m_p1.m_x * (
m_p2.m_y - horAxis) -
m_p2.m_x * (
m_p1.m_y - horAxis)) /
dy();
610 crossing = (
m_p1.m_y * (
m_p2.m_x - verAxis) -
m_p2.m_y * (
m_p1.m_x - verAxis)) /
dx();
616 template<
class Po
intType>
619 os <<
"Line: vertical with x = " << line.
m_p1.m_x;
621 os <<
"Line: f(x) = " << line.
slope() <<
"x + " << line.
yAbs();
630 template<
class Po
intType>
641 double minx = min(this->
m_p1.m_x, this->m_p2.m_x);
642 double miny = min(this->
m_p1.m_y, this->m_p2.m_y);
643 double maxx = max(this->
m_p1.m_x, this->m_p2.m_x);
644 double maxy = max(this->
m_p1.m_y, this->m_p2.m_y);
646 if (includeBorders) {
687 const PointType&
end()
const {
return this->
m_p2; }
706 bool endpoints =
true)
const {
723 }
else if (points[1] == points[2] && !(this->
m_p1 == inter && this->
m_p2 == inter)
724 && !(segment.
m_p1 == inter && segment.
m_p2 == inter)) {
786 template<
class Po
intType>
788 os <<
"Segment-Start: " << dl.
start() <<
", Segment-End: " << dl.
end();
821 virtual ~
DRect() =
default;
852 std::swap(m_p2.
m_x, m_p1.
m_x);
855 std::swap(m_p2.
m_y, m_p1.
m_y);
932 void initAreaAndCenter();
947 :
DRect(static_cast<
DRect>(dr)), m_area(dr.m_area), m_center(dr.m_center) { }
952 DPoint(center.m_x + width / 2, center.m_y + height / 2)) {};
969 double area()
const {
return m_area; }
1003 explicit DPolygon(
const DRect& rect,
bool cc =
true) : m_counterclock(cc) { operator=(rect); }
1036 void insertCrossPoint(
const DPoint& p);
1053 bool containsPoint(
DPoint& p)
const;
1076 const Shape& shape);
DPolygon(const DRect &rect, bool cc=true)
Creates a polgon from a rectangle.
GenericSegment< DPoint > DSegment
Segments with real coordinates.
GenericSegment(const GenericLine< PointType > &dl)
Creates a line segment defined by the start and end point of line dl.
The namespace for all OGDF objects.
DIntersectableRect(const DPoint ¢er, double width, double height)
Constructs a rectangle from the center point, width and height.
void xInvert()
Swaps the x-coordinates of the two points.
GenericPolyline()
Creates an empty polyline.
double det(const GenericLine< PointType > &line) const
Determines if line is left or right of this line.
GenericLine< PointType >::numberType dx() const
Returns the x-coordinate of the difference (end point - start point).
friend GenericPoint< T > operator/(const GenericPoint< T > &p, double c)
Point-wise divide p by c.
bool operator==(const DRect &dr) const
Equality operator: both rectangles have the same coordinates.
GenericPoint< T > & operator+=(const GenericPoint< T > &p)
Adds p to this.
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
@ bottomToTop
Edges are oriented from bottom to top.
Parameterized base class for points.
GenericPoint(T x=0, T y=0)
Creates a generic point (x,y).
DPolygon(const DPolygon &dop)
Copy constructor.
IntersectionType horIntersection(const double horAxis, double &crossing) const override
Computes the intersection of this line segment and the horizontal line through y = horAxis.
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 DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
PointType m_p2
The second point of the line.
IntersectionType intersection(const GenericSegment< PointType > &segment, PointType &inter, bool endpoints=true) const
Returns an IntersectionType specifying whether segment and this line segment intersect.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
GenericLine(const GenericLine< PointType > &dl)
Copy constructor.
void popFront()
Removes the first element from the list.
ListIterator< DPoint > insertPoint(const DPoint &p)
Inserts point p, that must lie on a polygon segment.
bool operator==(const GenericLine< PointType > &dl) const
Equality operator.
const PointType & start() const
Returns the start point of the line segment.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
friend GenericPoint< T > operator*(T c, const GenericPoint< T > &p)
Point-wise multiplies p with c.
void unify()
Deletes all successive points with equal coordinates.
Polylines with PointType points.
DIntersectableRect & operator=(const DIntersectableRect &dr)
Assignment operator.
bool isHorizontal() const
Returns true iff this line runs horizontally.
DPoint m_p2
The upper right point of the rectangle.
DIntersectableRect(const DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
bool contains(const DPoint &p) const
Returns true iff p lies within this rectangle, modulo the comparison epsilon OGDF_GEOM_ET.
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.
bool operator!=(const GenericPoint< T > &p) const
Inequality operator.
double height() const
Returns the height of the rectangle.
Polygons with real coordinates.
double area() const
Area of the rectangle.
bool valid() const
Returns true iff the iterator points to an element.
GenericLine()
Creates an empty line.
GenericPoint< T > & operator-=(const GenericPoint< T > &p)
Subtracts p from this.
void normalizeUnified(double minAngle)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adja...
void yInvert()
Swaps the y-coordinates of the two points.
void normalize()
Normalizes the rectangle.
List< E > & operator=(const List< E > &L)
Assignment operator.
GenericPoint< T > & operator*=(T c)
Point-wise multiplies this with c.
const DSegment top() const
Returns the top side of the rectangle.
bool contains(const PointType &p) const override
Returns true iff p lies on this line segment.
Rectangles with real coordinates.
virtual bool contains(const DPoint &p) const
Returns true iff p lies on this line.
@ SinglePoint
Two geometric objects intersect in a single point.
const DSegment left() const
Returns the left side of the rectangle.
double distance(const GenericPoint< T > &p) const
Returns the Euclidean distance between p and this point.
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.
void sort(T *array, int size, LessThan lt)
double radiansToDegrees(const double &angleInRadians)
Converts an angle from radians to degrees.
numberType dy() const
Returns the y-coordinate of the difference (second point - first point).
GenericPoint< T > & operator/=(T c)
Point-wise divide this by c.
double slope() const
Returns the slope of the line.
const EpsilonTest OGDF_GEOM_ET
DRect(const DSegment &dl)
Creates a rectangle defined by the end points of line segment dl.
iterator pushFront(const PointType &x)
Adds element x at the beginning of the list.
DPoint m_p1
The lower left point of the rectangle.
const DPoint & p1() const
Returns the lower left point of the rectangle.
const T & move(const T &v)
The parameterized class Array implements dynamic arrays of type E.
double length() const
Returns the length (Euclidean distance between start and end point) of this line segment.
Rectangles with real coordinates.
double norm() const
Returns the norm of the point.
bool counterclock()
Returns true iff points are given in counter-clockwise order.
void normalize(double minAngle=Math::pi)
Deletes all redundant points on the polyline that lie on a (nearly) straight line given by their adja...
const DSegment bottom() const
Returns the bottom side of the rectangle.
virtual IntersectionType horIntersection(const double horAxis, double &crossing) const
Computes the intersection of this line and the horizontal line through y = horAxis.
IntersectionType intersection(const GenericLine< PointType > &line, DPoint &inter) const
Returns an IntersectionType specifying whether line and this line intersect.
int numberType
The type for coordinates of the point.
GenericPoint(const GenericPoint< T > &p)
Copy constructor.
GenericLine< PointType > & operator=(const GenericLine< PointType > &dl)
Assignment operator.
T operator*(const GenericPoint< T > &dv) const
Returns the scalar product of this and dv.
@ Overlapping
Two geometric objects intersect in infinitely many points.
IntersectionType verIntersection(const double verAxis, double &crossing) const override
Computes the intersection between this line segment and the vertical line through x = verAxis.
DIntersectableRect(double x1, double y1, double x2, double y2)
Creates a rectangle with lower left point (x1,y1) and upper right point (x1,y2).
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
GenericPolyline(const GenericPolyline< PointType > &pl)
Copy constructor.
DRect(const DRect &dr)
Copy constructor.
GenericSegment()
Creates an empty line segment.
Doubly linked lists (maintaining the length of the list).
GenericPolyline(const List< PointType > &pl)
Creates a polyline using the list of points pl.
int orientation(const DPoint &p, const DPoint &q, const DPoint &r)
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.
constexpr double pi
The constant .
@ leftToRight
Edges are oriented from left to right.
double pointDist(const DPoint &p1, const DPoint &p2) const
Computes distance between two points.
bool m_counterclock
If true points are given in conter-clockwise order.
IntersectionType
Determines the type of intersection of two geometric objects.
GenericPolyline< PointType > & operator=(const GenericPolyline &pl)
Assignment operator.
double angle(GenericPoint< T > q, GenericPoint< T > r) const
Compute angle (in radians) between vectors.
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.
Orientation
Determines the orientation in hierarchical layouts.
bool intersection(const DSegment &segment) const
Returns true iff segment intersects this DRect.
double yAbs() const
Returns the value y' such that (0,y') lies on the unlimited straight-line defined by this line.
DIntersectableRect(const DIntersectableRect &dr)
Copy constructor.
GenericPoint< double > DPoint
Representing two-dimensional point with real coordinates.
GenericPoint< T > & operator=(const GenericPoint< T > &p)
Assignment operator.
double length() const
Returns the Euclidean length of the polyline.
GenericLine(numberType x1, numberType y1, numberType x2, numberType y2)
Creates a line through the points (x1,y1) and (x2,y2).
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.
DPolygon & operator=(const DPolygon &dop)
Assignment operator.
double angleDegrees(GenericPoint< T > q, GenericPoint< T > r) const
Compute angle (in degrees) between vectors.
GenericPoint< T > operator+(const GenericPoint< T > &p) const
Addition of points.
@ rightToLeft
Edges are oriented from right to left.
GenericPoint< T > operator-(const GenericPoint< T > &p) const
Subtraction of 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 adja...
void del(iterator it)
Removes it from the list.
DPolygon(bool cc=true)
Creates an empty polygon.
Basic declarations, included by all source files.
void popBack()
Removes the last element from the list.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
DPoint center() const
Center of the rectangle.
bool operator!=(const GenericSegment< PointType > &dl) const
Inequality operator.
typename PointType::numberType numberType
T determinant(const GenericPoint< T > &dv) const
Returns the determinant of the matrix (this, dv).
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
const DPoint & p2() const
Returns the upper right point of the rectangle.
int hash(const IPoint &ip) const
PointType m_p1
The first point of the line.
bool isPointCoveredByNode(const DPoint &point, const DPoint &v, const DPoint &vSize, const Shape &shape)
Check whether this point lies within a node (using node shapes with same size and aspect as in TikZ).
Declaration and implementation of Array class and Array algorithms.
bool isVertical() const
Returns true iff this line runs vertically.
Shape
Types for node shapes.
Declaration of doubly linked lists and iterators.
bool operator==(const GenericPoint< T > &dp) const
Equality operator.
GenericPoint< T > orthogonal() const
Returns a vector that is orthogonal to this vector.
double width() const
Returns the width of the rectangle.
GenericLine< PointType >::numberType dy() const
Returns the y-coordinate of the difference (end point - start point).
DRect & operator=(const DRect &dr)
Assignment operator.
DPoint contourPointFromAngle(double angle, int n, double rotationOffset=0, const DPoint ¢er=DPoint(), const DPoint &vSize=DPoint(1, 1))
returns the point where a vector, pointing from center in direction of angle, intersects with the con...
numberType dx() const
Returns the x-coordinate of the difference (second point - first point).
const DSegment right() const
Returns the right side of the rectangle.
@ topToBottom
Edges are oriented from top to bottom.
int size() const
Returns the number of elements in the list.
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.
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.
bool operator==(const GenericSegment< PointType > &dl) const
Equality operator.
GenericLine(const PointType &p1, const PointType &p2)
Creates a line through the points p1 and p2.
Encapsulates a pointer to a list element.
bool operator!=(const GenericLine< PointType > &dl) const
Inequality operator.
const PointType & end() const
Returns the end point of the line segment.
GenericSegment(const PointType &p1, const PointType &p2)
Creates a line segment from p1 to p2.
virtual IntersectionType verIntersection(const double verAxis, double &crossing) const
Computes the intersection between this line and the vertical line through x = verAxis.
friend GenericPoint< T > operator*(const GenericPoint< T > &p, T c)
Point-wise multiplies p with c.
@ None
Two geometric objects do not intersect.
bool operator>(const GenericPoint< T > &p) const
Operator 'greater'. Returns true iff p is less than this.
bool operator!=(const DRect &dr) const
Inequality operator.
GenericSegment(double x1, double y1, double x2, double y2)
Creates a line segment from (x1,y1) to (x2,y2).
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,...
GenericSegment & operator=(const GenericSegment< PointType > &ds)=default
Copy assignment operator.
iterator pushBack(const PointType &x)
Adds element x at the end of the list.