Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Melnichek <melnichek@gmail.com>2011-04-25 06:03:38 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:16:23 +0300
commit203254e7482b5758c4c2a86843c81713a5ab05b9 (patch)
treeacd67008f2f9ac12de331383e4d4f6ab2c910819 /geometry
parent1196862b8508e047a323c25613f383bf497f65fc (diff)
Use buffer_vector in geometry/covering.hpp.
Diffstat (limited to 'geometry')
-rw-r--r--geometry/covering.hpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/geometry/covering.hpp b/geometry/covering.hpp
index f7fd6869af..52c6551da9 100644
--- a/geometry/covering.hpp
+++ b/geometry/covering.hpp
@@ -2,11 +2,10 @@
#include "../geometry/point2d.hpp"
#include "../base/assert.hpp"
#include "../base/base.hpp"
+#include "../base/buffer_vector.hpp"
#include "../base/logging.hpp"
#include "../base/math.hpp"
#include "../std/algorithm.hpp"
-#include "../std/utility.hpp"
-#include "../std/vector.hpp"
namespace covering
{
@@ -60,9 +59,9 @@ CellObjectIntersection IntersectCellWithTriangle(
return i1;
}
-template <class CellIdT, typename IntersectF>
-void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, vector<CellIdT> & out,
- CellIdT cell = CellIdT::Root())
+template <class CellIdT, class CellIdContainerT, typename IntersectF>
+void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdContainerT & out,
+ CellIdT cell)
{
uint64_t const cellArea = my::sq(uint64_t(1 << (CellIdT::DEPTH_LEVELS - 1 - cell.Level())));
CellObjectIntersection const intersection = intersect(cell);
@@ -77,22 +76,21 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, vector<
return;
}
- vector<CellIdT> subdiv;
+ buffer_vector<CellIdT, 32> subdiv;
for (uint8_t i = 0; i < 4; ++i)
CoverObject(intersect, cellPenaltyArea, subdiv, cell.Child(i));
-
uint64_t subdivArea = 0;
for (size_t i = 0; i < subdiv.size(); ++i)
subdivArea += my::sq(uint64_t(1 << (CellIdT::DEPTH_LEVELS - 1 - subdiv[i].Level())));
ASSERT(!subdiv.empty(), (cellPenaltyArea, out, cell));
- if (subdiv.empty() ||
- cellPenaltyArea * (int(subdiv.size()) - 1) >= cellArea - subdivArea)
+ if (subdiv.empty() || cellPenaltyArea * (int(subdiv.size()) - 1) >= cellArea - subdivArea)
out.push_back(cell);
else
- out.insert(out.end(), subdiv.begin(), subdiv.end());
+ for (size_t i = 0; i < subdiv.size(); ++i)
+ out.push_back(subdiv[i]);
}