| 146 | } |
| 147 | |
| 148 | void search(const geom2d::rect<CTYPE>& rArea, std::list<pT>& listItems) const |
| 149 | { |
| 150 | // First, check for items belonging to this area, add them to the list |
| 151 | // if there is overlap |
| 152 | for (const auto& p : m_pItems) |
| 153 | { |
| 154 | if (geom2d::overlaps(rArea,p.first)) |
| 155 | listItems.push_back(p.second); |
| 156 | } |
| 157 | |
| 158 | // Second, recurse through children and see if they can |
| 159 | // add to the list |
| 160 | for (int i = 0; i < 4; i++) |
| 161 | { |
| 162 | if (m_pChild[i]) |
| 163 | { |
| 164 | // If child is entirely contained within area, recursively |
| 165 | // add all of its children, no need to check boundaries |
| 166 | if (geom2d::contains(rArea,m_rChild[i])) |
| 167 | m_pChild[i]->items(listItems); |
| 168 | |
| 169 | // If child overlaps with search area then checks need |
| 170 | // to be made |
| 171 | else if (geom2d::overlaps(m_rChild[i],rArea)) |
| 172 | m_pChild[i]->search(rArea, listItems); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | |
| 177 | } |
| 178 | |
| 179 | void items(std::list<pT>& listItems) const |
| 180 | { |