You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ What is Morton-Z space-filling curve? https://en.wikipedia.org/wiki/Z-order_curv
12
12
* Adaptable to any existing geometric system
13
13
* Adaptable to the original container of geometrical entities
14
14
* Arbitrary number of dimensions for other scientific usages
15
-
*Support of `std::execution` policies (so it is parallelizable)
15
+
*Parallelization is available (via `std::execution` policies)
16
16
* Edit functions to Insert/Update/Erase entities
17
17
* Wide range of search functions
18
18
* Range search
@@ -35,7 +35,8 @@ What is Morton-Z space-filling curve? https://en.wikipedia.org/wiki/Z-order_curv
35
35
36
36
## Usage
37
37
* Use `AdaptorBasicsConcept` or `AdaptorConcept` to adapt the actual geometric system. It is not a necessary step, basic point/vector and bounding box objects are available.
38
-
* Use the static member function `Create()` for a container (`std::unordered_map` or any `std::span` compatible) of Points or Bounding boxes to build the tree. It supports `std::execution` policies (e.g.: `std::execution::parallel_unsequenced_policy`) which can be effectively used to parallelize the creation process. (Template argument of the `Create()` functions)
38
+
* Decide to let the geometry management for octree or not. `Container` types could manage the geometries life-cycle, meanwhile the `non-container` types are just update the relevant metadata about the changes.
39
+
* Use `PAR_EXEC` tag as first parameter of constructor for parallel execution
39
40
* Use `PickSearch()` / `RangeSearch()` member functions to collect the wanted id-s
40
41
* Use `PlaneSearch()` / `PlaneIntersection()` / `PlanePositiveSegmentation()` member functions for hyperplane related searches
41
42
* Use `FrustumCulling()` to get entities in the multi-plane-bounded space/frustum
@@ -55,9 +56,9 @@ What is Morton-Z space-filling curve? https://en.wikipedia.org/wiki/Z-order_curv
55
56
* Naming
56
57
* Container types have "C" postfix (e.g.: core `OctreeBox`'s container is `OctreeBoxC`).
57
58
*`Map` named aliases are declared for `std::unordered_map` geometry containers (e.g.: `QuadtreeBoxMap`, `OctreeBoxMap`, `OctreeBoxMapC`). Non-`Map` named aliases uses `std::span`, which is compatible with `std::vector`, `std::array` or any contigous container.
58
-
*`s` means adjustable `SPLIT_DEPTH_INCREASEMENT` for box-types.
59
+
*`s` means adjustable `DO_SPLIT_PARENT_ENTITIES` for box-types.
59
60
* If `int` is preferred for indexing instead of `std::size_t`, declare `#define ORTHOTREE_INDEX_T__INT`.
60
-
* Bounding box-based solution stores item id in the parent node if it is not fit into any child node. Using `SPLIT_DEPTH_INCREASEMENT` template parameter, these boxes can be splitted then placed on the deeper level of the tree. The `SPLIT_DEPTH_INCREASEMENT` default is 2 and this split method is applied by default.
61
+
* Bounding box-based solution stores item id in the parent node if it is not fit into any child node. Using `DO_SPLIT_PARENT_ENTITIES` template parameter, these boxes can be splitted and placed on the first child level of the node. The `DO_SPLIT_PARENT_ENTITIES` default is `true`, it is applied by default.
61
62
* Edit functions are available but not recommended to fully build the tree with them.
62
63
* If less element is collected in a node than the max element then the child node won't be created.
63
64
* The underlying container is a hash-table (`std::unordered_map`) under 16D, which only stores the id-s and the bounding box of the child nodes.
@@ -67,8 +68,8 @@ What is Morton-Z space-filling curve? https://en.wikipedia.org/wiki/Z-order_curv
67
68
## Recommendations
68
69
* If the geometrical entities are already available, build the tree using the Constructor or Create, rather than entity-wise Insertions. This can result in a significant performance gain.
69
70
* For tree building, `InsertWithRebalancing()` offers much better performance than Insert() with leaf-node settings.
70
-
* If the box tree is used only for collision detection, set `SPLIT_DEPTH_INCREASEMENT = 0` (`OctreeBox` uses 2 by default). Both creation and collision detection will be significantly faster.
71
-
* For `Pick`/`Range`/`Ray`/`Plane` related search, the default `SPLIT_DEPTH_INCREASEMENT = 2` is recommended.
71
+
* If the box tree is used only for collision detection, set `DO_SPLIT_PARENT_ENTITIES = false` (`OctreeBox` uses `true` by default). Both creation and collision detection will be significantly faster.
72
+
* For `Pick`/`Range`/`Ray`/`Plane` related search, the default `DO_SPLIT_PARENT_ENTITIES = true` is recommended.
72
73
* If the overall modeling space size changes dynamically, this tool cannot be applied directly. However, you can combine it with sparse grid-based spatial partitioning, where each cell contains an `Orthotree`.
73
74
* After calling `Init()`, the max depth cannot be changed, and the tree cannot be deepened further.
74
75
* See the **BENCHMARKS** page for performance-related graphs.
@@ -139,17 +140,17 @@ The following defines can be used before the header file include:
139
140
using QuadtreePointC = TreePointContainerND<2, BaseGeometryType>;
140
141
141
142
// Quadtree for bounding boxes
142
-
template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
143
-
using QuadtreeBoxCs = TreeBoxContainerND<2, SPLIT_DEPTH_INCREASEMENT, BaseGeometryType>;
144
-
using QuadtreeBoxC = TreeBoxContainerND<2, 2, BaseGeometryType>;
143
+
template<bool DO_SPLIT_PARENT_ENTITIES = true>
144
+
using QuadtreeBoxCs = TreeBoxContainerND<2, DO_SPLIT_PARENT_ENTITIES, BaseGeometryType>;
145
+
using QuadtreeBoxC = TreeBoxContainerND<2, true, BaseGeometryType>;
145
146
146
147
// Octree for points
147
148
using OctreePointC = TreePointContainerND<3, BaseGeometryType>;
148
149
149
150
// Octree for bounding boxes
150
-
template<uint32_t SPLIT_DEPTH_INCREASEMENT = 2>
151
-
using OctreeBoxCs = TreeBoxContainerND<3, 2, BaseGeometryType>;
152
-
using OctreeBoxC = TreeBoxContainerND<3, 2, BaseGeometryType>;
151
+
template<bool DO_SPLIT_PARENT_ENTITIES = true>
152
+
using OctreeBoxCs = TreeBoxContainerND<3, DO_SPLIT_PARENT_ENTITIES, BaseGeometryType>;
153
+
using OctreeBoxC = TreeBoxContainerND<3, true, BaseGeometryType>;
153
154
```
154
155
155
156
## Basic examples
@@ -216,11 +217,11 @@ Usage of Container types
216
217
/* and more... */
217
218
};
218
219
219
-
auto octreeUsingCtor = OctreeBoxC(boxes
220
+
auto octreeUsingCtor = OctreeBoxC(PAR_EXEC
221
+
, boxes
220
222
, 3
221
223
, std::nullopt
222
224
, OctreeBox::DEFAULT_MAX_ELEMENT
223
-
, true // Set std::execution::parallel_unsequenced_policy
224
225
);
225
226
226
227
auto octreeUsingCreate = OctreeBoxC::Create<true>(boxes, 3);
@@ -378,7 +379,7 @@ using QuadtreeBoxCustom = OrthoTree::OrthoTreeBoundingBox<
0 commit comments