initNested takes the set of loops in this polygon and performs the nesting computations to set the proper nesting and parent/child relationships.
()
| 280 | // initNested takes the set of loops in this polygon and performs the nesting |
| 281 | // computations to set the proper nesting and parent/child relationships. |
| 282 | func (p *Polygon) initNested() { |
| 283 | if len(p.loops) == 1 { |
| 284 | p.initOneLoop() |
| 285 | return |
| 286 | } |
| 287 | |
| 288 | lm := make(loopMap) |
| 289 | |
| 290 | for _, l := range p.loops { |
| 291 | lm.insertLoop(l, nil) |
| 292 | } |
| 293 | // The loops have all been added to the loopMap for ordering. Clear the |
| 294 | // loops slice because we add all the loops in-order in initLoops. |
| 295 | p.loops = nil |
| 296 | |
| 297 | // Reorder the loops in depth-first traversal order. |
| 298 | p.initLoops(lm) |
| 299 | p.initLoopProperties() |
| 300 | } |
| 301 | |
| 302 | // loopMap is a map of a loop to its immediate children with respect to nesting. |
| 303 | // It is used to determine which loops are shells and which are holes. |
no test coverage detected