procedure FillFloodMaps_Crawler(x,y,dist:integer; fillHeight:single); forward;
procedure FillFloodMaps(x,y,dist:integer; fillHeight:single);
var DEM_Height, DEM_NoDataValue:single;
begin
if FlowMap[x,y] >= dist then
if FloodHeightMap[x,y] < fillHeight then
begin
//DEM_Height:=0;
//writeLn(floattostr(DEM_Height)); {--> segfaults when uncommented}
DEM.GetPixel(x,y,single(DEM_Height)); {--> segfaults}
//writeLn(floattostr(DEM_Height));
DEM.GetNoDataValue(single(DEM_NoDataValue));
if (DEM_Height<>DEM_NoDataValue) AND (DEM_Height<fillHeight) then
begin
FloodHeightMap[x,y]:=fillHeight;
FloodDepthMap[x,y]:=fillHeight-DEM_Height;
FillFloodMaps_Crawler(x,y,dist,fillHeight);
end;
end;
end;
procedure FillFloodMaps_Crawler(x,y,dist:integer; fillHeight:single);
begin
if (x+1<=Flood.Width-1) then FillFloodMaps(x+1,y, dist,fillHeight);
if (x+1<=Flood.Width-1) AND (y+1<=Flood.Height-1) then FillFloodMaps(x+1,y+1,dist,fillHeight);
if (y+1<=Flood.Height-1) then FillFloodMaps(x,y+1, dist,fillHeight);
if (x-1>=0) AND (y+1<=Flood.Height-1) then FillFloodMaps(x-1,y+1,dist,fillHeight);
if (x-1>=0) then FillFloodMaps(x-1,y, dist,fillHeight);
if (x-1>=0) AND (y-1>=0) then FillFloodMaps(x-1,y-1,dist,fillHeight);
if (y-1>=0) then FillFloodMaps(x,y-1, dist,fillHeight);
if (x+1<=Flood.Width-1) AND (y-1>=0) then FillFloodMaps(x+1,y-1,dist,fillHeight);
end;