Skip to content

Commit 5d9eea8

Browse files
sync
1 parent ac71ae8 commit 5d9eea8

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

src/Aardvark.Geometry.Quadtree/Builder.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ module Builder =
209209

210210
let flattended = LayerSet.Flatten config.Verbose patches
211211

212-
failwith "TODO"
213-
214212
let qnode = QNode(Guid.NewGuid(), ebb, rootCell, config.SplitLimitPowerOfTwo, flattended)
215213

216214
if config.Verbose then

src/Aardvark.Geometry.Quadtree/Layer.fs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,29 +465,25 @@ module Layer =
465465
/// result sample exponent
466466
let e = sampleSizeRange.Min
467467

468-
469-
let mutable i = 0
470-
for l in layersOrdered do
468+
for i=0 to layersOrdered.Length-1 do
469+
470+
let l = layersOrdered[i]
471471

472472
if verbose then
473473
printfn "[Layer.flattenTyped] | layersOrdered[%d] : e=%d origin=%A size=%A" i l.SampleExponent l.SampleWindow.Min l.SampleWindow.Size
474474

475475
if l.SampleExponent <> e then
476-
let resampledLayer = (l :> ILayer).Resample e
477-
failwith "TODO"
478-
479-
i <- i + 1
476+
let resampledLayer = l.Resample e
477+
layersOrdered[i] <- resampledLayer
480478

481-
failwith "TODO"
482-
483-
let finalWindow = layers |> Seq.map (fun l -> l.SampleWindow) |> Box2l
479+
let finalWindow = layersOrdered |> Seq.map (fun l -> l.SampleWindow) |> Box2l
484480
let finalOrigin = Cell2d(finalWindow.Min, e)
485481
let finalMapping = DataMapping(finalOrigin, V2i finalWindow.Size, finalWindow)
486482
let finalData = Array.zeroCreate<'a> (int finalWindow.Size.X * int finalWindow.Size.Y)
487483
let finalMask = Array.create<byte> (int finalWindow.Size.X * int finalWindow.Size.Y) 255uy
488484

489485
if verbose then
490-
for l in layers do printfn "[Layer.flattenTyped] .... [%A-%A]" l.SampleMin l.SampleMaxIncl
486+
for l in layersOrdered do printfn "[Layer.flattenTyped] .... [%A-%A]" l.SampleMin l.SampleMaxIncl
491487
printfn "[Layer.flattenTyped] .... final mapping"
492488
printfn "[Layer.flattenTyped] .... buffer origin: %A" finalOrigin
493489
printfn "[Layer.flattenTyped] .... buffer size : %A" finalWindow.Size
@@ -498,7 +494,7 @@ module Layer =
498494
let debugCollisionSamples = HashSet<int>()
499495

500496
let mutable layerIndex = 0uy
501-
for layer in layers do
497+
for layer in layersOrdered do
502498
let w = layer.Mapping.Window
503499
let xMaxIncl = int w.SizeX - 1
504500
let yMaxIncl = int w.SizeY - 1
@@ -526,8 +522,8 @@ module Layer =
526522
debugCollisionSamples.Add(i) |> ignore
527523
debugCountCollisions <- debugCountCollisions + 1
528524

529-
if verbose then
530-
printfn "[DEBUG][Layer.flattenTyped] COLLISION overwriting value %A from layer %d with value %A from layer %d" finalData[i] finalMask[i] v layerIndex
525+
//if verbose then
526+
// printfn "[Layer.flattenTyped] COLLISION overwriting value %A from layer %d with value %A from layer %d" finalData[i] finalMask[i] v layerIndex
531527

532528
else
533529
()
@@ -542,17 +538,16 @@ module Layer =
542538
let coundOccupiedSamples = finalMask |> Array.sumBy (fun x -> if x = 255uy then 1 else 0)
543539

544540
if verbose && debugCountCollisions > 0 then
545-
printfn "[DEBUG][Layer.flattenTyped] debugCountValues = %d" debugCountValues
546-
printfn "[DEBUG][Layer.flattenTyped] debugCountCollisions = %d" debugCountCollisions
547-
printfn "[DEBUG][Layer.flattenTyped] debugCollisionSamples.Count = %d" debugCollisionSamples.Count
548-
printfn "[DEBUG][Layer.flattenTyped] debugCountOccupied.Count = %d / %d ... %5.2f" coundOccupiedSamples finalMask.Length (float coundOccupiedSamples / float finalMask.Length)
549-
550-
// rewrite mask (1 ... occupied, 0 ... undefined)
541+
printfn "[Layer.flattenTyped] debugCountValues = %d" debugCountValues
542+
printfn "[Layer.flattenTyped] debugCountCollisions = %d" debugCountCollisions
543+
printfn "[Layer.flattenTyped] debugCollisionSamples.Count = %d" debugCollisionSamples.Count
544+
printfn "[Layer.flattenTyped] debugCountOccupied.Count = %d / %d ... %5.2f" coundOccupiedSamples finalMask.Length (float coundOccupiedSamples / float finalMask.Length)
551545

552546
let countOccupied = finalMask |> Array.filter (fun x -> x <> 255uy) |> Array.length
553547
let countUndefined = finalMask |> Array.filter (fun x -> x = 255uy) |> Array.length
554-
printfn "[OCCUPANCY][e = %d][%A][%A] countOccupied = %d, countUndefined = %d" e finalWindow finalWindow.Size countOccupied countUndefined
555-
548+
printfn "[Layer.flattenTyped][OCCUPANCY][e = %d][%A][%A] countOccupied = %d, countUndefined = %d" e finalWindow finalWindow.Size countOccupied countUndefined
549+
550+
// rewrite mask (1 ... occupied, 0 ... undefined)
556551
for i = 0 to finalMask.Length-1 do
557552
finalMask[i] <- if finalMask[i] = 255uy then 0uy else 1uy
558553

src/Aardvark.Geometry.Quadtree/Quadtree.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module Quadtree =
164164
let rec print indent (n : QNodeRef) =
165165
match n with
166166
| NoNode -> printfn "%sNoNode" indent
167-
| InMemoryNode n -> printfn "%sInMemoryNode %A" indent n.Cell
167+
| InMemoryNode n -> printfn "%sInMemoryNode %A; w=%A; wsize=%A; buffer=%A" indent n.Cell n.LayerSet.Mapping.Window n.LayerSet.Mapping.WindowSize n.LayerSet.Mapping.BufferSize
168168
| OutOfCoreNode n -> if outOfCore then
169169
print indent (n.Load())
170170
else

src/Scratch/Program.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,14 @@ let cp_20240202_quadtreetest () =
13541354
let config = Query.Config.Default //{ Query.Config.Default with Verbose = true }
13551355
let resultCells = qtree |> Query.All config |> Seq.toArray
13561356
let samples = makeReturnValOfQueryResults resultCells Defs.HeightsBilinear4f
1357+
let samplesLength = samples.Length
1358+
1359+
Quadtree.PrintStructure true qtree
1360+
1361+
printfn("SAMPLES: count=%d") samplesLength
1362+
let gs = samples |> List.groupBy (fun (c, v) -> c.Exponent) |> List.map (fun (e, xs) -> (e, xs.Length))
1363+
for (e, c) in gs do
1364+
printfn(" e=%d; count=%d") e c
13571365

13581366
()
13591367

0 commit comments

Comments
 (0)