From 54fa2ac1c7fff965b1a504a265db719cc89aafff Mon Sep 17 00:00:00 2001 From: Sergey Magidovich Date: Sun, 7 Feb 2016 16:06:45 +0300 Subject: [PATCH] Join ForEachPoint and ForEachPointRef. Join ForEachTriangle and ForEachTriangleRef. --- drape_frontend/rule_drawer.cpp | 6 ++--- drape_frontend/watch/feature_processor.cpp | 8 +++---- drape_frontend/watch/feature_styler.cpp | 2 +- indexer/feature.hpp | 26 ++++++---------------- indexer/feature_algo.cpp | 4 ++-- indexer/feature_covering.cpp | 4 ++-- map/mwm_tests/mwm_foreach_test.cpp | 4 ++-- 7 files changed, 21 insertions(+), 33 deletions(-) diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 32f39ca139f79..e1bbd058d6e41 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -188,7 +188,7 @@ void RuleDrawer::operator()(FeatureType const & f) ApplyAreaFeature apply(insertShape, f.GetID(), areaMinHeight, areaHeight, minVisibleScale, f.GetRank(), s.GetCaptionDescription()); - f.ForEachTriangleRef(apply, zoomLevel); + f.ForEachTriangle(apply, zoomLevel); if (s.PointStyleExists()) apply(feature::GetCenter(f, zoomLevel)); @@ -205,7 +205,7 @@ void RuleDrawer::operator()(FeatureType const & f) s.GetCaptionDescription(), m_currentScaleGtoP, zoomLevel >= kLineSimplifyLevelStart && zoomLevel <= kLineSimplifyLevelEnd, f.GetPointsCount()); - f.ForEachPointRef(apply, zoomLevel); + f.ForEachPoint(apply, zoomLevel); if (CheckCancelled()) return; @@ -218,7 +218,7 @@ void RuleDrawer::operator()(FeatureType const & f) { ASSERT(s.PointStyleExists(), ()); ApplyPointFeature apply(insertShape, f.GetID(), minVisibleScale, f.GetRank(), s.GetCaptionDescription(), 0.0f /* posZ */); - f.ForEachPointRef(apply, zoomLevel); + f.ForEachPoint(apply, zoomLevel); if (CheckCancelled()) return; diff --git a/drape_frontend/watch/feature_processor.cpp b/drape_frontend/watch/feature_processor.cpp index 9ab64e5c2607a..d8dc700e74c35 100644 --- a/drape_frontend/watch/feature_processor.cpp +++ b/drape_frontend/watch/feature_processor.cpp @@ -74,7 +74,7 @@ bool FeatureProcessor::operator()(FeatureType const & f) p.m_rect = &m_rect; functor_t fun(p); - f.ForEachPointRef(fun, m_zoom); + f.ForEachPoint(fun, m_zoom); if (fun.IsExist()) { isExist = true; @@ -93,7 +93,7 @@ bool FeatureProcessor::operator()(FeatureType const & f) p.m_rect = &m_rect; functor_t fun(p); - f.ForEachTriangleExRef(fun, m_zoom); + f.ForEachTriangleEx(fun, m_zoom); if (data.m_styler.m_hasPointStyles) fun.SetCenter(feature::GetCenter(f, m_zoom)); @@ -123,7 +123,7 @@ bool FeatureProcessor::operator()(FeatureType const & f) functor_t fun(p); - f.ForEachPointRef(fun, m_zoom); + f.ForEachPoint(fun, m_zoom); if (fun.IsExist()) { isExist = true; @@ -150,7 +150,7 @@ bool FeatureProcessor::operator()(FeatureType const & f) functor_t fun(p); - f.ForEachPointRef(fun, m_zoom); + f.ForEachPoint(fun, m_zoom); if (fun.IsExist()) { diff --git a/drape_frontend/watch/feature_styler.cpp b/drape_frontend/watch/feature_styler.cpp index d7b4d64e5786d..3976e19ea3c0e 100644 --- a/drape_frontend/watch/feature_styler.cpp +++ b/drape_frontend/watch/feature_styler.cpp @@ -241,7 +241,7 @@ FeatureStyler::FeatureStyler(FeatureType const & f, p.m_intervals = &m_intervals; functor_t fun(p); - f.ForEachPointRef(fun, zoom); + f.ForEachPoint(fun, zoom); LayoutTexts(fun.m_length); } diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 4f835947fd1f0..f6f7e84bbd796 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -195,8 +195,8 @@ class FeatureType : public FeatureBase bool IsEmptyGeometry(int scale) const; - template - void ForEachPointRef(FunctorT & f, int scale) const + template + void ForEachPoint(TFunctor && f, int scale) const { ParseGeometry(scale); @@ -225,14 +225,8 @@ class FeatureType : public FeatureBase return m_points[i]; } - template - void ForEachPoint(FunctorT f, int scale) const - { - ForEachPointRef(f, scale); - } - - template - void ForEachTriangleRef(FunctorT & f, int scale) const + template + void ForEachTriangle(TFunctor && f, int scale) const { ParseTriangles(scale); @@ -243,17 +237,11 @@ class FeatureType : public FeatureBase } } - template - void ForEachTriangle(FunctorT f, int scale) const - { - ForEachTriangleRef(f, scale); - } - - template - void ForEachTriangleExRef(FunctorT & f, int scale) const + template + void ForEachTriangleEx(TFunctor && f, int scale) const { f.StartPrimitive(m_triangles.size()); - ForEachTriangleRef(f, scale); + ForEachTriangle(forward(f), scale); f.EndPrimitive(); } //@} diff --git a/indexer/feature_algo.cpp b/indexer/feature_algo.cpp index 2c64a7ba81bb9..30c822b2d0a51 100644 --- a/indexer/feature_algo.cpp +++ b/indexer/feature_algo.cpp @@ -113,7 +113,7 @@ m2::PointD GetCenter(FeatureType const & f, int scale) case GEOM_LINE: { CalculateLineCenter doCalc; - f.ForEachPointRef(doCalc, scale); + f.ForEachPoint(doCalc, scale); return doCalc.GetCenter(); } @@ -121,7 +121,7 @@ m2::PointD GetCenter(FeatureType const & f, int scale) { ASSERT_EQUAL(type, GEOM_AREA, ()); CalculatePointOnSurface doCalc(f.GetLimitRect(scale)); - f.ForEachTriangleRef(doCalc, scale); + f.ForEachTriangle(doCalc, scale); return doCalc.GetCenter(); } } diff --git a/indexer/feature_covering.cpp b/indexer/feature_covering.cpp index 4503e1de88454..cac448f734837 100644 --- a/indexer/feature_covering.cpp +++ b/indexer/feature_covering.cpp @@ -126,8 +126,8 @@ vector CoverFeature(FeatureType const & f, int cellDepth, uint64_t cell int const scale = FeatureType::BEST_GEOMETRY; FeatureIntersector fIsect; - f.ForEachPointRef(fIsect, scale); - f.ForEachTriangleRef(fIsect, scale); + f.ForEachPoint(fIsect, scale); + f.ForEachTriangle(fIsect, scale); CHECK(!(fIsect.m_trg.empty() && fIsect.m_polyline.empty()) && f.GetLimitRect(scale).IsValid(), (f.DebugString(scale))); diff --git a/map/mwm_tests/mwm_foreach_test.cpp b/map/mwm_tests/mwm_foreach_test.cpp index b7ea80ada2f2c..27f558f69c731 100644 --- a/map/mwm_tests/mwm_foreach_test.cpp +++ b/map/mwm_tests/mwm_foreach_test.cpp @@ -152,8 +152,8 @@ class AccumulatorEtalon : public AccumulatorBase switch (f.GetFeatureType()) { case GEOM_POINT: check.TestPoint(f.GetCenter()); break; - case GEOM_LINE: f.ForEachPointRef(check, m_scale); break; - case GEOM_AREA: f.ForEachTriangleRef(check, m_scale); break; + case GEOM_LINE: f.ForEachPoint(check, m_scale); break; + case GEOM_AREA: f.ForEachTriangle(check, m_scale); break; default: CHECK ( false, () ); }