Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SplitTPAEx(const pts: TPointArray; w,h: single): T2DPointArray; cdecl;
- var
- lo,hi: Int32;
- sqx,sqy,sqxy: single;
- procedure ConnectCluster(p: TPoint);
- var i,top: Int32;
- begin
- top := hi;
- for i:=hi downto lo+1 do
- //if (Abs(p.x-pts[i].x) <= w) and (Abs(p.y-pts[i].y) <= h) then
- if (Sqr(p.x-list[i].x)*sqy)+(Sqr(p.y-list[i].y)*sqx) <= sqxy then
- begin
- Swap(pts[i], pts[hi]); // move towards end
- Dec(hi); // reduce upper bound
- end;
- for i:=hi+1 to top do
- ConnectCluster(pts[i]);
- end;
- var top,n: Int32;
- begin
- sqx := Sqr(w);
- sqy := Sqr(h);
- sqxy := sqx*sqy;
- lo := 0;
- hi := High(pts);
- while lo <= hi do
- begin
- top := hi;
- ConnectCluster(pts[lo]);
- // add the connected range
- n := Length(Result);
- SetLength(Result, n+1);
- Result[n] := Copy(pts, hi+1, (top-hi));
- Append(Result[n], pts[lo]);
- Inc(lo); // increase lower bound
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement