diff --git a/3party/kdtree++/kdtree.hpp b/3party/kdtree++/kdtree.hpp index 6d6c77c77e..1324756b71 100644 --- a/3party/kdtree++/kdtree.hpp +++ b/3party/kdtree++/kdtree.hpp @@ -110,8 +110,13 @@ namespace KDTree typedef _Node_compare<_Val, _Acc, _Cmp> _Node_compare_; public: - typedef _Region<__K, _Val, typename _Acc::result_type, _Acc, _Cmp> - _Region_; + typedef _Region<__K, _Val, typename _Acc::result_type, _Acc, _Cmp> _Region_; + + template struct dim_region_type + { + typedef _Region<__Dim, _Val, typename _Acc::result_type, _Acc, _Cmp> type; + }; + typedef _Val value_type; typedef value_type* pointer; typedef value_type const* const_pointer; @@ -462,9 +467,9 @@ namespace KDTree } } - template + template void - visit_within_range(_Region_ const& REGION, Visitor visitor) const + visit_within_range(TRegion const & REGION, Visitor visitor) const { if (_M_get_root()) _M_visit_within_range(visitor, _M_get_root(), REGION, REGION, 0); @@ -954,11 +959,11 @@ namespace KDTree } - template + template void _M_visit_within_range(Visitor visitor, - _Link_const_type N, _Region_ const& REGION, - _Region_ const& BOUNDS, + _Link_const_type N, TRegion const & REGION, + TRegion const & BOUNDS, size_type const L) const { // replace 'encloses' check with direct call @@ -966,7 +971,7 @@ namespace KDTree if (_S_left(N)) { - _Region_ bounds(BOUNDS); + TRegion bounds(BOUNDS); bounds.set_high_bound(_S_value(N), L); if (REGION.intersects_with(bounds)) _M_visit_within_range(visitor, _S_left(N), @@ -974,7 +979,7 @@ namespace KDTree } if (_S_right(N)) { - _Region_ bounds(BOUNDS); + TRegion bounds(BOUNDS); bounds.set_low_bound(_S_value(N), L); if (REGION.intersects_with(bounds)) _M_visit_within_range(visitor, _S_right(N), diff --git a/geometry/geometry_tests/tree_test.cpp b/geometry/geometry_tests/tree_test.cpp index 5c5df71dab..5dbd79f3c8 100644 --- a/geometry/geometry_tests/tree_test.cpp +++ b/geometry/geometry_tests/tree_test.cpp @@ -58,12 +58,18 @@ UNIT_TEST(Tree4D_DrawTexts) for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) { + size_t const count = theTree.GetSize(); + theTree.ReplaceIf(arr[i], arr[i], &compare_false); + TEST_EQUAL ( theTree.GetSize(), count + 1, () ); + theTree.ReplaceIf(arr1[i], arr1[i], &compare_false); + TEST_EQUAL ( theTree.GetSize(), count + 1, () ); } vector test; theTree.ForEach(MakeBackInsertFunctor(test)); + TEST_EQUAL(4, test.size(), ()); for (int i = 0; i < test.size(); ++i) TEST_EQUAL(test[i], arr[i], ()); diff --git a/geometry/tree4d.hpp b/geometry/tree4d.hpp index b8401ab9e4..079d2e45d3 100644 --- a/geometry/tree4d.hpp +++ b/geometry/tree4d.hpp @@ -38,7 +38,7 @@ namespace m4 }; typedef KDTree::KDTree<4, value_t> tree_t; - typedef typename tree_t::_Region_ region_t; + typedef typename tree_t::dim_region_type<2>::type region_t; tree_t m_tree; typedef vector store_vec_t; @@ -67,19 +67,10 @@ namespace m4 void ReplaceIf(T const & obj, m2::RectD const & rect, TCompare comp) { region_t rgn; - for (size_t i = 0; i < 4; ++i) - { - if (i % 2 == 0) - { - rgn._M_low_bounds[i] = rect.minX(); - rgn._M_high_bounds[i] = rect.maxX(); - } - else - { - rgn._M_low_bounds[i] = rect.minY(); - rgn._M_high_bounds[i] = rect.maxY(); - } - } + rgn._M_low_bounds[0] = rect.minX(); + rgn._M_high_bounds[0] = rect.maxX(); + rgn._M_low_bounds[1] = rect.minY(); + rgn._M_high_bounds[1] = rect.maxY(); store_vec_t isect; @@ -108,6 +99,8 @@ namespace m4 toDo((*i).m_val); } + size_t GetSize() const { return m_tree.size(); } + void Clear() { m_tree.clear(); } }; } diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index aefdd19964..88c79575ce 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -550,7 +550,7 @@ namespace void DoDraw(shared_ptr p) { int startSize = 20; - int sizesCount = 4; + int sizesCount = 20; int startY = 30; for (size_t i = 0; i < sizesCount; ++i)