TTK
Loading...
Searching...
No Matches
Octree.h
Go to the documentation of this file.
1
20
21#pragma once
22
23#include <Triangulation.h>
24#include <cassert>
25#include <iostream>
26#include <stack>
27#include <unordered_map>
28#include <vector>
29
31public:
33 locCode_ = 0;
34 childExists_ = 0;
35 }
36 OctreeNode(uint32_t location) {
37 locCode_ = location;
38 childExists_ = 0;
39 }
40
41 ~OctreeNode() = default;
42
43protected:
44 uint32_t locCode_;
45 uint8_t childExists_;
46 std::vector<ttk::SimplexId> vertexIds_;
47 std::vector<ttk::SimplexId> cellIds_;
48
49 friend class Octree;
50};
51
52class Octree : public virtual ttk::Debug {
53public:
55 Octree(const ttk::AbstractTriangulation *t, const int k);
56 ~Octree() override;
57 void initialize(const ttk::AbstractTriangulation *t, const int k);
58
59 bool empty();
60
61 size_t getNodeTreeDepth(const OctreeNode *node);
62
64
65 void visitAll(const OctreeNode *node);
66
67 int verifyTree(ttk::SimplexId &vertexNum);
68
69 int insertVertex(ttk::SimplexId &vertexId);
70
71 int insertCell(ttk::SimplexId &cellId);
72
73 void reindex(std::vector<ttk::SimplexId> &vertices,
74 std::vector<ttk::SimplexId> &nodes,
75 std::vector<ttk::SimplexId> &cells);
76
77private:
78 const ttk::AbstractTriangulation *triangulation_;
79 std::unordered_map<uint32_t, OctreeNode> allNodes_;
80 int capacity_;
81 std::array<float, 3> center_{}, size_{};
82
87 inline OctreeNode *lookupNode(uint32_t locCode) {
88 const auto iter = allNodes_.find(locCode);
89 return (iter == allNodes_.end() ? nullptr : &(iter->second));
90 }
91
96 void computeCenterSize(uint32_t location,
97 std::array<float, 3> &centerArr,
98 std::array<float, 3> &sizeArr);
99
103 uint32_t getChildLocation(uint32_t parLoc,
104 ttk::SimplexId vertexId,
105 const std::array<float, 3> &centerArr);
106
111 void subdivide(OctreeNode *node);
112};
uint32_t locCode_
Definition Octree.h:44
std::vector< ttk::SimplexId > cellIds_
Definition Octree.h:47
std::vector< ttk::SimplexId > vertexIds_
Definition Octree.h:46
uint8_t childExists_
Definition Octree.h:45
OctreeNode(uint32_t location)
Definition Octree.h:36
~OctreeNode()=default
OctreeNode()
Definition Octree.h:32
Implementation of the point region (PR) octree.
Definition Octree.h:52
bool empty()
Definition Octree.cpp:48
size_t getNodeTreeDepth(const OctreeNode *node)
Definition Octree.cpp:60
~Octree() override
void visitAll(const OctreeNode *node)
Definition Octree.cpp:80
int insertVertex(ttk::SimplexId &vertexId)
Definition Octree.cpp:123
void initialize(const ttk::AbstractTriangulation *t, const int k)
Definition Octree.cpp:17
int insertCell(ttk::SimplexId &cellId)
Definition Octree.cpp:158
void reindex(std::vector< ttk::SimplexId > &vertices, std::vector< ttk::SimplexId > &nodes, std::vector< ttk::SimplexId > &cells)
Definition Octree.cpp:197
OctreeNode * getParentNode(OctreeNode *node)
Definition Octree.cpp:71
int verifyTree(ttk::SimplexId &vertexNum)
Definition Octree.cpp:96
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
Minimalist debugging class.
Definition Debug.h:88
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22