Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions
ILPolyClipper Interface Reference

This interface functionalities of various filtering, clipping and offsetting operations to the LPolygon object. More...

Inheritance diagram for ILPolyClipper:
ILObject LPolyClipper

Public Member Functions

ILPolygonExpand (ILPolygon *poly, double delta, double miterLimit)
 
LArray< ILPolygon * > Intersect (ILPolygon *poly1, ILPolygon *poly2)
 
ILPolygonIntersect1 (ILPolygon *poly1, ILPolygon *poly2)
 
ILPolygonShrink (ILPolygon *poly, double delta, double miterLimit)
 
ILPolygonSimplify (ILPolygon *poly, int maxVertexes, double areaThreshold, double angleThreshold)
 
ILPolygonSimplifyDP (ILPolygon *poly, double dt)
 
ILPolygonSmooth (ILPolygon *poly, double nbRange)
 
ILPolygonSmoothIterative (ILPolygon *poly, double filterNbRng, double updateNbRng, int maxIterCount, double stopCriteria)
 
LArray< ILPolygon * > Subtract (ILPolygon *poly1, ILPolygon *poly2)
 
ILPolygonSubtract1 (ILPolygon *poly1, ILPolygon *poly2)
 
ILPolygonTrimCollinear (ILPolygon *poly)
 
LArray< ILPolygon * > Union (ILPolygon *poly1, ILPolygon *poly2)
 
ILPolygonUnion1 (ILPolygon *poly1, ILPolygon *poly2)
 
LArray< ILPolygon * > XOR (ILPolygon *poly1, ILPolygon *poly2)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Detailed Description

This interface functionalities of various filtering, clipping and offsetting operations to the LPolygon object.

To use this interface, you should create a LPolyClipper object.

Example Code

Member Function Documentation

◆ Expand()

ILPolygon* Expand ( ILPolygon poly,
double  delta,
double  miterLimit 
)

Offset the polygon to the outer to create a parallel and inflated polygon.

Parameters
[in]polyThe input polygon object
[in]deltaThe offset distance
[in]miterLimitThe miter threshold for the offset segments to avoid narrow angled joins producing excessively long and narrow spikes. When the mitered joins exceed the specified distance limit (relative to the offset distance), we would use squared connection instead.
Return values
resultPolyReturn the result polygon object.
See also
Shrink()

◆ Intersect()

LArray< ILPolygon *> Intersect ( ILPolygon poly1,
ILPolygon poly2 
)

Intersect the two input polygons, @math_eq{P = P_1 \cap P_2} . If the two inputs are intersected in multiple places, the results are plural.
Note: Only closed polygons are acceptable.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolysReturn the result polygon collection (a list of LPolygon object).
See also
Intersect1(), Union(), Union1(), Subtract(), Subtract1(), XOR()

◆ Intersect1()

ILPolygon* Intersect1 ( ILPolygon poly1,
ILPolygon poly2 
)

Similar functionality as Intersect(), provided for convenience. It report the single polygon. If the intersection results are plural, it reports the one part of the biggest area.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolyReturn the result polygon object.
See also
Intersect(), Union(), Union1(), Subtract(), Subtract1(), XOR()

◆ Shrink()

ILPolygon* Shrink ( ILPolygon poly,
double  delta,
double  miterLimit 
)

Offset the polygon to the inner to create a parallel and deflated polygon.

Parameters
[in]polyThe input polygon object
[in]deltaThe offset distance
[in]miterLimitThe miter threshold for the offset segments to avoid narrow angled joins producing excessively long and narrow spikes. When the mitered joins exceed the specified distance limit (relative to the offset distance), we would use squared connection instead.
Return values
resultPolyReturn the result polygon object.
See also
Expand()

◆ Simplify()

ILPolygon* Simplify ( ILPolygon poly,
int  maxVertexes,
double  areaThreshold,
double  angleThreshold 
)

Simplify the polygon by removing the redundant vertexes that meet the area or angle threshold.

Parameters
[in]polyThe input polygon object
[in]maxVertexesThe maximum count of vertexes in the result polygon. You may set it to 0 to remove all unwanted vertexes.
[in]areaThresholdThe area threshold for the aggregated area for removing the vertex(and its removed neighbors). For smaller than the threshold, the vertexes are treated as redundant and eliminated. Negative or zero value means simplify by area is not enabled.
[in]angleThresholdThe angle threshold for removing the sharp vertexes in the polygon, in 0 ~ 180. Negative or zero value means simplify by angle is not enabled. If both area and angle threshold is specified, then the simplification score is weighted by them both.
If neither of them are specified, then the simplification is in fact the redundant vertexes removal operation for those are on the adjacent collinear segments.
Return values
resultPolyReturn the result polygon object.
See also
SimplifyDP()

◆ SimplifyDP()

ILPolygon* SimplifyDP ( ILPolygon poly,
double  dt 
)

