Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILPolygon Interface Reference

This interface represents a polygon(LPolygon object). More...

Inheritance diagram for ILPolygon:
ILObjects ILObject LPolygon

Public Member Functions

void AddPoints (ILPoints *points)
 
double DistanceToPoint (ILPoint *point, LPVAggregation aggType, ILPoint **rootPoint)
 
double DistanceToPolygon (ILPolygon *polygon, LPVAggregation aggType, ILPoint **rootPoint1, ILPoint **rootPoint2)
 
void Draw (BOOL bFill, HDC hdc, double zoomX, double zoomY, double panX, double panY)
 
void FromPolyRegion (ILPolyRegion *val)
 
double GetArea ()
 
ILPointGetGravityCenter ()
 
ILCircleGetInscribedCircle ()
 
double GetPerimeter ()
 
ILPointsGetPoints ()
 
LPVIntersectType IntersectLine (ILLine *line, ILPoints **intersectPoints)
 
BOOL IntersectPolygon (ILPolygon *polygon, ILPoints **intersectPoints)
 
ILPointItem (int index)
 
LPVPointTestResult PointTest (ILPoint *point)
 
void RemovePoints (double lbX, double ubX, double lbY, double ubY)
 
ILPolygonResample (int num)
 
ILPolygonResampleByStep (double step, double stepThreshold)
 
void Set (int index, double x, double y)
 
void SetPolygon (LArray< double > xs, LArray< double > ys, BOOL isClosed)
 
ILPolyRegionToPolyRegion ()
 
ILPolygonTransform (ILTransform *tf)
 
ILPolygonTranslate (double offsetX, double offsetY)
 
- Public Member Functions inherited from ILObjects
int Count ()
 
BOOL Empty ()
 
ILObjectItemObject (int objIndex)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

BOOL Closed [get, set]
 Whether this is a closed polygon.
 

Detailed Description

This interface represents a polygon(LPolygon object).

Member Function Documentation

◆ AddPoints()

void AddPoints ( ILPoints points)

Append the points in the given collection to this polygon.

Parameters
[in]pointsThe input points

◆ DistanceToPoint()

double DistanceToPoint ( ILPoint point,
LPVAggregation  aggType,
ILPoint **  rootPoint 
)

Calculate the minimum/maximum distance between the input point and the polygon, it could be either the distance from the input point to any of the polygon's vertexes or segments.

Parameters
[in]pointThe input point.
[in]aggTypeThe aggregation type, only LPVAggMin or LPVAggMax is acceptable
[out]rootPointOutput the root point, could be either a vertex or the input point's perpendicular root to a polygon segment
Return values
valReturn the minimum distance.

◆ DistanceToPolygon()

double DistanceToPolygon ( ILPolygon polygon,
LPVAggregation  aggType,
ILPoint **  rootPoint1,
ILPoint **  rootPoint2 
)

Calculate the minimum/maximum distance between the input polygon and this polygon, it could be either the distance between any of the polygons' vertexes or segments. For example, the red one is this polygon, the green one is the input polygon, their minimum distance and root points are shown as below:

Parameters
[in]polygonThe input polygon
[in]aggTypeThe aggregation type, only LPVAggMin or LPVAggMax is acceptable
[out]rootPoint1Output the root point on this polygon
[out]rootPoint2Output the root point on the input polygon
Return values
valReturn the minimum distance.

◆ Draw()

void Draw ( BOOL  bFill,
HDC  hdc,
double  zoomX,
double  zoomY,
double  panX,
double  panY 
)

Draw all the points on HDC.

Parameters
[in]bFillWhether to fill the path using current brush.
See also
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.

◆ FromPolyRegion()

void FromPolyRegion ( ILPolyRegion val)

Set placement of the polygon from the input polygon region.

◆ GetArea()

double GetArea ( )

Get the area of the polygon. For open polygons, the first and last vertexes are connected to form closed shapes.

Return values
valReturn the area value

◆ GetGravityCenter()

ILPoint* GetGravityCenter ( )

Get the gravity center of the polygon

◆ GetInscribedCircle()

ILCircle* GetInscribedCircle ( )

Get the inscribed circle of the polygon

