diff --git a/indexer/indexer_tool/feature_sorter.cpp b/indexer/indexer_tool/feature_sorter.cpp index aaed963176..1191e85371 100644 --- a/indexer/indexer_tool/feature_sorter.cpp +++ b/indexer/indexer_tool/feature_sorter.cpp @@ -260,7 +260,10 @@ namespace feature ASSERT ( m_buffer.m_innerTrg.empty(), () ); if (!IsPolygonCCW(points.begin(), points.end())) + { reverse(points.begin(), points.end()); + ASSERT ( IsPolygonCCW(points.begin(), points.end()), (points) ); + } size_t const index = FindSingleStrip(count, IsDiagonalVisibleFunctor(points.begin(), points.end())); @@ -306,7 +309,7 @@ namespace feature if (isLine) holder.AddPoints(points, i); - if (isArea && points.size() > 2 && holder.NeedProcessTriangles()) + if (isArea && points.size() > 3 && holder.NeedProcessTriangles()) { // simplify and serialize triangles diff --git a/indexer/indexer_tool/feature_sorter.hpp b/indexer/indexer_tool/feature_sorter.hpp index 52f4ee478d..e89a243678 100644 --- a/indexer/indexer_tool/feature_sorter.hpp +++ b/indexer/indexer_tool/feature_sorter.hpp @@ -35,28 +35,33 @@ namespace feature typedef mn::DistanceToLineSquare DistanceF; double const eps = my::sq(scales::GetEpsilonForSimplify(level)); - SimplifyNearOptimal(20, in.begin(), in.end()-1, - eps, MakeBackInsertFunctor(out)); + //SimplifyNearOptimal(20, in.begin(), in.end()-1, eps, MakeBackInsertFunctor(out)); + //switch (out.size()) + //{ + //case 0: + // out.push_back(in.front()); + // // no break + //case 1: + // out.push_back(in.back()); + // break; + //default: + // if (!are_points_equal(out.back(), in.back())) + // out.push_back(in.back()); + //} - switch (out.size()) - { - case 0: - out.push_back(in.front()); - // no break - case 1: - out.push_back(in.back()); - break; - default: - if (!are_points_equal(out.back(), in.back())) - out.push_back(in.back()); - } + SimplifyDP(in.begin(), in.end(), eps, + AccumulateSkipSmallTrg(out, eps)); + + ASSERT_GREATER ( out.size(), 1, () ); + ASSERT ( are_points_equal(in.front(), out.front()), () ); + ASSERT ( are_points_equal(in.back(), out.back()), () ); #ifdef DEBUG - for (size_t i = 2; i < out.size(); ++i) - { - double const dist = DistanceF(out[i-2], out[i])(out[i-1]); - ASSERT_GREATER(dist, eps, ()); - } + //for (size_t i = 2; i < out.size(); ++i) + //{ + // double const dist = DistanceF(out[i-2], out[i])(out[i-1]); + // ASSERT ( dist >= eps, (dist, eps, in) ); + //} #endif } }