API Documentation
Loading...
Searching...
No Matches
Tree.hpp
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Tree
28File: Tree
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/TreeIterator.h>
34#include <NDEVR/Node.h>
35#include <NDEVR/BaseValues.h>
36#include <NDEVR/Buffer.h>
37#include <NDEVR/Bounds.h>
38#include <NDEVR/ProgressInfo.h>
39#include <NDEVR/Vector.h>
40#include <NDEVR/VectorFunctions.h>
41#include <NDEVR/Intersection.h>
42#include <NDEVR/BinaryHeap.h>
43
44
45namespace NDEVR
46{
48 {
49
50 };
51
52 template<class t_node_type, class t_type, uint01 t_node_child_size>
53 class TreeBase : public TreeObject
54 {
55 static_assert(std::is_base_of<TreeNode, t_node_type>::value, "t_node_type must inherit from Node");
56 protected:
57 explicit TreeBase(uint04 bucket_size)
58 : m_indices(bucket_size)
59 , m_nodes(1, t_node_type(0))
60 , m_bucket_size(bucket_size)
61 {
62 m_indices.addSpace<false>(bucket_size);
63 }
72 : m_indices()
73 , m_nodes()
77 {
78 std::swap(m_indices, tree.m_indices);
79 std::swap(m_nodes, tree.m_nodes);
80 std::swap(m_available_node_positions, tree.m_available_node_positions);
81 std::swap(m_available_indexed_positions, tree.m_available_indexed_positions);
82 }
83 TreeBase(const Buffer<t_node_type>& nodes, const Buffer<uint04>& indices, bool is_read_only)
85 , m_nodes(nodes)
88 {
89 UNUSED(is_read_only);
90 }
91 virtual ~TreeBase(){}
92 public:
93 uint04 getIndex(uint04 index) const { return m_indices[index]; }
94 void clear()
95 {
98 m_nodes.clear();
99 m_nodes.add(t_node_type(0));
102 }
103
105 {
106 return m_nodes.size();
107 }
108 const t_node_type& getNode(uint04 node_id) const
109 {
110 return m_nodes[node_id];
111 }
112
113 void removeIndices(const Buffer<bool>& deletion_indices)
114 {
115 Buffer<uint04> new_indices(deletion_indices.size());
116 uint04 index = 0;
117 for (uint04 i = 0; i < deletion_indices.size(); i++)
118 {
119 new_indices.add(index);
120 if (!deletion_indices[i])
121 index++;
122 }
123 TreeIterator iterator(root_node);
124 while (iterator.valid())
125 {
126 uint04 node_index = iterator.get();
127 t_node_type& node = m_nodes[node_index];
128 iterator.pop();
129 if (node.isLeaf())
130 {
131 const uint04 end = node.end();
132 for (uint04 i = node.begin(); i < end; i++)
133 {
134 lib_assert(!deletion_indices[m_indices[i]], "Must Call remove values prior to removeIndices");
135 m_indices[i] = new_indices[m_indices[i]];
136 }
137 }
138 else
139 {
140 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
141 }
142 }
143 }
144
145 void removeIndices(uint04 begin, uint04 end)
146 {
147 uint04 size = end - begin;
148 TreeIterator iterator(root_node);
149 while (iterator.valid())
150 {
151 uint04 node_index = iterator.get();
152 t_node_type& node = m_nodes[node_index];
153 iterator.pop();
154 if (node.isLeaf())
155 {
156 const uint04 node_end = node.end();
157 for (uint04 i = node.begin(); i < node_end; i++)
158 {
159 lib_assert(end <= m_indices[i] || begin > m_indices[i], "Must Call remove values prior to removeIndices");
160 if (m_indices[i] >= end)
161 m_indices[i] -= size;
162 }
163 }
164 else
165 {
166 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
167 }
168 }
169 }
170
171
172 void addIndices(const Buffer<bool>& insertion_indices)
173 {
174 Buffer<uint04> index_mapping(m_indices.size());
175 uint04 index = 0;
176 for (uint04 i = 0; i < insertion_indices.size(); i++)
177 {
178 if (!insertion_indices[i])
179 index_mapping.add(index);
180 index++;
181 }
182 lib_assert(index_mapping.size() == m_indices.size(), "Unexpected Insertion Structure");
183 TreeIterator iterator(root_node);
184 while (iterator.valid())
185 {
186 uint04 node_index = iterator.get();
187 t_node_type& node = m_nodes[node_index];
188 iterator.pop();
189 if (node.isLeaf())
190 {
191 const uint04 end = node.end();
192 for (uint04 i = node.begin(); i < end; i++)
193 {
194 m_indices[i] = index_mapping[m_indices[i]];
195 }
196 }
197 else
198 {
199 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
200 }
201 }
202 }
203
204 void addIndices(uint04 begin, uint04 end)
205 {
206 uint04 size = end - begin;
207 TreeIterator iterator(root_node);
208 while (iterator.valid())
209 {
210 uint04 node_index = iterator.get();
211 t_node_type& node = m_nodes[node_index];
212 iterator.pop();
213 if (node.isLeaf())
214 {
215 const uint04 node_end = node.end();
216 for (uint04 i = node.begin(); i < node_end; i++)
217 {
218 if (m_indices[i] > end)
219 m_indices[i] += size;
220 }
221 }
222 else
223 {
224 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
225 }
226 }
227 }
228
229 uint04 size() const
230 {
231 return m_nodes[root_node].size();;
232 }
233
234 void removeIndex(uint04 index) const
235 {
236 TreeIterator iterator(root_node);
237 while (iterator.valid())
238 {
239 const t_node_type& node = m_nodes[iterator.get()];
240 iterator.pop();
241 if (node.isLeaf())
242 {
243 uint04 end = node.end();
244 for (uint04 i = node.begin(); i < end; i++)
245 {
246 if (m_indices[index] > index)
247 --index;
248 lib_assert(index != m_indices[index], "Must Call remove value prior to removeIndex");
249 }
250 }
251 else
252 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
253 }
254 }
255
256 template<uint01 t_dims, class t_buffer_type>
257 Bounds<t_dims, t_type> _getBounds(const Buffer<uint04>& indices, const t_buffer_type& elements, uint04 start, uint04 end)
258 {
260 for (uint04 i = start; i < end; i++)
261 {
262 bounds.addToBoundingBox(elements[indices[i]]);
263 }
264 return bounds;
265 }
266
267 void addIndex(uint04 index) const
268 {
269 TreeIterator iterator(index);
270 while (iterator.valid())
271 {
272 const t_node_type& node = m_nodes[iterator.get()];
273 iterator.pop();
274 if (node.isLeaf())
275 {
276 uint04 end = node.end();
277 for (uint04 i = node.begin(); i < end; i++)
278 {
279 if (m_indices[index] >= index)
280 ++index;
281 }
282 }
283 else
284 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
285 }
286 }
287 const Buffer<uint04>& indices() const
288 {
289 return m_indices;
290 }
291 template<class t_buffer_type>
292 void sortVertices(const t_buffer_type& elements, t_buffer_type& sorted) const
293 {
294 sorted.setSize(indexSize());
295 for (uint04 i = 0; i < m_indices.size(); ++i)
296 {
297 if (m_indices[i] < elements.size())
298 sorted[i] = elements[m_indices[i]];
299 }
300 }
301 public:
302 //Operators
303 //-------------------
304 inline TreeBase& operator=(const TreeBase& value)
305 {
306 m_indices = value.m_indices;//setting equal to ourselves
307 m_nodes = value.m_nodes;
310 return (*this);
311 }
312 inline TreeBase& operator=(TreeBase&& value)
313 {
314 std::swap(m_indices, value.m_indices);//setting equal to ourselves
315 std::swap(m_nodes, value.m_nodes);
316 std::swap(m_available_node_positions, value.m_available_node_positions);
317 std::swap(m_available_indexed_positions, value.m_available_indexed_positions);
318 return (*this);
319 }
320 protected:
321 template<bool t_use_values>
323 {
324 uint04 index_count = index_values.count(true);
325 Buffer<uint04> indices(t_use_values ? index_count : index_values.size() - index_count);
326 for (uint04 i = 0; i < index_values.size(); i++)
327 if (t_use_values == index_values[i])
328 indices.add(i);
329 return indices;
330 }
331 template<class t_buffer_type>
332 Buffer<uint04> prepareAddAll(uint04 start_index, uint04 end_index, const t_buffer_type& elements)
333 {
334 Buffer<uint04> indices(end_index - start_index);
335 for (uint04 i = start_index; i < end_index; i++)
336 {
337 if(!isNaN(elements[i]))
338 indices.add(i);
339 }
340 return indices;
341 }
342
347
349 {
350 return m_available_node_positions.size() * t_node_child_size;
351 }
352
354 {
355 uint04 child_node_index;
357 {
358 child_node_index = m_nodes.size();
359 m_nodes.add(t_node_type(m_nodes[index].begin()));
360 for (uint04 i = 0; i < t_node_child_size - 1; ++i)
361 {
363 {
364 m_nodes.add(t_node_type(m_indices.size()));
366 }
367 else
368 {
369 m_nodes.add(t_node_type(m_available_indexed_positions.last()));
371 }
372 }
373 }
374 else
375 {
376 child_node_index = m_available_node_positions.last();
378
379 m_nodes[child_node_index + 0].clear(m_nodes[index].begin());
380 for (uint04 i = 1; i < t_node_child_size; ++i)
381 {
383 {
384 m_nodes[child_node_index + i].clear(m_indices.size());
386 }
387 else
388 {
389 m_nodes[child_node_index + i].clear(m_available_indexed_positions.last());
391 }
392 }
393 }
394 m_nodes[index].setChildNodeStart(child_node_index);
395 }
396
398 {
399 if (!m_nodes[index].isLeaf())
400 {
401 TreeIterator iterator(index);
402 while (iterator.valid())
403 {
404 uint04 i = iterator.get();
405 iterator.pop();
406 if (m_nodes[i].isLeaf())
407 {
408 lib_assert(!m_available_indexed_positions.contains(m_nodes[i].begin()), "Bad contains");
410 }
411 else
412 {
413 m_available_node_positions.add(m_nodes[i].childNodeStart());
414 iterator.addAndGoToIndex(m_nodes[i].left(), m_nodes[i].right());
415 }
416 }
417 m_nodes[index].setBegin(m_available_indexed_positions.last());
419 }
420 }
421
422 template<bool t_set_true>
423 void _getAllT(const uint04& node_index, Buffer<bool>& indices) const
424 {
425 TreeIterator iterator(node_index);
426 while (iterator.valid())
427 {
428 const t_node_type& node = m_nodes[iterator.get()];
429 iterator.pop();
430 if (node.isLeaf())
431 {
432 const uint04 end = node.end();
433 for (uint04 i = node.begin(); i < end; i++)
434 {
435 indices[m_indices[i]] = t_set_true;
436 }
437 }
438 else
439 {
440 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
441 }
442 }
443 }
444 template<bool t_is_presorted>
445 void _getAll(const uint04& node_index, Buffer<uint04>& indices) const
446 {
447 TreeIterator iterator(node_index);
448 while (iterator.valid())
449 {
450 const t_node_type& node = m_nodes[iterator.get()];
451 iterator.pop();
452 if (node.isLeaf())
453 {
454 if constexpr (!t_is_presorted)
455 {
456 indices.addAll(m_indices.begin(node.begin()), node.size());
457 }
458 else
459 {
460 const uint04 end = node.begin() + node.size();
461 for(uint04 i = node.begin(); i < end; i++)
462 indices.add(i);
463 }
464 }
465 else
466 iterator.addAndGoToIndices(node.childNodeStart(), t_node_child_size);
467 }
468 }
469 public:
471 {
472 return m_indices.size();
473 }
475 {
476 return m_nodes.size();
477 }
478 protected:
483 static const uint04 root_node = 0;
485 };
486
487 template<uint01 t_dims, class t_type, class t_child_tree>
488 class Tree : public t_child_tree
489 {
490 protected:
491 explicit Tree(uint04 bucket_size)
492 : t_child_tree(bucket_size)
493 {}
494 Tree(const t_child_tree& tree)
495 : t_child_tree(tree)
496 {}
497 Tree(t_child_tree&& tree)
498 : t_child_tree(std::move(tree))
499 {}
500 public:
501 void getAll(Buffer<bool>& indices) const
502 {
503 t_child_tree::template _getAllT<true>(t_child_tree::root_node, indices);
504 }
505
506 void getAll(Buffer<uint04>& indices) const
507 {
508 t_child_tree::template _getAll<false>(t_child_tree::root_node, indices);
509 }
510 template<class t_reference_type, class t_buffer_type>
511 uint04 closestElement(const t_reference_type& point, const t_buffer_type& elements, t_type epsilon = cast<t_type>(0)) const
512 {
513 t_type max_distance = Constant<t_type>::Max;
514 return closestElement(point, elements, max_distance, epsilon);
515 }
516 template<class t_reference_type, class t_buffer_type>
517 uint04 closestElement(const t_reference_type& point, const t_buffer_type& elements, t_type& max_distance_squared, t_type epsilon = cast<t_type>(0)) const
518 {
520 t_child_tree::template _getClosestElement<false>(t_child_tree::root_node, point, elements, max_distance_squared, epsilon, index);
521 return index;
522 }
523 template<class t_reference_type, class t_buffer_type>
524 uint04 closestElementPresorted(const t_reference_type& point, const t_buffer_type& elements, t_type epsilon = cast<t_type>(0)) const
525 {
526 t_type max_distance = Constant<t_type>::Max;
527 return closestElementPresorted(point, elements, max_distance, epsilon);
528 }
529 template<class t_reference_type, class t_buffer_type>
530 uint04 closestElementPresorted(const t_reference_type& point, const t_buffer_type& elements, t_type& max_distance_squared, t_type epsilon = cast<t_type>(0)) const
531 {
533 t_child_tree::template _getClosestElement<true>(t_child_tree::root_node, point, elements, max_distance_squared, epsilon, index);
534 return index;
535 }
536 template<class t_area_type, class t_buffer_type>
537 void enclosedElements(const t_area_type& area, Buffer<uint04>& indices, const t_buffer_type& elements) const
538 {
539 t_child_tree::template _getEnclosedElements<false>(t_child_tree::root_node, area, indices, elements);
540 }
541 template<class t_area_type, class t_buffer_type>
542 void presortedEnclosedElements(const t_area_type& area, Buffer<uint04>& indices, const t_buffer_type& elements) const
543 {
544 t_child_tree::template _getEnclosedElements<true>(t_child_tree::root_node, area, indices, elements);
545 }
546
547
548 template<class t_area_type, class t_buffer_type>
549 void getChangedElements(const t_area_type& new_area, const t_area_type& old_area, Buffer<bool>& indices, const t_buffer_type& elements, bool allow_enable, bool allow_disable) const
550 {
551 t_child_tree::template _getChangedElements(t_child_tree::root_node, new_area, old_area, indices, elements, allow_enable, allow_disable);
552 }
553 template<class t_area_type, class t_buffer_type>
554 void enclosedElements(const t_area_type& area, Buffer<bool>& indices, const t_buffer_type& elements) const
555 {
556 t_child_tree::template _getEnclosedElements(t_child_tree::root_node, area, indices, elements);
557 }
558
559 template<class t_area_type, class t_buffer_type>
560 uint04 getNumberOfEnclosedElements(const t_area_type& area, const t_buffer_type& elements) const
561 {
562 return t_child_tree::template _getNumberOfEnclosedElements(t_child_tree::root_node, area, elements);
563 }
564
565 template<class t_reference_type, class t_buffer_type>
566 void closestElements(const t_reference_type& point, uint04 size, Buffer<uint04>& indices, const t_buffer_type& elements, t_type& max_distance, t_type epsilon = cast<t_type>(0)) const
567 {
568 if (size <= 1)
569 {
570 uint04 index = closestElement(point, elements, max_distance, epsilon);
571 if(!isNaN(index))
572 indices.add(index);
573 return;
574 }
575 MinHeap<t_type, uint04> heap(size + 1);
576 t_child_tree::template _getClosestElements<false>(t_child_tree::root_node, point, elements, max_distance, epsilon, heap, size);
577 indices.addAll(heap.sortedIndices());
578 }
579
580 template<class t_reference_type, class t_buffer_type>
581 void closestElements(const t_reference_type& point, uint04 size, MinHeap<t_type, uint04>& value_heap, const t_buffer_type& elements, t_type& max_distance, t_type epsilon = cast<t_type>(0)) const
582 {
583 t_child_tree::template _getClosestElements<false>(t_child_tree::root_node, point, elements, max_distance, epsilon, value_heap, size);
584 }
585 template<class t_reference_type, class t_buffer_type>
586 void presortedClosestElements(const t_reference_type& point, uint04 size, MinHeap<t_type, uint04>& value_heap, const t_buffer_type& elements, t_type& max_distance, t_type epsilon = cast<t_type>(0)) const
587 {
588 t_child_tree::template _getClosestElements<true>(t_child_tree::root_node, point, elements, max_distance, epsilon, value_heap, size);
589 }
590 void swapIndices(uint04 index_a, uint04 index_b)
591 {
592 t_child_tree::m_indices.swapAllElements(index_a, index_b);
593 }
594
595
596 template<bool t_has_nans, bool t_uses_boundary, class t_buffer_type>
597 void addValue(uint04 index, const t_buffer_type& elements, bool rebalance)
598 {
599 t_child_tree::template _addValue<t_has_nans, t_uses_boundary>(t_child_tree::root_node, index, elements, rebalance);
600 }
601
602 template<bool t_has_nans, bool t_uses_boundary, class t_buffer_type>
603 void addValues(const Buffer<bool>& insertion_indices, const t_buffer_type& elements, bool is_precise, ProgressInfo* progress = nullptr)
604 {
605 if (t_child_tree::useBulkResize(insertion_indices.count(true)))
606 {
607 t_child_tree::template _addValues<t_has_nans, t_uses_boundary>(t_child_tree::root_node, t_child_tree::template prepareAddAll<true>(insertion_indices), elements, is_precise, progress);
608 }
609 else
610 {
611 for (uint04 i = 0; i < elements.size(); i++)
612 {
613 if (insertion_indices[i])
615 }
616 }
617 }
618 template<bool t_has_nans, bool t_uses_boundary, class t_buffer_type>
619 void addValues(const t_buffer_type& elements, bool is_precise, ProgressInfo* progress = nullptr)
620 {
621 addValues<t_has_nans, t_uses_boundary>(0, elements.size(), elements, is_precise, progress);
622 }
623 template<bool t_has_nans, bool t_uses_boundary, class t_buffer_type>
624 void addValues(uint04 start_index, uint04 end_index, const t_buffer_type& elements, bool is_precise, ProgressInfo* progress = nullptr)
625 {
626 if (t_child_tree::useBulkResize(end_index - start_index))
627 {
628 t_child_tree::template _addValues<t_has_nans, t_uses_boundary>(t_child_tree::root_node, t_child_tree::template prepareAddAll(start_index, end_index, elements), elements, is_precise, progress);
629 }
630 else
631 {
632 for (uint04 i = start_index; i < end_index; i++)
633 {
634 if constexpr (t_has_nans)
635 {
636 if (isNaN(elements[i]))
637 continue;
638 }
639 addValue<t_has_nans, t_uses_boundary>(i, elements, is_precise);
640 }
641 }
642 };
643
644 template<bool t_has_nans, bool t_uses_boundary, class t_buffer_type>
645 void addValues(const Buffer<uint04>& indices, const t_buffer_type& elements, bool is_precise, ProgressInfo* progress = nullptr)
646 {
647 if (t_child_tree::useBulkResize(indices.size()))
648 {
649 t_child_tree::template _addValues<t_has_nans, t_uses_boundary>(t_child_tree::root_node, indices, elements, is_precise, progress);
650 }
651 else
652 {
653 for (uint04 i = 0; i < indices.size(); i++)
654 {
655 addValue<t_has_nans, t_uses_boundary>(indices[i], elements, is_precise);
656 }
657 }
658 }
659
660
661
662 template<class t_buffer_type>
663 void removeValue(uint04 index, const t_buffer_type& elements)
664 {
665 t_child_tree::template _removeValue(t_child_tree::root_node, index, elements);
666 }
667
668 template<class t_buffer_type>
669 void removeValues(const Buffer<bool>& insertion_indices, const t_buffer_type& elements, ProgressInfo* progress = nullptr)
670 {
671 if (t_child_tree::useBulkResize(insertion_indices.count(true)))
672 {
673 t_child_tree::template clear();
674 t_child_tree::template _addValues(t_child_tree::root_node, t_child_tree::template prepareAddAll<false>(insertion_indices), elements, progress);
675 }
676 else
677 {
678 for (uint04 i = 0; i < elements.size(); i++)
679 {
680 if (insertion_indices[i])
681 t_child_tree::template removeValue(i, elements);
682 }
683 }
684 }
685
686 template<class t_buffer_type>
687 void removeValues(uint04 start_index, uint04 end_index, const t_buffer_type& elements, ProgressInfo* progress = nullptr)
688 {
689 if (t_child_tree::template useBulkResize(end_index - start_index))
690 {
691 t_child_tree::template clear();
692 Buffer<uint04> indices(elements.size() - (end_index - start_index));
693 for (uint04 i = 0; i < start_index; i++)
694 indices.add(i);
695 for (uint04 i = end_index; i < elements.size(); i++)
696 indices.add(i);
697 t_child_tree::template _addValues(t_child_tree::root_node, indices, elements, progress);
698 }
699 else
700 {
701 for (uint04 i = start_index; i < end_index; i++)
702 {
703 removeValue(i, elements);
704 }
705 }
706 }
707
708
709 /*Tree getAsReadOnly() const
710 {
711 Buffer<uint04> indices(t_child_tree::size());
712 auto nodes = t_child_tree::m_nodes;
713 TreeIterator iterator(t_child_tree::root_node);
714 while (iterator.valid())
715 {
716 uint04 node_index = iterator.get();
717 iterator.pop();
718 if (nodes[node_index].isLeaf())
719 {
720 nodes[node_index].setBegin(indices.size());
721 indices.addAll(t_child_tree::m_indices.begin(t_child_tree::m_nodes[node_index].begin()), t_child_tree::m_nodes[node_index].size());
722 }
723 else
724 {
725 iterator.addAndGoToIndex(t_child_tree::m_nodes[node_index].left(), t_child_tree::m_nodes[node_index].right());
726 }
727
728 }
729 return Tree(nodes, indices, true);
730 }*/
731
732 virtual const char* getTreeType() const = 0;
733 };
734};
735
#define UNUSED(expr)
Definition BaseValues.hpp:433
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Definition BinaryHeap.hpp:39
Buffer< t_value_type > sortedIndices() const
Definition BinaryHeap.hpp:92
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
void addSpace(t_index_type space_to_add)
Definition Buffer.hpp:440
bool contains(const t_type &element) const
Definition Buffer.hpp:674
constexpr t_index_type size() const
Definition Buffer.hpp:1461
decltype(auto) last()
Definition Buffer.hpp:977
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:248
decltype(auto) begin()
Definition Buffer.hpp:504
void clear()
Definition Buffer.hpp:572
t_index_type count(const t_type &element) const
Definition Buffer.hpp:728
void removeLast()
Definition Buffer.hpp:1099
Definition ProgressInfo.hpp:43
Definition Tree.hpp:54
uint04 getNumberOfFreeIndices()
Definition Tree.hpp:343
uint04 m_bucket_size
Definition Tree.hpp:484
TreeBase & operator=(const TreeBase &value)
Definition Tree.hpp:304
Buffer< t_node_type, uint04, ObjectAllocator< true > > m_nodes
Definition Tree.hpp:480
void reclaimChildren(uint04 index)
Definition Tree.hpp:397
const Buffer< uint04 > & indices() const
Definition Tree.hpp:287
uint04 nodeSize() const
Definition Tree.hpp:474
void removeIndices(uint04 begin, uint04 end)
Definition Tree.hpp:145
Buffer< uint04 > prepareAddAll(const Buffer< bool > &index_values)
Definition Tree.hpp:322
Buffer< uint04 > m_available_node_positions
Definition Tree.hpp:481
void addIndices(const Buffer< bool > &insertion_indices)
Definition Tree.hpp:172
virtual ~TreeBase()
Definition Tree.hpp:91
void addIndices(uint04 begin, uint04 end)
Definition Tree.hpp:204
const t_node_type & getNode(uint04 node_id) const
Definition Tree.hpp:108
void _getAllT(const uint04 &node_index, Buffer< bool > &indices) const
Definition Tree.hpp:423
void _getAll(const uint04 &node_index, Buffer< uint04 > &indices) const
Definition Tree.hpp:445
uint04 getNumberOfNodes() const
Definition Tree.hpp:104
void removeIndex(uint04 index) const
Definition Tree.hpp:234
Bounds< t_dims, t_type > _getBounds(const Buffer< uint04 > &indices, const t_buffer_type &elements, uint04 start, uint04 end)
Definition Tree.hpp:257
TreeBase(const Buffer< t_node_type > &nodes, const Buffer< uint04 > &indices, bool is_read_only)
Definition Tree.hpp:83
void sortVertices(const t_buffer_type &elements, t_buffer_type &sorted) const
Definition Tree.hpp:292
uint04 size() const
Definition Tree.hpp:229
TreeBase(TreeBase &&tree)
Definition Tree.hpp:71
Buffer< uint04 > prepareAddAll(uint04 start_index, uint04 end_index, const t_buffer_type &elements)
Definition Tree.hpp:332
Buffer< uint04 > m_indices
Definition Tree.hpp:479
static const uint04 root_node
Definition Tree.hpp:483
uint04 indexSize() const
Definition Tree.hpp:470
TreeBase & operator=(TreeBase &&value)
Definition Tree.hpp:312
TreeBase(uint04 bucket_size)
Definition Tree.hpp:57
void splitLeafNode(uint04 index)
Definition Tree.hpp:353
void clear()
Definition Tree.hpp:94
void removeIndices(const Buffer< bool > &deletion_indices)
Definition Tree.hpp:113
void addIndex(uint04 index) const
Definition Tree.hpp:267
TreeBase(const TreeBase &tree)
Definition Tree.hpp:64
uint04 getIndex(uint04 index) const
Definition Tree.hpp:93
Buffer< uint04 > m_available_indexed_positions
Definition Tree.hpp:482
uint04 getNumberOfFreeNodes()
Definition Tree.hpp:348
Definition Tree.hpp:489
void addValues(const Buffer< bool > &insertion_indices, const t_buffer_type &elements, bool is_precise, ProgressInfo *progress=nullptr)
Definition Tree.hpp:603
void closestElements(const t_reference_type &point, uint04 size, MinHeap< t_type, uint04 > &value_heap, const t_buffer_type &elements, t_type &max_distance, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:581
void enclosedElements(const t_area_type &area, Buffer< bool > &indices, const t_buffer_type &elements) const
Definition Tree.hpp:554
void removeValues(uint04 start_index, uint04 end_index, const t_buffer_type &elements, ProgressInfo *progress=nullptr)
Definition Tree.hpp:687
void removeValues(const Buffer< bool > &insertion_indices, const t_buffer_type &elements, ProgressInfo *progress=nullptr)
Definition Tree.hpp:669
void enclosedElements(const t_area_type &area, Buffer< uint04 > &indices, const t_buffer_type &elements) const
Definition Tree.hpp:537
void presortedEnclosedElements(const t_area_type &area, Buffer< uint04 > &indices, const t_buffer_type &elements) const
Definition Tree.hpp:542
virtual const char * getTreeType() const =0
uint04 closestElementPresorted(const t_reference_type &point, const t_buffer_type &elements, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:524
void addValues(uint04 start_index, uint04 end_index, const t_buffer_type &elements, bool is_precise, ProgressInfo *progress=nullptr)
Definition Tree.hpp:624
void addValues(const Buffer< uint04 > &indices, const t_buffer_type &elements, bool is_precise, ProgressInfo *progress=nullptr)
Definition Tree.hpp:645
void presortedClosestElements(const t_reference_type &point, uint04 size, MinHeap< t_type, uint04 > &value_heap, const t_buffer_type &elements, t_type &max_distance, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:586
void addValue(uint04 index, const t_buffer_type &elements, bool rebalance)
Definition Tree.hpp:597
void addValues(const t_buffer_type &elements, bool is_precise, ProgressInfo *progress=nullptr)
Definition Tree.hpp:619
void getAll(Buffer< uint04 > &indices) const
Definition Tree.hpp:506
void getAll(Buffer< bool > &indices) const
Definition Tree.hpp:501
void removeValue(uint04 index, const t_buffer_type &elements)
Definition Tree.hpp:663
uint04 getNumberOfEnclosedElements(const t_area_type &area, const t_buffer_type &elements) const
Definition Tree.hpp:560
void getChangedElements(const t_area_type &new_area, const t_area_type &old_area, Buffer< bool > &indices, const t_buffer_type &elements, bool allow_enable, bool allow_disable) const
Definition Tree.hpp:549
uint04 closestElement(const t_reference_type &point, const t_buffer_type &elements, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:511
void swapIndices(uint04 index_a, uint04 index_b)
Definition Tree.hpp:590
Tree(const t_child_tree &tree)
Definition Tree.hpp:494
void closestElements(const t_reference_type &point, uint04 size, Buffer< uint04 > &indices, const t_buffer_type &elements, t_type &max_distance, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:566
Tree(uint04 bucket_size)
Definition Tree.hpp:491
Tree(t_child_tree &&tree)
Definition Tree.hpp:497
uint04 closestElementPresorted(const t_reference_type &point, const t_buffer_type &elements, t_type &max_distance_squared, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:530
uint04 closestElement(const t_reference_type &point, const t_buffer_type &elements, t_type &max_distance_squared, t_type epsilon=cast< t_type >(0)) const
Definition Tree.hpp:517
Definition TreeIterator.hpp:38
void pop()
Definition TreeIterator.hpp:53
bool valid() const
Definition TreeIterator.hpp:49
void addAndGoToIndices(uint04 start, uint04 size)
Definition TreeIterator.hpp:71
void addAndGoToIndex(uint04 index)
Definition TreeIterator.hpp:61
uint04 get() const
Definition TreeIterator.hpp:45
Definition Tree.hpp:48
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
Definition File.h:213
Definition BaseValues.hpp:272