TwiceAsNice  2019-02-18
Public Member Functions | List of all members
Nice::Polygon Class Reference

#include <Polygon.h>

Inheritance diagram for Nice::Polygon:
Inheritance graph
Collaboration diagram for Nice::Polygon:
Collaboration graph

Public Member Functions

 Polygon ()
 Default ctor. More...
 
 Polygon (size_t size)
 
 Polygon (const Rect &r)
 
 Polygon (const SeqLine &linetrain)
 construct the polyogn from a sequence of consecutive lines. More...
 
void append (const Nice::Point &pt)
 extend the polygon by adding a point at the end. More...
 
void close ()
 Close the polygon by adding a line from the last to the first point. More...
 
Nice::Line lineSeg (size_t idx) const
 retrieve the idx-th line segment. More...
 
Nice::Line::IntersectType intersect (const Nice::Polygon &oth) const
 Check whether any of the line segments intersects with another polygon. More...
 
void translate (double dx, double dy)
 
void translate (const Point &offset)
 
Polygon translated (double dx, double dy) const
 
Polygon translated (const Point &offset) const
 
bool isClosed () const
 
Rect boundingRect () const
 
bool containsPoint (const Point &pt) const
 
 Polygon ()
 
 Polygon (size_t size)
 
 Polygon (const Rect &r)
 
 Polygon (const SeqLine &linetrain)
 
void append (const Nice::Point &pt)
 
void close ()
 
Nice::Line lineSeg (size_t idx) const
 
Nice::Line::IntersectType intersect (const Nice::Polygon &oth) const
 
void translate (double dx, double dy)
 
void translate (const Point &offset)
 
Polygon translated (double dx, double dy) const
 
Polygon translated (const Point &offset) const
 
bool isClosed () const
 
Rect boundingRect () const
 
bool containsPoint (const Point &pt) const
 

Constructor & Destructor Documentation

◆ Polygon() [1/8]

Nice::Polygon::Polygon ( )

Default ctor.


This defines a polygon without points.

Since
2017-03-31

◆ Polygon() [2/8]

Nice::Polygon::Polygon ( size_t  size)
inline

◆ Polygon() [3/8]

Nice::Polygon::Polygon ( const Rect r)

◆ Polygon() [4/8]

Nice::Polygon::Polygon ( const SeqLine linetrain)

construct the polyogn from a sequence of consecutive lines.


Parameters
linetrainThe line segments that define the polygon. The ctor assumes that the end point of each segment is equal to the start point of the next segment, without checking this assumption.
Since
2017-03-31

◆ Polygon() [5/8]

Nice::Polygon::Polygon ( )

◆ Polygon() [6/8]

Nice::Polygon::Polygon ( size_t  size)
inline

◆ Polygon() [7/8]

Nice::Polygon::Polygon ( const Rect r)

◆ Polygon() [8/8]

Nice::Polygon::Polygon ( const SeqLine linetrain)

Member Function Documentation

◆ append() [1/2]

void Nice::Polygon::append ( const Nice::Point pt)

extend the polygon by adding a point at the end.


Parameters
ptThe additional point to be appended.
Since
2017-03-31

◆ append() [2/2]

void Nice::Polygon::append ( const Nice::Point pt)

◆ boundingRect() [1/2]

Nice::Rect Nice::Polygon::boundingRect ( ) const

Returns the bounding rectangle of the polygon, or Nice::Rect(0,0,0,0) if the polygon is empty.

See also
QVector::isEmpty()

◆ boundingRect() [2/2]

Rect Nice::Polygon::boundingRect ( ) const

◆ close() [1/2]

void Nice::Polygon::close ( void  )

Close the polygon by adding a line from the last to the first point.


Since
2017-03-31

◆ close() [2/2]

void Nice::Polygon::close ( )

◆ containsPoint() [1/2]

bool Nice::Polygon::containsPoint ( const Point pt) const
Since
4.3

Returns true if the given point is inside the polygon according to the specified fillRule; otherwise returns false.

◆ containsPoint() [2/2]

bool Nice::Polygon::containsPoint ( const Point pt) const

◆ intersect() [1/2]

Nice::Line::IntersectType Nice::Polygon::intersect ( const Nice::Polygon oth) const

Check whether any of the line segments intersects with another polygon.


All line segments of this are checked for intersection with the line segments of the other polygon.

Parameters
othThe other polygon.
Returns
NoIntersection if no lines intersect, BoundedIntersection if some touch. Note that NoIntersection is also returned if one polygon is entirely within another.
Since
2017-03-30

◆ intersect() [2/2]

Nice::Line::IntersectType Nice::Polygon::intersect ( const Nice::Polygon oth) const

◆ isClosed() [1/2]

bool Nice::Polygon::isClosed ( ) const
inline

◆ isClosed() [2/2]

bool Nice::Polygon::isClosed ( ) const
inline

◆ lineSeg() [1/2]

Nice::Line Nice::Polygon::lineSeg ( size_t  idx) const

retrieve the idx-th line segment.


Parameters
idxThe 0-based line segment
Returns
The line starting at point idx. If the idx is outside the range of known points, a null line (as defined by Nice, whatever that might be) is returned
Since
2017-03-30

◆ lineSeg() [2/2]

Nice::Line Nice::Polygon::lineSeg ( size_t  idx) const

◆ translate() [1/4]

void Nice::Polygon::translate ( double  dx,
double  dy 
)
inline

◆ translate() [2/4]

void Nice::Polygon::translate ( double  dx,
double  dy 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Translates all points in the polygon by ({dx}, {dy}).

See also
translated()

◆ translate() [3/4]

void Nice::Polygon::translate ( const Point offset)

◆ translate() [4/4]

void Nice::Polygon::translate ( const Point offset)

Translate all points in the polygon by the given offset.

See also
translated()

◆ translated() [1/4]

Polygon Nice::Polygon::translated ( double  dx,
double  dy 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.6

Returns a copy of the polygon that is translated by ({dx}, {dy}).

See also
translate()

◆ translated() [2/4]

Polygon Nice::Polygon::translated ( double  dx,
double  dy 
) const
inline

◆ translated() [3/4]

Polygon Nice::Polygon::translated ( const Point offset) const

◆ translated() [4/4]

Nice::Polygon Nice::Polygon::translated ( const Point offset) const

Returns a copy of the polygon that is translated by the given offset.

Since
4.6
See also
translate()

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