Menu

parent child relationship from a number of closed paths

sajjad
2016-06-07
2016-07-10
  • sajjad

    sajjad - 2016-06-07

    Hello forum,

    I have several closed paths generated with another API. I want to use clipper to create the parent-child relationship among these closed paths. All the closed paths are separated and not self-intersecting.

    Thanks

     
  • Timo Kähkönen

    Timo Kähkönen - 2016-07-10

    Clipper makes those relationships automatically if you use PolyTree as a solution structure instead of Paths. Something like:

    Clipper c = new Clipper();
    PolyTree solution = new PolyTree();
    c.AddPaths(subj, PolyType.ptSubject, true); // subj is your source paths as Paths structure
    c.Execute(ClipType.ctUnion, solution);

    Solution PolyTree is now filled with data representing the solution. Execute() makes an UNION operation, so it can change your coordinates in case of overlapping source polygons. But if none are overlapping, it just organizes the paths to represent their parent-child relationships.