Insert a region into this area
| 102 | |
| 103 | // Insert a region into this area |
| 104 | QuadTreeItemLocation<pT> insert(const pT item, const geom2d::rect<CTYPE>& itemsize) |
| 105 | { |
| 106 | for (int i = 0; i < 4; i++) |
| 107 | { |
| 108 | if (geom2d::contains(m_rChild[i], itemsize)) |
| 109 | { |
| 110 | // Have we reached depth limit? |
| 111 | if (m_depth + 1 < m_maxdepth) |
| 112 | { |
| 113 | // No, so does child exist? |
| 114 | if (!m_pChild[i]) |
| 115 | { |
| 116 | // No, so create it |
| 117 | m_pChild[i] = std::make_shared<DynamicQuadTree<pT>>(m_rChild[i], m_depth + 1, m_maxdepth); |
| 118 | } |
| 119 | |
| 120 | // Yes, so add item to it |
| 121 | return m_pChild[i]->insert(item, itemsize); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // It didnt fit, so item must belong to this geom2d::rect<CTYPE> |
| 127 | m_pItems.push_back({ itemsize, item }); |
| 128 | return { &m_pItems, std::prev(m_pItems.end()) }; |
| 129 | } |
| 130 | |
| 131 | void relocate(pT item, const geom2d::rect<CTYPE>& rArea) |
| 132 | { |
no test coverage detected