Simplify the polygon using the classic Douglas-Peucker algorithm

Parameters
[in]polyThe input polygon object
[in]dtThe maximum allowable offset between the original and simplified polygon
Return values
resultPolyReturn the result polygon object.
See also
Simplify()

◆ Smooth()

ILPolygon* Smooth ( ILPolygon poly,
double  nbRange 
)

Smooth the polygon by averaging the vertexes in the specified neighbor range.

Parameters
[in]polyThe input polygon object
[in]nbRangeThe neighbor range \( (-nbRange, nbRange) \) in distance measured along the polygon. We may create the interpolated vertex on the endings of the neighborhood for longer edges.
Return values
resultPolyReturn the result polygon object.
See also
SmoothIterative()

◆ SmoothIterative()

ILPolygon* SmoothIterative ( ILPolygon poly,
double  filterNbRng,
double  updateNbRng,
int  maxIterCount,
double  stopCriteria 
)

Smooth the polygon by iteratively applying the mean filtering on to the edge normals then update the vertexes. This approach usually results in better-looking polygon than the naive averaging filtering(aka. Smooth()) and resistant to over-smoothing, but it's also considerable time-consuming.

Parameters
[in]polyThe input polygon object
[in]filterNbRngThe filtering neighbor range \( (-filterNbRng, filterNbRng) \) in distance measured along the polygon and interpolation is involved at the end of the neighborhood. The larger value indicates more edge normals contribute to the filtering result.
[in]updateNbRngThe updating neighbor range \( (-updateNbRng, updateNbRng) \) in distance measured along the polygon and interpolation is involved at the end of the neighborhood. Those neighbors are taken over to calculate the new vertex. The range is usually smaller then the filtering range. The proper value may speed up the convergence and stop the iteration earlier. It's recommended to use 2 ~ 5. By default, it's set to 0 which means 10% of the filtering range.
[in]maxIterCountThe maximum count of iteration. The default value is 30.
[in]stopCriteriaThe stop criteria of the iteration. The default value is 0.001. It stops when the maximum movement of the vertexes is smaller than the criteria, or the difference of maximum movement between the two iterations is smaller than 0.1%: @math_eq{m_i < criteria || (m_i - m_{i-1}) / m_{i-1} < 0.1%}
Return values
resultPolyReturn the result polygon object.
See also
Smooth()

◆ Subtract()

LArray< ILPolygon *> Subtract ( ILPolygon poly1,
ILPolygon poly2 
)

Subtract the two input polygons and get the differences, @math_eq{P = P_1 - P_2} . If the first polygon is separated into several parts by the subtraction, the results are plural.
Note: Only closed polygons are acceptable.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolysReturn the result polygon collection (a list of LPolygon object).
See also
Subtract1(), Union(), Union1(), Intersect(), Intersect1(), XOR()

◆ Subtract1()

ILPolygon* Subtract1 ( ILPolygon poly1,
ILPolygon poly2 
)

Similar functionality as Subtract(), provided for convenience. It report the single polygon. If the difference results are plural, it reports the one part of the biggest area.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolyReturn the result polygon object.
See also
Subtract(), Union(), Union1(), Intersect(), Intersect1(), XOR()

◆ TrimCollinear()

ILPolygon* TrimCollinear ( ILPolygon poly)

Remove the vertexes that are on the adjacent collinear segments, and also remove the duplicated vertexes. It is usually used to reduce the count of vertexes while not changing the shape of the polygon.

Parameters
[in]polyThe input polygon object
Return values
resultPolyReturn the result polygon object.
See also
Simplify()

◆ Union()

LArray< ILPolygon *> Union ( ILPolygon poly1,
ILPolygon poly2 
)

Union the polygons, @math_eq{P = P_1 \cup P_2} . For the two not-intersected inputs, the results are plural; otherwise, they are merged into one.
Note: Only closed polygons are acceptable.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolysReturn the result polygon collection (a list of LPolygon object).
See also
Union1(), Subtract(), Subtract1(), Intersect(), Intersect1(), XOR()

◆ Union1()

ILPolygon* Union1 ( ILPolygon poly1,
ILPolygon poly2 
)

Similar functionality as Union(), provided for convenience. It report the single polygon. If the unioned results are plural, it reports the one part of the biggest area.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolyReturn the result polygon object.
See also
Union(), Subtract(), Subtract1(), Intersect(), Intersect1(), XOR()

◆ XOR()

LArray< ILPolygon *> XOR ( ILPolygon poly1,
ILPolygon poly2 
)

Calculate the symmetric difference of the two input polygons, @math_eq{P = P_1 \oplus P_2} . The results are commonly plural.
Note: Only closed polygons are acceptable.

Parameters
[in]poly1The first input polygon object
[in]poly2The second input polygon object
Return values
resultPolysReturn the result polygon collection (a list of LPolygon object).
See also
Union(), Union1(), Subtract(), Subtract1(), Intersect(), Intersect1()