Refactors Pad and Scale operations into + and * operations on the Dtm_Data type
This commit is contained in:
parent
c6692dcb74
commit
1bb7279f33
18
src/dtm.adb
18
src/dtm.adb
|
@ -22,18 +22,22 @@ package body Dtm is
|
|||
return Max_Val;
|
||||
end Max;
|
||||
|
||||
procedure Scale(Data : in out Dtm_Data; Scale_Factor : Dtm_Value := 100.0) is
|
||||
function "+"(D : Dtm_Data; V : Dtm_Value) return Dtm_Data is
|
||||
R : Dtm_Data := D;
|
||||
begin
|
||||
for Element of Data.Grid loop
|
||||
Element := Element * Scale_Factor;
|
||||
for El of R.Grid loop
|
||||
El := El + V;
|
||||
end loop;
|
||||
end Scale;
|
||||
return R;
|
||||
end;
|
||||
|
||||
procedure Pad(Data :in out Dtm_Data; Pad_Factor : Dtm_Value := 2.0) is
|
||||
function "*"(D : Dtm_Data; V : Dtm_Value) return Dtm_Data is
|
||||
R : Dtm_Data := D;
|
||||
begin
|
||||
for Element of Data.Grid loop
|
||||
Element := Element + Pad_Factor;
|
||||
for El of R.Grid loop
|
||||
El := El * V;
|
||||
end loop;
|
||||
return R;
|
||||
end;
|
||||
|
||||
function Triangle_Count(Info : Dtm_Info) return Natural is
|
||||
|
|
|
@ -12,9 +12,9 @@ package Dtm with SPARK_Mode is
|
|||
Global => null;
|
||||
|
||||
function Max(Data : Dtm_Data) return Dtm_Value;
|
||||
procedure Scale(Data : in out Dtm_Data; Scale_Factor : Dtm_Value := 100.0);
|
||||
procedure Pad(Data :in out Dtm_Data; Pad_Factor : Dtm_Value := 2.0);
|
||||
function Triangle_Count(Info : Dtm_Info) return Natural;
|
||||
function "+"(D : Dtm_Data; V : Dtm_Value) return Dtm_Data;
|
||||
function "*"(D : Dtm_Data; V : Dtm_Value) return Dtm_Data;
|
||||
|
||||
private
|
||||
type Dtm_Data(X, Y : Integer) is tagged
|
||||
|
|
10
src/tess.adb
10
src/tess.adb
|
@ -10,8 +10,8 @@ procedure Tess is
|
|||
use Ada.Text_IO;
|
||||
Info : Dtm_Info;
|
||||
Input : File_Type;
|
||||
Minimum_Thickness : constant := 2.0;
|
||||
Z_Scaling_Value : constant := 100.0;
|
||||
Minimum_Thickness : constant := 1.0;
|
||||
Z_Scaling_Value : constant := 20.0;
|
||||
begin
|
||||
Ada.Text_IO.Put_Line("Tess started.");
|
||||
Open(Input, In_File, "sample-data/katie.dat");
|
||||
|
@ -27,11 +27,11 @@ begin
|
|||
begin
|
||||
Dtm.Katie.Get_Data(Data, Input);
|
||||
Normalize_and_Scale_Factor := Z_Scaling_Value / Max(Data);
|
||||
Data.Scale(Normalize_and_Scale_Factor);
|
||||
Data.Pad(Minimum_Thickness);
|
||||
Data := Data * Normalize_and_Scale_Factor;
|
||||
Data := Data + Minimum_Thickness;
|
||||
Triangles.Reserve_Capacity(Count_Type(Info.Triangle_Count));
|
||||
Dtm.Surface.Surface_From_Grid(Triangles, Data);
|
||||
Stl.Write(Triangles, "Farts.stl");
|
||||
-- Stl.Write(Triangles, "Farts.stl");
|
||||
Stl.Write_Binary(Triangles, "Binary_Farts.stl");
|
||||
end;
|
||||
end Tess;
|
||||
|
|
Loading…
Reference in New Issue