Polygon represents a sequence of zero or more loops; recall that the interior of a loop is defined to be its left-hand side (see Loop). When the polygon is initialized, the given loops are automatically converted into a canonical form consisting of "shells" and "holes". Shells and holes are both or
| 50 | // |
| 51 | // - No loop may be empty. The full loop may appear only in the full polygon. |
| 52 | type Polygon struct { |
| 53 | loops []*Loop |
| 54 | |
| 55 | // index is a spatial index of all the polygon loops. |
| 56 | index *ShapeIndex |
| 57 | |
| 58 | // hasHoles tracks if this polygon has at least one hole. |
| 59 | hasHoles bool |
| 60 | |
| 61 | // numVertices keeps the running total of all of the vertices of the contained loops. |
| 62 | numVertices int |
| 63 | |
| 64 | // numEdges tracks the total number of edges in all the loops in this polygon. |
| 65 | numEdges int |
| 66 | |
| 67 | // bound is a conservative bound on all points contained by this loop. |
| 68 | // If l.ContainsPoint(P), then l.bound.ContainsPoint(P). |
| 69 | bound Rect |
| 70 | |
| 71 | // Since bound is not exact, it is possible that a loop A contains |
| 72 | // another loop B whose bounds are slightly larger. subregionBound |
| 73 | // has been expanded sufficiently to account for this error, i.e. |
| 74 | // if A.Contains(B), then A.subregionBound.Contains(B.bound). |
| 75 | subregionBound Rect |
| 76 | |
| 77 | // A slice where element i is the cumulative number of edges in the |
| 78 | // preceding loops in the polygon. This field is used for polygons that |
| 79 | // have a large number of loops, and may be empty for polygons with few loops. |
| 80 | cumulativeEdges []int |
| 81 | } |
| 82 | |
| 83 | // PolygonFromLoops constructs a polygon from the given set of loops. The polygon |
| 84 | // interior consists of the points contained by an odd number of loops. (Recall |
nothing calls this directly
no outgoing calls
no test coverage detected