SRL Archive - Development

TPointArray object.


Wizzup?

2010-01-16 11:22:33

Currently, we have exported Wizzyplugin in it's entirety to Simba.
However, Raymond and I believe a more OOP approach to TPointArrays would be better.


var
t: TTPAObj;
begin
t := TTPAObj.Create([Point(0,0)]);
t.sortfrom(point(2,4));
t.split(1,2);
end.

Something like that, although probably a bit more or less complicated. Perhaps it would like different, but I think currently the naming conventions and approach in wizzyplugin sucks. :)

What do you think?

Naum

2010-01-16 11:32:42

Looks plausible, I would use it. If you changed it from what it is I wouldn't mind so much.
However, many people are used to calling it differently, so this could affect them. Also as long as it is stable it shouldn't really be a problem.

EDIT: Naming conventions are fine IMO.

Nava2

2010-01-16 11:37:56

Hmm, will split mess it up being as it has to hold a 2D array?

Or will we just have references like:
for i := 0 to High(t.get2D()) do
t.get2D[0].middleEx(x, y);

That looks goofy to me.. the only issue is the 2D aspect.

We could also set it up like the Items property in a TList.

Blumblebee

2010-01-16 14:07:39

i like the oop style approach, after working with java and stuff it just makes so much more sense (easier to see and use things imo).

Nava2

2010-01-16 14:40:22

type
TTPAObject = class(TObject)
protected
ptArr: TList; // allows for it to be a 2D Array or a 1D;; public?
intA: TIntegerArray; // for color stuff
private
public
procedure RAaSTPAEx(const w, h: Integer);
procedure RAaSTPA(const Dist: Integer);
function NearbyPointInArrayEx(const P: TPoint; w, h:Integer): Boolean;
function NearbyPointInArray(const P: TPoint; Dist:Integer): Boolean;
procedure ReArrangeandShortenArrayEx(w, h: Integer): TPointArray;// set internal
procedure ReArrangeandShortenArray(Dist: Integer): TPointArray; // set internal
procedure TPAtoATPAEx(w, h: Integer); // set internal
procedure TPAtoATPA(Dist: Integer); // set internal
{ procedure QuickTPASort(var A: TIntegerArray; var B: TPointArray; iLo, iHi: Integer; SortUp: Boolean);
procedure QuickATPASort(var A: TIntegerArray; var B: T2DPointArray; iLo, iHi: Integer; SortUp: Boolean); }
procedure SortTPAFrom(const From: TPoint); // set internal
procedure SortATPAFrom(const From: TPoint); // set internal
procedure SortATPAFromFirstPoint(const From: TPoint); // set internal
procedure InvertTPA; // set internal
procedure InvertATPA; // set internal
function MiddleTPAEx(out x, y: Integer): Boolean; // set internal
procedure MiddleTPA: TPoint;
procedure SortATPASize(const BigFirst: Boolean); // set internal
procedure SortATPAFromSize(const Size: Integer; CloseFirst: Boolean); // set internal
//function CombineTPA(Ar1, Ar2: TPointArray): TPointArray;
procedure AddTPA(addArr: TPointArray); // set internal, perhaps use another TTPAObject
{procedure ClearSameIntegers(var a: TIntegerArray); }
//and now im too lazy to change more for no reason :D
procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;
procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
function GetATPABounds(ATPA: T2DPointArray): TBox;
function GetTPABounds(TPA: TPointArray): TBox;
function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray;
procedure SortCircleWise(var tpa: TPointArray; const cx, cy, StartDegree: Integer; SortUp, ClockWise: Boolean);
procedure LinearSort(var tpa: TPointArray; cx, cy, sd: Integer; SortUp: Boolean);
Function MergeATPA(ATPA : T2DPointArray) : TPointArray;
function TPAFromBox(const Box : TBox) : TPointArray;
Function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray ;
Function RotatePoint(Const p: TPoint; angle, mx, my: Extended): TPoint; inline;
function FindTPAEdges(p: TPointArray): TPointArray;
function PointInTPA(p: TPoint; arP: TPointArray): Boolean;
function ClearTPAFromTPA(arP, ClearPoints: TPointArray): TPointArray;
procedure ClearDoubleTPA(var TPA: TPointArray);
Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray;
Procedure TPACountSort(Var TPA: TPointArray;const max: TPoint;Const SortOnX : Boolean);
Procedure TPACountSortBase(Var TPA: TPointArray;const maxx, base: TPoint; const SortOnX : Boolean);

// these could be avoided by making the TList public.
function get(ind: Integer): Pointer; // may not be necessary..
procedure Put(ind: Integer; p: Pointer); // ^
property Items[Index: Integer]: Pointer read Get write Put; default; // will this allow for Items[x][y]?
end;

Purely for concept, all I did was toss it all in a class..

Wizzup?

2010-01-16 17:21:58

That makes no sense…

Nava2

2010-01-17 01:27:02

Idk, how else are you going to support T2DPointArrays

mixster

2010-01-17 09:40:12

Add T2DPointArrays as separate objects? TPA.Split() returns a T2DPA and all the others things as well. Then add a bit of operator overloading (unsure if that can be added through PS though?) so that individual arrays in the T2DPA can be assigned TPA's, otherwise wrapper functions for it?

mastaraymond

2010-01-17 10:26:30

Seperate classes for TPA and ATPA?

Nava2

2010-01-17 10:27:46

We already overload the `+' and `-' operators for TPoints, why not for TPA's and ATPAs.. albeit, that also means that we would need to do it for other arrays?

Wizzup?

2010-01-17 15:29:23

From: Nava2
We already overload the `+' and `-' operators for TPoints, why not for TPA's and ATPAs.. albeit, that also means that we would need to do it for other arrays?


Because that is ambiguous. Plus means 'add'. So what is it, combine those two arrays? Add every element in one array to another? Add them all up to one Point?

mixster

2010-01-17 15:40:27

I would hazard a guess that if people wanted to add 2 TPA's, they would want to append one to the other to form a single, longer TPA of all points. Similarly, subtraction of a TPA could be used to remove duplicate points that are common to both, returning the remaining ones in the first TPA.

Nava2

2010-01-17 16:39:14

From: mixster
I would hazard a guess that if people wanted to add 2 TPA's, they would want to append one to the other to form a single, longer TPA of all points. Similarly, subtraction of a TPA could be used to remove duplicate points that are common to both, returning the remaining ones in the first TPA.


^That was my intention with my comment..

Wizzup?

2010-01-17 17:26:42

Like I said, it is WAY too ambiguous, and very useless.