Skip to content

Commit

Permalink
Saving/restoring of point cloud has been implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvmorozov committed Sep 26, 2019
1 parent f9f3070 commit 1408efc
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion ExamplesMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ TForm1 = class(TForm)
DownhillSimplexAlgorithm1: TDownhillSimplexAlgorithm;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
{ Minimum bounding box problem. }
SavedPointCloud: TComponentList;
{ Set of random points. }
PointCloud: TComponentList;
{ Angles describing rotation of coordinate system. }
Expand All @@ -31,6 +31,10 @@ TForm1 = class(TForm)
BoxPosition: TDoubleVector3;
InitialVolume: Double;

{ TODO: saving/restoring make more efficient. }
procedure CopyPointCloud(Src: TComponentList; var Dest: TComponentList);
procedure SavePointCloud;
procedure RestorePointCloud;
procedure GenerateRandomPointCloud;
procedure InitializeVariableParameters;
procedure TransformPointCloudCoordinates;
Expand Down Expand Up @@ -208,4 +212,31 @@ function TForm1.ComputeBoxVolume: Double;
Result := A * B * C;
end;

procedure TForm1.CopyPointCloud(Src: TComponentList; var Dest: TComponentList);
var i: LongInt;
Point: T3DVector;
begin
if Dest <> nil then
Dest.Destroy;

Dest := TComponentList.Create(True);

for i := 0 to Src.Count - 1 do
begin
Point := T3DVector.Create(nil);
Point.Vector := T3DVector(Src[i]).Vector;
Dest.Add(Point);
end;
end;

procedure TForm1.SavePointCloud;
begin
CopyPointCloud(PointCloud, SavedPointCloud);
end;

procedure TForm1.RestorePointCloud;
begin
CopyPointCloud(SavedPointCloud, PointCloud);
end;

end.

0 comments on commit 1408efc

Please sign in to comment.