Skip to content

Commit

Permalink
changed KdTree loading order in favor of lazy kdtree's and rebuilding…
Browse files Browse the repository at this point in the history
… fading out InCore Level0 KdTrees & version bump
  • Loading branch information
haraldsteinlechner committed Apr 11, 2024
1 parent 6b7d8e9 commit 973b8fe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.6.1
- changed KdTree loading order in favor of lazy kdtree's and rebuilding fading out InCore Level0 KdTrees.

### 1.6.0
- exposed kdtree build flags

Expand Down
42 changes: 25 additions & 17 deletions src/OPCViewer.Base/KdTrees.fs
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,9 @@ module KdTrees =
let missingKd0Paths = kd0Paths |> Array.filter (not << System.IO.File.Exists << snd)
Log.line "[KdTrees] valid kd0 paths: %d/%d" missingKd0Paths.Length kd0Paths.Length

if not ignoreMasterKdTree && (File.Exists masterKdPath && not (Array.isEmpty missingKd0Paths)) && not forceRebuild then
let allKd0Available = Array.isEmpty missingKd0Paths

Log.warn "Found master kdtree - loading incore. THIS NEEDS A LOT OF MEMORY. CONSIDER CREATING PER-PATCH KD TREES. see: "
let tree = loadKdtree masterKdPath

let kd =
{ kdTree = tree
boundingBox = tree.KdIntersectionTree.BoundingBox3d.Transformed(trafo) }

HashMap.single kd.boundingBox (InCoreKdTree kd)
else
if allKd0Available || ignoreMasterKdTree || forceRebuild then
Log.line "Found master kdtree and patch trees"
Log.startTimed "building lazy kdtree cache"

Expand Down Expand Up @@ -268,9 +260,13 @@ module KdTrees =
if kdTreeParameters.setObjectSetToNull then
kdTree.ObjectSet <- null

Log.startTimed "saving KdTree to: %s" info.Name
saveKdTree kdTree kdPath
Log.stop()
if not surpressFileConstruction then
Log.startTimed "saving KdTree to: %s" info.Name
saveKdTree kdTree kdPath
Log.stop()
else
Log.warn "[KdTrees] live KdTree construction is supressed, please create KdTrees manually."

let fi = FileInfo(kdPath)
Log.line $"{info.Name} has size: {Mem(fi.Length)}."
ConcreteKdIntersectionTree(kdTree, Trafo3d.Identity)
Expand All @@ -283,10 +279,12 @@ module KdTrees =
Log.warn "[KdTrees] could not load kdtree: %A" e
if surpressFileConstruction then None
else createConcreteTree() |> Some
elif not surpressFileConstruction then
createConcreteTree() |> Some
else
None
else
if not surpressFileConstruction then
createConcreteTree() |> Some
else
Log.warn "[KdTrees] Kdtree not available, please build it manually using opc-tool or pro3d."
None


match t with
Expand Down Expand Up @@ -331,6 +329,16 @@ module KdTrees =
else
HashMap.empty

else
Log.warn "Found master kdtree - loading incore. THIS NEEDS A LOT OF MEMORY. CONSIDER CREATING PER-PATCH KD TREES. see: "
let tree = loadKdtree masterKdPath

let kd =
{ kdTree = tree
boundingBox = tree.KdIntersectionTree.BoundingBox3d.Transformed(trafo) }

HashMap.single kd.boundingBox (InCoreKdTree kd)


if File.Exists cacheFile then
Log.line "Found lazy KdTree cache"
Expand Down

0 comments on commit 973b8fe

Please sign in to comment.