Delphi property ZCallback: TZCallbackD //read & write;

C++ void SetZCallback( ZCallbackD cb);

C#  public ZCallbackD ZCallback { get; set; };

This property is only exposed when the pre-processor directive USINGZ has been defined. If this is the case, an Int64 Z member will be included in the definitions of both the Point64 and PointD classes. (This Z member is for user defined data and has nothing to do with 3D clipping.)

While most vertices in clipping solutions will correspond to input (subject and clip) vertices, there will also be new vertices wherever these edges intersect. This callback facilitates assigning Z values at these intersections. To aid the user in determining appropriate Z values, the function receives four vertices that will be the bottoms and tops of these intersecting edges. (Subject vertices will always be the first two parameters in the callback unless the intersection is between two clip paths.)

In the following examples, use the Z callback to flag intersections (Z = 1) and differentiate them from non-intersection vertices (default Z = 0).

C++ Example:
    using namespace Clipper2Lib;
    // option1 - static callback function
    void myZCBD(const PointD& e1bot, const PointD& e1top,
      const PointD& e2bot, const PointD& e2top, PointD& pt)
      pt.z = 1;

    // option2 - class member callback function
    class MyClass {
      // PointD callback - see TestingZ_Double()
      void myZCBD(const PointD& e1bot, const PointD& e1top,
        const PointD& e2bot, const PointD& e2top, PointD& pt)
        pt.z = 1;

    int main()
    PathsD subject, solution;
      "100, 50, 10, 79, 65, 2, 65, 98, 10, 21"));

    MyClass mc;
    ClipperD c;
    //option 1: static function assignment
    // option 2: class member function assignment
      std::bind(&MyClass::myZCBD, mc, std::placeholders::_1,
        std::placeholders::_2, std::placeholders::_3,
        std::placeholders::_4, std::placeholders::_5));
    c.Execute(ClipType::Union, FillRule::NonZero, solution);

    // display result
    SvgWriter svg;
    SvgAddSubject(svg, subject, FillRule::NonZero);
    SvgAddSolution(svg, solution, FillRule::NonZero, true);
    // draw a red circle around any intersections
    for (const auto& sol_path : solution)
      if (sol_path.empty()) continue;
      PathsD ellipses;
      const double r = 3.0;
      for (const PointD& pt : sol_path)
        if (pt.z) ellipses.push_back(
          Ellipse(RectD(pt.x - r, pt.y - r, pt.x + r, pt.y + r), 11));
      svg.AddPaths(ellipses, false, 
        FillRule::NonZero, 0x20FF0000, 0xFFFF0000, 1, false);
    SvgSaveToFile(svg, "usingz_D.svg", 600, 600, 20);

C# Example:
    using Clipper2Lib;

    public class Application
      public class MyCallbacks
        public void MyCallbackD(PointD bot1, PointD top1,
          PointD bot2, PointD top2, ref PointD intersectPt)
          intersectPt.Z = 1;

      public static void Main()
        PathsD solution = new PathsD();
        PathsD subject = new PathsD();
          new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 }));

        ClipperD c = new ClipperD();
        MyCallbacks cb = new MyCallbacks();
        c.ZCallback = cb.MyCallbackD;
        c.Execute(ClipType.Union, FillRule.NonZero, solution);

        SvgWriter svg= new SvgWriter();
        SvgUtils.AddSubject(svg, subject);
        SvgUtils.AddSolution(svg, solution, false);
        // draw a red circle around any intersections
        for (int i = 0; i < solution[0].Count; i++)
          if (solution[0][i].Z == 1)
            svg.DrawCircle(solution[0][i].X, solution[0][i].Y, 
              4, 1, 0x20FF0000, 0xFFFF0000);
        svg.SaveToFile("usingz.svg", 400, 400);


See Also

Point64, PointD, ZCallbackD