Function S2Polygon.initializeNested

Create a polygon from a set of hierarchically nested 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.)

void initializeNested (
  S2Loop[] loops
);

This method figures out the loop nesting hierarchy and assigns every loop a depth. Shells have even depths, and holes have odd depths. Note that the loops are reordered so the hierarchy can be traversed more easily (see GetParent(), GetLastDescendant(), and S2Loop::depth()).

This method may be called more than once, in which case any existing loops are deleted before being replaced by the input loops.