PolyTree

The Clipper Library

Home ClipperLib

PolyTree

Hierarchy

   |

PolyNode

A PolyTree object can be passed as a parameter to Clipper's Execute method. This class encapsulates a data structure that mirrors the parent-child relationships of the polygons returned by Clipper. (The PolyTree class replaces the obsolete ExPolygons structure that was unable to represent polygons 'nesting' within holes.)

The term 'polygon' is often used by others to refer to a single 'outer' contour together with any number of inner contours or 'holes'. However, in this documentation, polygon is used synonymously with a single polygon contour, irrespective of whether it's an outer or a hole.

The PolyTree object encapsulates any number PolyNode children, where a PolyNode object represents a single polygon (either an outer or hole polygon). PolyTree is a specialized PolyNode that contains all the PolyNodes within the tree. Its Contour property will always be empty. The PolyTree's immediate children represent top-level 'outer' polygons returned by the Clipper object. These top-level PolyNodes may contain their own PolyNode children representing hole polygons that may also contain children representing nested outer polygons etc.

Since the PolyTree data structure is more complex than the alternative Polygons data structure that's passed to Clipper's overloaded Execute method, and because it's more computationally expensive to process (roughly 5-10% slower), it should only be used when parent-child polygon relationships are needed and not just polygon coordinates.


    polytree: 
    Contour = ()
    ChildCount = 1
    Childs[0]: 
        Contour = ((10,10),(100,10),(100,100),(10,100))
        IsHole = False
        ChildCount = 1
        Childs[0]: 
            Contour = ((20,20),(20,90),(90,90),(90,20))
            IsHole = True
            ChildCount = 2
            Childs[0]: 
                Contour = ((30,30),(50,30),(50,50),(30,50))
                IsHole = False
                ChildCount = 0
            Childs[1]: 
                Contour = ((60,60),(80,60),(80,80),(60,80))
                IsHole = False
                ChildCount = 0

            

Reference

Fields Methods Properties
In PolyTree:
Clear Total
GetFirst
In PolyNode:
GetNext ChildCount
Childs
Contour
IsHole
Parent

See Also

Clipper.Execute, PolyNode, ExPolygons, Polygons



Copyright ©2010-2012 Angus Johnson  -   Clipper version 5.1.0   -   Help file built on 17-February-2013