◆ GetPerimeter()

double GetPerimeter ( )

Get the perimeter of the polygon

Return values
valReturn the perimeter value

◆ GetPoints()

ILPoints* GetPoints ( )

Get all points in the polygon for further calculation, like generate bounding shape, fitting.

Return values
valReturn the collection of points.

◆ IntersectLine()

LPVIntersectType IntersectLine ( ILLine line,
ILPoints **  intersectPoints 
)

Determines whether this polygon intersects with the given line. Return the intersection points if they are intersected.

Parameters
[in]lineThe input line
[out]intersectPointsOutput the intersection points, it should be an empty set for not-intersected case, 1 or more points for intersected case.
Return values
typeReturn the intersection type depends on the count of intersection points which is on the line segment, LPVIntersectBounded(all), LPVIntersectBoundedPartial(part) or LPVIntersectUnbounded(none).
See also
ILLine::IntersectPoly().

◆ IntersectPolygon()

BOOL IntersectPolygon ( ILPolygon polygon,
ILPoints **  intersectPoints 
)

Determines whether this polygon intersects with another given polygon, and output the intersection points if intersected.

Parameters
[in]polygonThe input another polygon
[out]intersectPointsOutput the intersection points, it should be an empty set for not-intersected case, 1 or more points for intersected case.
Return values
resultReturn true if they are intersected, false otherwise.

◆ Item()

ILPoint* Item ( int  index)

Fetch one point with the given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
Return values
pointReturn the point of given index.

◆ PointTest()

LPVPointTestResult PointTest ( ILPoint point)

Determines whether the point is inside this polygon, outside, or lies on the edge. For a not-closed polygon, the result is either outside or on-the-edge

Parameters
[in]pointThe input point
Return values
valReturn the test result

◆ RemovePoints()

void RemovePoints ( double  lbX,
double  ubX,
double  lbY,
double  ubY 
)

Remove some points in the collection which is in the given range.

Parameters
[in]lbXThe lower bound of the x-coordinate to be removed
[in]ubXThe upper bound of the x-coordinate to be removed
[in]lbYThe lower bound of the y-coordinate to be removed
[in]ubYThe upper bound of the y-coordinate to be removed

◆ Resample()

ILPolygon* Resample ( int  num)

Resample the polygon object into another polygon of the specified vertex count. For an open polygon, the two end points are always kept in the resampled result.

Parameters
[in]numThe count of the resampled vertexes, at least 3
Return values
resultReturn the resampling result polygon
See also
ResampleByStep()

◆ ResampleByStep()

ILPolygon* ResampleByStep ( double  step,
double  stepThreshold 
)

Resample the polygon object into another polygon, based on the given fixed interval step. For an open polygon, the two end points are always kept in the resampled result.

Parameters
[in]stepThe interval step.
[in]stepThresholdThe last resampling vertex should be omitted if the remaining length to the end point is smaller than the threshold. By default, it's 0 means \( Step / 4 \).
Return values
resultReturn the resampling result polygon
See also
Resample()

◆ Set()

void Set ( int  index,
double  x,
double  y 
)

Set the point of the given index to specified position.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count. Pass in negative index to add the new point at the end.
[in]xThe x-coordinate of the new point
[in]yThe y-coordinate of the new point

◆ SetPolygon()

void SetPolygon ( LArray< double >  xs,
LArray< double >  ys,
BOOL  isClosed 
)

Set the points

Parameters
[in]xsThe x-coordinate of the points
[in]ysThe y-coordinate of the points
[in]isClosedWhether this is a closed polygon

◆ ToPolyRegion()

ILPolyRegion* ToPolyRegion ( )

Generate a polygon region use the polygon object

◆ Transform()

ILPolygon* Transform ( ILTransform tf)

Transform the polygon via the given transformation and return a new polygon

Parameters
[in]tfThe transformation.
Return values
Returnthe new polygon

◆ Translate()

ILPolygon* Translate ( double  offsetX,
double  offsetY 
)

Translate the polygon by the given offset and return a new polygon

Parameters
[in]offsetXThe x-coordinate of the offset
[in]offsetYThe y-coordinate of the offset
Return values
resultsReturn the new polygon