Janilabo

Janilabo | TPAExtractPoints()

Dec 17th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.92 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Extracts all points from a given TPointArray TPA
  3.                by removing all points that fall outside extractPoints.    
  4. [==============================================================================}
  5. procedure TPAExtractPoints(var TPA: TPointArray; extractPoints: TPointArray);
  6. var
  7.   tmp: TPointArray;
  8. begin
  9.   if (Length(TPA) > 0) then
  10.     if (Length(extractPoints) > 0) then
  11.     begin
  12.       tmp := CopyTPA(TPA);  
  13.       TPAFilterPoints(tmp, extractPoints);
  14.       if (Length(tmp) > 0) then
  15.       begin
  16.         TPAFilterPoints(TPA, tmp);
  17.         SetLength(tmp, 0);
  18.       end;
  19.     end else
  20.       SetLength(TPA, 0);
  21. end;
  22.  
  23. var
  24.   tmp, TPA: TPointArray;
  25.  
  26. begin
  27.   TPA := [Point(1, 1), Point(1, 2), Point(2, 1), Point(2, 2)];
  28.   TPAExtractPoints(TPA, tmp);
  29.   WriteLn(TPAToStr(TPA));
  30.   SetLength(TPA, 0);
  31. end.
Advertisement
Add Comment
Please, Sign In to add comment