// Copyright 2023, University of Freiburg, // Chair of Algorithms and Data Structures. // Author: Patrick Brosi // _____________________________________________________________________________ template class G, typename T> void RTree::add(G geom, V val) { Box box = getBoundingBox(geom); T minCoords[2]; T maxCoords[2]; minCoords[0] = box.getLowerLeft().getX(); minCoords[1] = box.getLowerLeft().getY(); maxCoords[0] = box.getUpperRight().getX(); maxCoords[1] = box.getUpperRight().getY(); if (_valIdx.count(val)) assert(false); _valIdx[val] = box; _rtree->Insert(minCoords, maxCoords, val); } // _____________________________________________________________________________ template class G, typename T> bool RTree::searchCb(V val, void* s) { static_cast*>(s)->insert(val); return true; } // _____________________________________________________________________________ template class G, typename T> void RTree::get(const Box& box, std::set* s) const { T minCoords[2]; T maxCoords[2]; minCoords[0] = box.getLowerLeft().getX(); minCoords[1] = box.getLowerLeft().getY(); maxCoords[0] = box.getUpperRight().getX(); maxCoords[1] = box.getUpperRight().getY(); std::function f = [s](const V& val) { s->insert(val); return true; }; _rtree->Search(minCoords, maxCoords, f); } // _____________________________________________________________________________ template class G, typename T> void RTree::get(const Box& box, std::vector* s) const { T minCoords[2]; T maxCoords[2]; minCoords[0] = box.getLowerLeft().getX(); minCoords[1] = box.getLowerLeft().getY(); maxCoords[0] = box.getUpperRight().getX(); maxCoords[1] = box.getUpperRight().getY(); std::function f = [s](const V& val) { s->push_back(val); return true; }; _rtree->Search(minCoords, maxCoords, f); } // _____________________________________________________________________________ template class G, typename T> void RTree::remove(V val) { auto bit = _valIdx.find(val); if (bit == _valIdx.end()) return; Box box = bit->second; T minCoords[2]; T maxCoords[2]; minCoords[0] = box.getLowerLeft().getX(); minCoords[1] = box.getLowerLeft().getY(); maxCoords[0] = box.getUpperRight().getX(); maxCoords[1] = box.getUpperRight().getY(); _valIdx.erase(bit); bool notFound = _rtree->Remove(minCoords, maxCoords, val); assert(!notFound); } // _____________________________________________________________________________ template class G, typename T> template