TClipper.Execute

function Execute(clipType: TClipType; out solution: TArrayOfArrayOfFloatPoint; subjFillType: TPolyFillType = pftEvenOdd; clipFillType: TPolyFillType = pftEvenOdd): Boolean; overload;


function Execute(clipType: TClipType; out solution: TArrayOfArrayOfFixedPoint; subjFillType: TPolyFillType = pftEvenOdd; clipFillType: TPolyFillType = pftEvenOdd): Boolean; overload;


The Execute() method performs the specified clipping task (intersection, union, difference or xor) on the previously assigned subject and clip polygons. This method can be called multiple times without reassigning subject and clip polygons (ie when different clipping operations are required on the same polygon sets). The polygon fill methods can be Even-Odd, Non-Zero, Positive and Negative. Subject and clip polygons can use different fill types.

The order that polygons are listed in the solution structure is undefined, though polygons lower down (when rendered in an image) are generally listed before those higher up. The solution will never contain overlapping polygons, nor will it contain polygons with self-intersections. Also, the filling mode for solution polygons is undefined since it can be either EvenOdd or NonZero. (This is because the winding depth of solution polygons will always be in the range of -1 to 1.)

Solution orientation: Polygons returned in the 'solution' will always have a positive (true) orientation for outer 'container' polygons, and the opposite orientation for inner 'hole' polygons.

Example
uses GR32, GR32_Clipper;
	...
	var
	  i: integer;
	  subj, clip, solution: TArrayOfArrayOfFloatPoint;
	begin
	  setlength(subj, 2);
	  setlength(subj[0], 4);
	  subj[0][0] := FloatPoint(180,200);
	  subj[0][1] := FloatPoint(260,200);
	  subj[0][2] := FloatPoint(260,150);
	  subj[0][3] := FloatPoint(180,150);
	  
	  setlength(subj[1], 3);
	  subj[1][0] := FloatPoint(215,160);
	  subj[1][1] := FloatPoint(230,190);
	  subj[1][2] := FloatPoint(200,190);

	  setlength(clip, 1);
	  setlength(clip[0], 4);
	  clip[0][0] := FloatPoint(190,210);
	  clip[0][1] := FloatPoint(240,210);
	  clip[0][2] := FloatPoint(240,130);
	  clip[0][3] := FloatPoint(190,130);
	  
	  with TClipper.Create do
	  try
	    Add(subj, ptSubject);
	    Add(clip, ptClip);
	    Execute(ctIntersection, solution, pftNonZero, pftNonZero);
	  finally
	    free;
	  end;
	  
	  //nb: DrawPolygons is a stub for your own polygon rendering code.
	  DrawPolygons(subj, $160000FF, $600000FF);
	  DrawPolygons(clip, $20FFFF00, $30FF0000);
	  DrawPolygons(solution, $3000FF00, $FF006600);
          

See Also

Orientation