Skip to content

Commit 978a9d3

Browse files
authored
Merge pull request #381 from pro3d-space/bugs/masterKdTreeOOM
KdTree discoverability, cache creation, KdTree creation support in PRo3D
2 parents 24b212d + 187acd6 commit 978a9d3

21 files changed

+336
-464
lines changed

PRODUCT_RELEASE_NOTES.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 4.22.0
2+
- further improved kdtree loading on NTFS/macbook
3+
4+
5+
## 4.21.0-prerelease3
6+
- further improved kdtree loading on NTFS/macbook
7+
8+
## 4.21.0-prerelease2
9+
- fixed kdtree loading on NTFS/mac
10+
11+
## 4.21.0-prerelease1
12+
- added support to re-create kdtrees
13+
14+
## 4.20.2
15+
- opc tool now supports "ignoreMasterKdTree" option which can be used to force leaf kdtree construction
16+
117
## 4.20.1
218
- added readme to opc-tool
319

aardium/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "PRo3D",
33
"productName": "PRo3D.Viewer",
4-
"version": "4.2.0-prerelease1",
4+
"version": "4.22.0",
55
"description": "PRo3D, short for Planetary Robotics 3D Viewer, is an interactive 3D visualization tool to allow planetary scientists to work with high-resolution 3D reconstructions of the Martian surface.",
66
"license": "AGPL",
77
"copyright": "VRVis Zentrum für Virtual Reality und Visualisierung Forschungs-GmbH",

docs/KdTrees.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
### General concept
2+
3+
PRo3D has two mechanisms for picking:
4+
1. geometry based picking on surfaces via KdTrees. This is implemented via [aardvark.geometry.intersection](https://github.com/aardvark-platform/aardvark.algodat/tree/3b225ef80e87c24177fcd1230c1e368408c52e6b/src/Aardvark.Geometry.Intersection).
5+
2. rendering driven picking via pixel-readback. This one is used for picking existing annotations in a scene. Starting point is [here](https://github.com/pro3d-space/PRo3D/blob/1c8601d9fc88f81a03dae12965af1fb72fe61bcd/src/PRo3D.Core/Drawing/PackedRendering.fs#L519).
6+
7+
Here we describe the current state of KdTree picking (notes by harald: Parts of this seems to have no official documentation, thus i reconstruted it from my "rework" efforts for KdTrees, at least it makes sense and matches current data available and the current source code).
8+
One could create a single kdtree for a whole OPC hierarchy (1). Another option is to create "smaller" KdTrees for leaf nodes of OPC hierarchies (2).
9+
PRo3D generally supported both, but especially for huge scenes (1) is problematic.
10+
The plan is to fade-out (1) in favor of (2).
11+
1. Master KdTree files:
12+
![alt text](./images/masterKdTree.png). Usage/Loading can be seen [here](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs). Packing a complete hierarchy into a single file has several drawbacks: firstly it takes a long loading time, secondly it is not out-of-core and thirdly it might have issues with floating-point precision for huge scenes (all files i have seen have double precision though). Recently [`ignoreMasterKdTree`](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L212) flag was introduced to provide a transition scheme for master KdTrees.
13+
2. Per-Patch KdTree files. Typically they are placed just in the "top-level" patch directory.
14+
![alt text](./images/patchKdTrees.png). (note by harald: i have seen hierarchies where those are placed in the respective patch directory. This seems to have changed over time though)
15+
16+
17+
### Loading of Per-Patch KdTree files
18+
19+
Loading takes place [here](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L210). A validation step makes sure that all KdTrees are here. If not, in-place KdTree creation can be [triggered via appropriate flags](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L262):
20+
```
21+
9: there are missing Kd0Paths. The first one has the following path: K:\gardencity\MSL_Mastcam_Sol_925_id_48420\OPC_000_000\patches\03-Patch-00001~0035\00-Patch-00016~0005-0.aakd
22+
9: in total there are 24/24 of Kd0Paths missing
23+
```
24+
25+
### Lazy KdTree caches
26+
27+
To support lazy loading of particular KdTrees, the loading can be delayed via [LazyKdTrees](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L277).
28+
To build a list of lazy kdtrees, unfortunately the original kdtree needs to be loaded once to extract the bounding box currently (partly reading of kdtrees could get rid of this of course).
29+
The bounding box, kdtree tuples are stored in .cache files to prevent this step when loading a surface, [see here.](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L305)
30+
31+
Recently i tried to make this quite robust, if however the cache file cannot be loaded or is invalid, the loading code can be used to create a new cache file. If the surface is loaded from a readonly file system or another problem appears this fails and is ignored (see [here](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L307)).
32+
33+
## Create KdTrees for an OPC hierarchy.
34+
35+
KdTrees can be constructed:
36+
- directly from within PRo3D. This is now available via the UI
37+
![alt text](./images/createKdTree.png)
38+
- the [library](https://www.nuget.org/packages/OPCViewer.Base) and in [particular](https://github.com/aardvark-platform/OpcViewer/blob/7fdf368e1e59a2c33c0cc7e5ca3e20b8c18a42a0/src/OPCViewer.Base/KdTrees.fs#L307).
39+
- the OPC command-line tool. see [here](./OpcTool.md).

docs/OpcTool.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,26 @@ Das Tool "opc-tool" (Version 4.20.0-prerelease1) wurde erfolgreich installiert.
2121
* generates KdTrees.
2222
2323
opc-tool 4.10.0.0
24-
PRo3D contributors.
24+
PRo3D.Space contributors
2525
26-
--verbose Prints all messages to standard output.
26+
--verbose Prints all messages to standard output.
2727
28-
--forcekdtreerebuild Forces rebuild and overwrites existing KdTrees
28+
--forcekdtreerebuild Forces rebuild and overwrites existing kd-trees
2929
30-
--generatedds Generate DDS
30+
--ignoremasterkdtree Ignores master kd-trees and load or creates per-patch kd-trees as well as the lazy
31+
kd-tree cache
3132
32-
--overwritedds Overwrite DDS
33+
--generatedds Generate DDS
3334
34-
--help Display this help screen.
35+
--skippatchvalidation Skip patch validation (textures, aara files)
3536
36-
--version Display version information.
37+
--overwritedds Overwrite DDS
3738
38-
value pos. 0 Surface Directory
39+
--help Display this help screen.
40+
41+
--version Display version information.
42+
43+
value pos. 0 Surface Directory
3944
```
4045

4146
For example:

docs/images/createKdTree.png

278 KB
Loading

docs/images/masterKdTree.png

9.85 KB
Loading

docs/images/patchKdTrees.png

22.4 KB
Loading

paket.dependencies

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ nuget Aardvark.GPGPU ~> 5.4.0
3434
nuget Aardvark.Geometry.Intersection ~> 5.2.25
3535
nuget Aardvark.Geometry.PointTree ~> 5.2.25
3636
nuget Aardvark.Geometry.PolyMesh ~> 5.2.25
37+
nuget Aardvark.Geometry.Clustering ~> 5.2.25
3738

3839
nuget Aardvark.Service ~> 5.4.0
3940
nuget Aardvark.UI ~> 5.4.0
@@ -49,7 +50,7 @@ nuget Aardvark.GeoSpatial.Opc ~> 5.10.8
4950

5051
nuget Aardium ~> 2.0.10-prerelease0007
5152

52-
nuget OPCViewer.Base ~> 1.3.0
53+
nuget OPCViewer.Base ~> 1.5.2
5354

5455
nuget Uncodium.Eigensystems ~> 1.1.2
5556
nuget Chiron ~> 6.3.1

0 commit comments

Comments
 (0)