Correct merge for SimplifyPoints

This commit is contained in:
Alex Zolotarev 2011-01-19 02:07:56 +02:00 committed by Alex Zolotarev
parent 73ce9b6b17
commit c10441aa9b
2 changed files with 13 additions and 38 deletions

View file

@ -72,43 +72,8 @@ namespace
namespace feature
{
typedef vector<m2::PointD> points_t;
/*
void SimplifyPoints(points_t const & in, points_t & out, int level)
{
if (in.size() >= 2)
{
typedef mn::DistanceToLineSquare<m2::PointD> DistanceF;
double const eps = my::sq(scales::GetEpsilonForSimplify(level));
SimplifyNearOptimal<DistanceF>(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 (!is_equal(out.back(), in.back()))
out.push_back(in.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, ());
}
#endif
}
}
*/
void TesselateInterior(points_t const & bound, list<points_t> const & holes, points_t & triangles);
class FeaturesCollector2 : public FeaturesCollector
{
FilesContainerW m_writer;

View file

@ -32,9 +32,11 @@ namespace feature
{
if (in.size() >= 2)
{
SimplifyNearOptimal<mn::DistanceToLineSquare<typename PointsContainerT::value_type> >(
20, in.begin(), in.end()-1, my::sq(scales::GetEpsilonForSimplify(level)),
MakeBackInsertFunctor(out));
typedef mn::DistanceToLineSquare<m2::PointD> DistanceF;
double const eps = my::sq(scales::GetEpsilonForSimplify(level));
SimplifyNearOptimal<DistanceF>(20, in.begin(), in.end()-1,
eps, MakeBackInsertFunctor(out));
switch (out.size())
{
@ -48,6 +50,14 @@ namespace feature
if (!are_points_equal(out.back(), in.back()))
out.push_back(in.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, ());
}
#endif
}
}
}