PolyPathD.Child

Delphi property Child[index: Integer]: TPolyPathD; default; //read-only


C++ const PolyPathD* Child(size_t index) const

C++ const PolyPathD* operator [] (size_t index) const


C#  PolyPathD Child(int index);

C#  PolyPathD this[int index]{ get{} }


Child is perhaps the most explicit way of accessing children (ie nested polygon contours that are contained within Polygon).
The array operator [ ] is another (simpler) way of access children, and iterators can also be used.

C++
  // nice and simple
  for (const auto& poly : polytree)
    for (const auto& hole : *poly)
    {
      if (!hole->IsHole() || hole->Level() != 2)
        std::cout << "oops!";
    }

  // or full disclosure
  PolyPathDList::const_iterator ppi, ppi2;
  for (ppi = polytree.begin(); ppi != polytree.end(); ++ppi)
    for (ppi2 = (*ppi)->begin(); ppi != (*ppi)->end(); ++ppi2)
    {
      const std::unique_ptr<PolyPathD>& hole = *ppi2;
      if (!hole->IsHole() || hole->Level() != 2)
        std::cout << "oops!";
    }
    
  // and other somewhat messy options
  const auto& first_poly = polytree.Child(0);
  if (first_poly->Count() && 
    first_poly->Child(0)->Level() != 2 ||
    !first_poly[0].IsHole())
      std::cout << "oops!" << std::endl;
      

C#
    PolyTreeD polytree;
    // do boolean op that populates polytree
    // now access the polytree
    foreach (PolyPathD poly in polytree)
      foreach (PolyPathD hole in poly)
        if (hole.Count > 0)
          Debug.Assert(!hole[0].IsHole && hole.Child(0).Level == 3);
    // and another way to access nested PolyPathD objects
    PolyPathD holeInsideSecondPoly = polytree[1][0];
  
      

Delphi
    var 
      i,j     : Integer;
      polytree: TPolyTreeD;
    begin
      // do boolean op that populates polytree
      // now access the polytree
        for i := 0 to polytree.Count -1 do
          for j := 0 to polytree[i].Count -1 do
            if not polytree[i][j].IsHole or
              (polytree[i][j].Level <> 2) then
                WriteLn('oops!');
    end;
      

See Also

Polygon