PolygonFromLoops constructs a polygon from the given set of loops. The polygon interior consists of the points contained by an odd number of loops. (Recall that a loop contains the set of points on its left-hand side.) This method determines the loop nesting hierarchy and assigns every loop a depth
(loops []*Loop)
| 90 | // Note: The given set of loops are reordered by this method so that the hierarchy |
| 91 | // can be traversed using Parent, LastDescendant and the loops depths. |
| 92 | func PolygonFromLoops(loops []*Loop) *Polygon { |
| 93 | p := &Polygon{} |
| 94 | // Empty polygons do not contain any loops, even the Empty loop. |
| 95 | if len(loops) == 1 && loops[0].IsEmpty() { |
| 96 | p.initLoopProperties() |
| 97 | return p |
| 98 | } |
| 99 | p.loops = loops |
| 100 | p.initNested() |
| 101 | return p |
| 102 | } |
| 103 | |
| 104 | // PolygonFromOrientedLoops returns a Polygon from the given set of loops, |
| 105 | // like PolygonFromLoops. It expects loops to be oriented such that the polygon |
searching dependent graphs…