#include <2DPolygon.h>
Inheritance diagram for C2DPolygon:
Public Member Functions | |
C2DPolygon (void) | |
Constructor. | |
C2DPolygon (const C2DPoint *pPoint, unsigned int nNumber, bool bReorderIfNeeded=false) | |
Constructor. | |
C2DPolygon (const C2DPointSet &Points, bool bReorderIfNeeded=false) | |
Constructor. | |
C2DPolygon (const C2DPolygon &Other) | |
Constructor. | |
C2DPolygon (const C2DPolyBase &Other) | |
Constructor. | |
~C2DPolygon (void) | |
Destructor. | |
bool | Create (const C2DRoute &Route) |
Sets the point list to that of the route provided. Route can be closed or not. | |
bool | Create (const C2DPoint *pPoint, unsigned int nNumber, bool bReorderIfNeeded=false) |
Creates the polygon with optional reordering of points. | |
bool | Create (const C2DPointSet &Points, bool bReorderIfNeeded=false) |
Creates the polygon with optional reordering of points. | |
bool | CreateRegular (const C2DPoint &Centre, double dDistanceToPoints, int nNumberSides) |
Creates a regular polygon. | |
bool | CreateConvexHull (const C2DPolygon &Other) |
Creates a convex hull from another polygon. Uses Graham's algorithm. | |
bool | CreateRandom (const C2DRect &cBoundary, int nMinPoints, int nMaxPoints) |
Creates a randon polygon. | |
bool | CreateMorph (const C2DPolygon &OtherFrom, const C2DPolygon &OtherTo, double dFactor) |
Mophs this polygon into another by the factor given. | |
bool | CreateConvexSubAreas (void) |
Creates convex sub areas by joining inflection if possible or joining inflected points with other points that will remove the inflection. | |
void | ClearConvexSubAreas (void) |
Removes the convex sub areas. | |
bool | Contains (const C2DPoint &pt) const |
True if the point is contained. | |
bool | Contains (const C2DPolygon &Other) const |
True if the polygon is contained. | |
bool | Contains (const C2DHoledPolyBase &Other) const |
True if it entirely contains the other. | |
bool | Contains (const C2DLine &Line) const |
True if the Line is contained. | |
bool | Contains (const C2DLineBase &Line) const |
True if the Line is contained. | |
bool | Crosses (const C2DLineBase &Line) const |
True if the lines of this cross the line. | |
bool | Crosses (const C2DLineBase &Line, C2DPointSet *IntersectionPts) const |
True if a given lines crosses any line in the polygon. Records the intersection points in order. | |
bool | CrossesRay (const C2DLine &Ray, C2DPointSet *IntersectionPts) const |
True if the ray crosses the polygon, records the points in order. | |
bool | IsConvex (void) |
True if the polygon is convex. | |
void | Clear (void) |
Clears all. | |
void | RotateToRight (double dAng, const C2DPoint &Origin) |
Rotates the polygon to the right around the origin given. | |
void | RotateToRight (double dAng) |
Rotates the polygon to the right around the centroid. | |
void | Move (const C2DVector &Vector) |
Moves the polygon. | |
void | Grow (double dFactor) |
Grows the polygon from the centre. | |
void | Grow (double dFactor, const C2DPoint &Origin) |
Grows from the origin given. | |
void | Reflect (const C2DPoint &Point) |
Reflects throught the point provided. | |
void | Reflect (const C2DLine &Line) |
Reflects throught the line provided. | |
const C2DPolygon & | operator= (const C2DPolygon &Other) |
Assignment. | |
bool | HasRepeatedPoints (void) const |
True if there are repeated points. | |
bool | IsClockwise (void) |
True if clockwise. | |
void | Project (const C2DVector &Vector, CInterval &Interval) const |
Projects the polygon onto a vector providing the interval of projection on the vector. | |
void | Project (const C2DLine &Line, CInterval &Interval) const |
Projects the polygon onto a line providing the interval of projection on the vector. | |
const C2DPolygon * | GetSubArea (int nIndex) const |
Returns a pointer to the sub area. | |
void | GetConvexSubAreas (C2DPolygonSet &SubAreas) const |
Returns the convex sub areas if created. | |
bool | Overlaps (const C2DPolygon &Other, C2DVector &MinimumTranslationVector) const |
Returns true if there is an overlap between this and the other polygon and the vector required to move them apart from one another. Exact for a convex polygon. For non-convex, the function effectively works on the convex hull. However, a non-convex polygon can be split into convex polygons and then the calculated translation vector is more accurate. | |
bool | Overlaps (const C2DPolygon &Other) const |
True if this overlap the other. | |
void | Avoid (const C2DPolygon &Other) |
Calls the Overlaps function and moves this away from the other. | |
unsigned int | GetPointsCount (void) const |
Returns the number of points. | |
const C2DPoint | GetCentroid (void) const |
Returns the centroid. | |
double | GetArea () const |
Returns the area. | |
double | GetAreaSigned () const |
Returns the area signed (-ve if clockwise). | |
const C2DPoint * | GetPoint (unsigned short nPointIndex) const |
Returns a pointer to the point required;. | |
void | GetPointsCopy (C2DPointSet &PointCopy) const |
Copies the points into the set object provided. | |
const C2DLine * | GetLine (unsigned int i) const |
Returns a constant pointer to the line. | |
int | GetLeftMostPoint (void) const |
Returns the left most point. | |
void | Smooth (double dMinAngle=conPI *0.8, double dCropFactor=0.8) |
Smooths the polygon. | |
void | GetBoundingCircle (C2DCircle &Circle) const |
Get the minimum bounding circle. | |
void | GetNonOverlaps (const C2DPolygon &Other, C2DHoledPolygonSet &HoledPolygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the difference between this and the other. | |
void | GetNonOverlaps (const C2DPolygon &Other, C2DHoledPolyBaseSet &HoledPolygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the difference between this and the other. Access to base class. | |
void | GetUnion (const C2DPolygon &Other, C2DHoledPolygonSet &HoledPolygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the union of tihis and the other. | |
void | GetUnion (const C2DPolygon &Other, C2DHoledPolyBaseSet &HoledPolygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the union of tihis and the other. Access to base class. | |
void | GetOverlaps (const C2DPolygon &Other, C2DHoledPolygonSet &Polygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the overlap between this and the other. | |
void | GetOverlaps (const C2DPolygon &Other, C2DHoledPolyBaseSet &Polygons, CGrid::eDegenerateHandling eDegen=CGrid::None) const |
Returns the overlap between this and the other. Access to base class. | |
Static Public Member Functions | |
static void | GetMinProjection (C2DPolygonSet &Polygons, C2DVector &Result, CInterval &Interval) |
Returns the vector on which the projection of the whole set of polygons is minimal. Also returns the projection interval on that vector. |
Class which represents a polygon which is defined as a sequence of straight lines that are joined and closed, with no holes and no self intersections.
User adds points and then calls the create function. Can opt to add points without any order and in which case the points are reordered so that the perimeter of the shape is minimised and there are no crossing lines.
Supports a variety of functions including functions to find the intersection, union and non-intersection of two polygons.
---------------------------------------------------------------------------
|
Constructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Constructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Constructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Constructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Constructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Destructor.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Calls the Overlaps function and moves this away from the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Clears all.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Removes the convex sub areas.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if the Line is contained.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
True if the Line is contained.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if it entirely contains the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
True if the polygon is contained.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if the point is contained.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Creates the polygon with optional reordering of points.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Creates the polygon with optional reordering of points.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Sets the point list to that of the route provided. Route can be closed or not.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Creates a convex hull from another polygon. Uses Graham's algorithm.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Creates convex sub areas by joining inflection if possible or joining inflected points with other points that will remove the inflection. Creates convex sub areas of the current polygon. These can then be extracted. This function is also useful when obtaining minimum translation vectors.
|
|
Mophs this polygon into another by the factor given.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Creates a randon polygon.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Creates a regular polygon.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if a given lines crosses any line in the polygon. Records the intersection points in order. True if the lines of this cross the line. Returns the points in order of their position on the line. Reimplemented from C2DPolyBase. |
|
True if the lines of this cross the line.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
True if the ray crosses the polygon, records the points in order. True if the lines of this cross the ray. Returns the points in order of their position on the ray. (assumes the line is infinite). Reimplemented from C2DPolyBase. |
|
Returns the area.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the area signed (-ve if clockwise).
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Get the minimum bounding circle.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the centroid.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the convex sub areas if created.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the left most point.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the vector on which the projection of the whole set of polygons is minimal. Also returns the projection interval on that vector. Returns the vector which results in the smallest projection of all the polygons in the array and the interval representing that translation. |
|
Returns the difference between this and the other. Access to base class.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the difference between this and the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the overlap between this and the other. Access to base class.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the overlap between this and the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns a pointer to the point required;.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Copies the points into the set object provided.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns a pointer to the sub area.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the union of tihis and the other. Access to base class.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns the union of tihis and the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Grows from the origin given.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Grows the polygon from the centre.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if there are repeated points.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if clockwise.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if the polygon is convex.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Moves the polygon.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Assignment.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
True if this overlap the other.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Returns true if there is an overlap between this and the other polygon and the vector required to move them apart from one another. Exact for a convex polygon. For non-convex, the function effectively works on the convex hull. However, a non-convex polygon can be split into convex polygons and then the calculated translation vector is more accurate. True if this overlaps another and returns the translation vector required to move this apart. Exact if this is convex, approximate if concave. Better approximation if convex sub areas have been created. |
|
Projects the polygon onto a line providing the interval of projection on the vector.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Projects the polygon onto a vector providing the interval of projection on the vector.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Reflects throught the line provided.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Reflects throught the point provided.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Rotates the polygon to the right around the centroid.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
Rotates the polygon to the right around the origin given.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- Reimplemented from C2DPolyBase. |
|
Smooths the polygon.
-------------------------------------------------------------------------- --------------------------------------------------------------------------- |