38 #ifndef FCL_HIERARCHY_TREE_H
39 #define FCL_HIERARCHY_TREE_H
62 using S =
typename BV::S;
70 HierarchyTree(
int bu_threshold_ = 16,
int topdown_level_ = 0);
75 void init(std::vector<NodeType*>& leaves,
int level = 0);
78 NodeType* insert(
const BV& bv,
void* data);
100 void update(
NodeType* leaf,
int lookahead_level = -1);
103 bool update(
NodeType* leaf,
const BV& bv);
112 size_t getMaxHeight()
const;
115 size_t getMaxDepth()
const;
118 void balanceBottomup();
121 void balanceTopdown();
124 void balanceIncremental(
int iterations);
130 void extractLeaves(
const NodeType* root, std::vector<NodeType*>& leaves)
const;
141 void print(
NodeType* root,
int depth);
157 void bottomup(
const NodeVecIterator lbeg,
const NodeVecIterator lend);
160 NodeType* topdown(
const NodeVecIterator lbeg,
const NodeVecIterator lend);
163 size_t getMaxHeight(NodeType* node)
const;
166 void getMaxDepth(NodeType* node,
size_t depth,
size_t& max_depth)
const;
171 NodeType* topdown_0(
const NodeVecIterator lbeg,
const NodeVecIterator lend);
177 NodeType* topdown_1(
const NodeVecIterator lbeg,
const NodeVecIterator lend);
180 void init_0(std::vector<NodeType*>& leaves);
184 void init_1(std::vector<NodeType*>& leaves);
188 void init_2(std::vector<NodeType*>& leaves);
191 void init_3(std::vector<NodeType*>& leaves);
193 NodeType* mortonRecurse_0(
const NodeVecIterator lbeg,
const NodeVecIterator lend,
const uint32& split,
int bits);
195 NodeType* mortonRecurse_1(
const NodeVecIterator lbeg,
const NodeVecIterator lend,
const uint32& split,
int bits);
197 NodeType* mortonRecurse_2(
const NodeVecIterator lbeg,
const NodeVecIterator lend);
200 void update_(NodeType* leaf,
const BV& bv);
203 NodeType* sort(NodeType* n, NodeType*&
r);
211 void insertLeaf(NodeType*
const sub_root, NodeType*
const leaf);
220 NodeType* removeLeaf(NodeType*
const leaf);
223 void fetchLeaves(NodeType* root, std::vector<NodeType*>& leaves,
int depth = -1);
225 static size_t indexOf(NodeType* node);
228 NodeType* createNode(NodeType* parent,
232 NodeType* createNode(NodeType* parent,
237 NodeType* createNode(NodeType* parent,
240 void deleteNode(NodeType* node);
242 void recurseDeleteNode(NodeType* node);
244 void recurseRefit(NodeType* node);
267 template<
typename BV>
272 template<
typename BV>
280 template<
typename BV>