Clipper64.ZCallback

Delphi property ZCallback: TZCallback64 //read & write;

C++ void SetZCallback( ZCallback64 cb);

C#  public ZCallback64 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.)

C++ Example:
  using namespace Clipper2Lib;
  
  class MyClass {
  public:
    void myZCB(const Point64& e1bot, const Point64& e1top,
      const Point64& e2bot, const Point64& e2top, Point64& pt)
    {
      pt.z = 1;
    }
  };
    
  static void myZCB(const Point64& e1bot, const Point64& e1top,
    const Point64& e2bot, const Point64& e2top, Point64& pt)
  {
    pt.z = 1;
  }
    
  int main()
  {
    PathsD subject, clip, solution;
    //fill subject and clip paths here
    
    //option 1: static function assignment
    Clipper64 c = Clipper64;
    c.SetZCallback(myZCB);
    
    //option 2: class member function assignment
    MyClass mc;    
    Clipper64 c = Clipper64;
    c.SetZCallback(
      std::bind(&MyClass::myZCB, mc, std::placeholders::_1,
        std::placeholders::_2, std::placeholders::_3,
        std::placeholders::_4, std::placeholders::_5));
        
    //and complete clipping operation
  }  
  
      

See Also

Point64, PointD, ZCallback64