Read@CVL
rdf::Line Class Reference

A basic line class including stroke width (thickness). More...

#include <Shapes.h>

Public Member Functions

 Line (const QLineF &line=QLineF(), float thickness=1)
 Initializes a new instance of the Line class. More...
 
 Line (const Polygon &poly)
 
 Line (const cv::Point p1, const cv::Point p2, float thickness=1)
 
 Line (const Vector2D &p1, const Vector2D &p2, float thickness=1)
 
 Line (double p1x, double p1y, double p2x, double p2y, float thickness=1)
 
bool isEmpty () const
 Determines whether this instance is empty. More...
 
void sortEndpoints (bool horizontal=true)
 
void setLine (const QLineF &line, float thickness=1)
 Sets the line. More...
 
void setThickness (float thickness)
 
float thickness () const
 Returns the stroke width of the line. More...
 
double squaredLength () const
 
double length () const
 Returns the line length. More...
 
double weightedLength (const Vector2D &orVec) const
 Returns the orientation weighed length. Hence, if orVec is parallel to the line, the length is 0. If it is orthogonal, the line length is returned. More...
 
double angle () const
 Returns the line angle. More...
 
double minDistance (const Line &l) const
 Returns the minimum distance of the line endings of line l to the line endings of the current line instance. More...
 
void translate (cv::Point offset)
 
void scale (double s)
 
double distance (const Vector2D &p) const
 Returns the minimal distance of point p to the current line instance. More...
 
double horizontalOverlap (const Line &l) const
 
double horizontalDistance (const Line &l, double threshold=20) const
 
double verticalOverlap (const Line &l) const
 
double verticalDistance (const Line &l, double threshold=20) const
 
Line merge (const Line &l) const
 Merges the specified line l with the current line instance. More...
 
Line mergeFit (const Line &l) const
 
Line gapLine (const Line &l) const
 Calculates the gap line between line l and the current line instance. More...
 
double diffAngle (const Line &l) const
 The angle difference of line l and the current line instance. More...
 
bool within (const Vector2D &p) const
 Calculated if point p is within the current line instance. More...
 
Line moved (const Vector2D &mVec) const
 Returns a line moved by the vector mVec. More...
 
Vector2D p1 () const
 Returns the start point. More...
 
Vector2D p2 () const
 Returns the end point. More...
 
Vector2D center () const
 
QLineF qLine () const
 Returns the line information. More...
 
QPolygonF toPoly () const
 
bool isHorizontal (double mAngleTresh=0.5) const
 Determines whether the specified m angle tresh is horizontal. More...
 
bool isVertical (double mAngleTresh=0.5) const
 
bool isColinear (const Line &line, double threshold=20) const
 
bool isClose (const Line &line, double threshold=20) const
 
bool intersects (const Line &line, QLineF::IntersectType t=QLineF::BoundedIntersection) const
 
Vector2D intersection (const Line &line, QLineF::IntersectType t=QLineF::BoundedIntersection) const
 Returns the intersection point of both lines. This function returns an empty vector if the lines do not intersect within the bounds More...
 
Vector2D intersectionUnrestricted (const Line &line) const
 
Vector2D vector () const
 Returns the line's orientation vector. More...
 
void draw (QPainter &p) const
 
Line extendBorder (const Rect &box) const
 Extends the line until the borders of the box. More...
 

Static Public Member Functions

static bool lessX1 (const Line &l1, const Line &l2)
 
static bool lessY1 (const Line &l1, const Line &l2)
 

Protected Member Functions

cv::Mat toMat (const Line &l) const
 

Protected Attributes

QLineF mLine
 
float mThickness = 1
 

Detailed Description

A basic line class including stroke width (thickness).

Constructor & Destructor Documentation

rdf::Line::Line ( const QLineF &  line = QLineF(),
float  thickness = 1 
)

Initializes a new instance of the Line class.

Parameters
lineThe line.
thicknessThe stroke width.
rdf::Line::Line ( const Polygon poly)
rdf::Line::Line ( const cv::Point  p1,
const cv::Point  p2,
float  thickness = 1 
)
rdf::Line::Line ( const Vector2D p1,
const Vector2D p2,
float  thickness = 1 
)
rdf::Line::Line ( double  p1x,
double  p1y,
double  p2x,
double  p2y,
float  thickness = 1 
)

Member Function Documentation

double rdf::Line::angle ( ) const

Returns the line angle.

Returns
The line angle [-pi,+pi] in radians.
Vector2D rdf::Line::center ( ) const
double rdf::Line::diffAngle ( const Line l) const

