Skip to content

Commit

Permalink
Join ForEachPoint and ForEachPointRef.
Browse files Browse the repository at this point in the history
Join ForEachTriangle and ForEachTriangleRef.
  • Loading branch information
Sergey Magidovich authored and syershov committed Mar 23, 2016
1 parent b7b0892 commit 54fa2ac
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 33 deletions.
6 changes: 3 additions & 3 deletions drape_frontend/rule_drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions drape_frontend/watch/feature_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion drape_frontend/watch/feature_styler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
26 changes: 7 additions & 19 deletions indexer/feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ class FeatureType : public FeatureBase

bool IsEmptyGeometry(int scale) const;

template <typename FunctorT>
void ForEachPointRef(FunctorT & f, int scale) const
template <typename TFunctor>
void ForEachPoint(TFunctor && f, int scale) const
{
ParseGeometry(scale);

Expand Down Expand Up @@ -225,14 +225,8 @@ class FeatureType : public FeatureBase
return m_points[i];
}

template <typename FunctorT>
void ForEachPoint(FunctorT f, int scale) const
{
ForEachPointRef(f, scale);
}

template <typename FunctorT>
void ForEachTriangleRef(FunctorT & f, int scale) const
template <typename TFunctor>
void ForEachTriangle(TFunctor && f, int scale) const
{
ParseTriangles(scale);

Expand All @@ -243,17 +237,11 @@ class FeatureType : public FeatureBase
}
}

template <typename FunctorT>
void ForEachTriangle(FunctorT f, int scale) const
{
ForEachTriangleRef(f, scale);
}

template <typename FunctorT>
void ForEachTriangleExRef(FunctorT & f, int scale) const
template <typename TFunctor>
void ForEachTriangleEx(TFunctor && f, int scale) const
{
f.StartPrimitive(m_triangles.size());
ForEachTriangleRef(f, scale);
ForEachTriangle(forward<TFunctor>(f), scale);
f.EndPrimitive();
}
//@}
Expand Down
4 changes: 2 additions & 2 deletions indexer/feature_algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ m2::PointD GetCenter(FeatureType const & f, int scale)
case GEOM_LINE:
{
CalculateLineCenter doCalc;
f.ForEachPointRef(doCalc, scale);
f.ForEachPoint(doCalc, scale);
return doCalc.GetCenter();
}

default:
{
ASSERT_EQUAL(type, GEOM_AREA, ());
CalculatePointOnSurface doCalc(f.GetLimitRect(scale));
f.ForEachTriangleRef(doCalc, scale);
f.ForEachTriangle(doCalc, scale);
return doCalc.GetCenter();
}
}
Expand Down
4 changes: 2 additions & 2 deletions indexer/feature_covering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ vector<int64_t> 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)));
Expand Down
4 changes: 2 additions & 2 deletions map/mwm_tests/mwm_foreach_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, () );
}
Expand Down

0 comments on commit 54fa2ac

Please sign in to comment.