Sure thing!Could you give us a little word what the code is supposed to do?
What information does FPoints hold?
FPoints is a TList object and it stores TShapeVec objects:
[pascal]
{ .: TShapeVec :. }
TShapeVec = class(TObject)
public
{ Public declarations }
X, Y: Integer;
constructor Create(const AX, AY: Integer);
end;
[/pascal]
TShape stores points that describe a shape. It has a few other methods. Here's the snippet:
[pascal]
{ .: TShape :. }
TShape = class(TObject)
private
{ Private declarations }
FPoints: TList;
function GetPoint(const AIndex: Integer): TShapeVec;
procedure SetPoint(const AIndex: Integer; const Value: TShapeVec);
function GetCount(): Integer;
public
{ Public declarations }
constructor Create(); overload;
constructor Create(AShape: TShape); overload;
constructor Create(APoints: TArrOfPoints); overload;
destructor Destroy(); override;
procedure Add(const AX, AY: Integer);
procedure Delete(const AIndex: Integer);
procedure Clear();
function Validate(): Boolean;
procedure LoadFromXML(const FileName: String);
procedure SaveToXML(const FileName: String);
procedure ImportFromStream(S: TMemoryStream);
procedure ExportToStream(S: TMemoryStream);
property Points[const AIndex: Integer]: TShapeVec read GetPoint
write SetPoint; default;
property Count: Integer read GetCount;
end;
[/pascal]
I've got a problem with Validate method, which is supposed to check if the lines doesn't intersect. Here is the code (not optimized so far):
http://pastebin.com/f4d5572a7
This procedure sometimes works correctly, sometimes not. :shock: I.e. it doesn't work for these points:
[pascal]
(0; 0)
(1; 3)
(0; 5)
(10; 4)
[/pascal]
It says these points intersect, but they don't!
Why doesn't it work? :cry:
Bookmarks