The angle difference of line l and the current line instance.

Parameters
lThe line l.
Returns
The angle difference in rad.
double rdf::Line::distance ( const Vector2D p) const

Returns the minimal distance of point p to the current line instance.

Parameters
pThe point p.
Returns
The distance of point p.
void rdf::Line::draw ( QPainter &  p) const
Line rdf::Line::extendBorder ( const Rect box) const

Extends the line until the borders of the box.

Parameters
boxthe 'cropping' box.
Line rdf::Line::gapLine ( const Line l) const

Calculates the gap line between line l and the current line instance.

Parameters
lThe line l to which a gap line is calculated.
Returns
The gap line.
double rdf::Line::horizontalDistance ( const Line l,
double  threshold = 20 
) const
double rdf::Line::horizontalOverlap ( const Line l) const
Vector2D rdf::Line::intersection ( const Line line,
QLineF::IntersectType  t = QLineF::BoundedIntersection 
) const

Returns the intersection point of both lines. This function returns an empty vector if the lines do not intersect within the bounds

Parameters
lineAnother line.
Returns
The line intersection.
Vector2D rdf::Line::intersectionUnrestricted ( const Line line) const
bool rdf::Line::intersects ( const Line line,
QLineF::IntersectType  t = QLineF::BoundedIntersection 
) const
bool rdf::Line::isClose ( const Line line,
double  threshold = 20 
) const
bool rdf::Line::isColinear ( const Line line,
double  threshold = 20 
) const
bool rdf::Line::isEmpty ( ) const

Determines whether this instance is empty.

Returns
True if no line is set
bool rdf::Line::isHorizontal ( double  mAngleTresh = 0.5) const

Determines whether the specified m angle tresh is horizontal.

Parameters
mAngleTreshThe m angle tresh.
Returns
true if the specified m angle tresh is horizontal; otherwise, false.
bool rdf::Line::isVertical ( double  mAngleTresh = 0.5) const
double rdf::Line::length ( ) const

Returns the line length.

Returns
The line length.
bool rdf::Line::lessX1 ( const Line l1,
const Line l2 
)
static
bool rdf::Line::lessY1 ( const Line l1,
const Line l2 
)
static
Line rdf::Line::merge ( const Line l) const

Merges the specified line l with the current line instance.

Parameters
lThe line to merge.
Returns
The merged line.
Line rdf::Line::mergeFit ( const Line l) const
double rdf::Line::minDistance ( const Line l) const

Returns the minimum distance of the line endings of line l to the line endings of the current line instance.

Parameters
lThe line l to which the minimum distance is computed.
Returns
The minimum distance.
Line rdf::Line::moved ( const Vector2D mVec) const

Returns a line moved by the vector mVec.

Parameters
mVecMove vector.
Returns
Vector2D rdf::Line::p1 ( ) const

Returns the start point.

Returns
The start point.
Vector2D rdf::Line::p2 ( ) const

Returns the end point.

Returns
The end point.
QLineF rdf::Line::qLine ( ) const

Returns the line information.

Returns
The line.
void rdf::Line::scale ( double  s)
void rdf::Line::setLine ( const QLineF &  line,
float  thickness = 1 
)

Sets the line.

Parameters
lineThe line.
thicknessThe stroke width.
void rdf::Line::setThickness ( float  thickness)
void rdf::Line::sortEndpoints ( bool  horizontal = true)
double rdf::Line::squaredLength ( ) const
float rdf::Line::thickness ( ) const

Returns the stroke width of the line.

Returns
The stroke width.
cv::Mat rdf::Line::toMat ( const Line l) const
protected
QPolygonF rdf::Line::toPoly ( ) const
void rdf::Line::translate ( cv::Point  offset)
Vector2D rdf::Line::vector ( ) const

Returns the line's orientation vector.

Returns
double rdf::Line::verticalDistance ( const Line l,
double  threshold = 20 
) const
double rdf::Line::verticalOverlap ( const Line l) const
double rdf::Line::weightedLength ( const Vector2D orVec) const

Returns the orientation weighed length. Hence, if orVec is parallel to the line, the length is 0. If it is orthogonal, the line length is returned.

Parameters
orVecAn orientation vector.
Returns
The length weighed by the orientation
bool rdf::Line::within ( const Vector2D p) const

Calculated if point p is within the current line instance.

Parameters
pThe point p to be checked.
Returns
True if p is within the current line instance.

Member Data Documentation

QLineF rdf::Line::mLine
protected
float rdf::Line::mThickness = 1
protected

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