Delphi property Child[index: Integer]: TPolyPath64; default; //read-only
C++ const PolyPath64* Child(size_t index) const
C++ const PolyPath64* operator [] (size_t index) const
C# PolyPath64 Child(int index);
C# PolyPath64 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.
// 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 PolyPath64List::const_iterator ppi, ppi2; for (ppi = polytree.begin(); ppi != polytree.end(); ++ppi) for (ppi2 = (*ppi)->begin(); ppi != (*ppi)->end(); ++ppi2) { const std::unique_ptr<PolyPath64>& 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;
PolyTree64 polytree; // do boolean op that populates polytree // now access the polytree foreach (PolyPath64 poly in polytree) foreach (PolyPath64 hole in poly) if (hole.Count > 0) Debug.Assert(!hole[0].IsHole && hole.Child(0).Level == 3); // and another way to access nested PolyPath64 objects PolyPath64 holeInsideSecondPoly = polytree[1][0];
var i,j : Integer; polytree: TPolyTree64; 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;
Copyright © 2010-2024 Angus Johnson - Clipper2 1.3.0 - Help file built on 14 Jan 2024