Commit b42c00c9 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

#14. Finished testing of 4 edge group case.

parent 82f7edc5
Pipeline #11529 passed with stages
in 4 minutes and 34 seconds
......@@ -128,6 +128,8 @@ std::vector<std::pair<int, int>> MarchingSquares<data_type>::march(
mData[i] = wash_bit;
}
}
//
// TODO: Simply polygon being returned with Ramer-Douglas-Peuker algorithm
return out;
} // march
......
......@@ -141,25 +141,110 @@ TEST(MarchingSquares, 4EdgeGroups)
{
std::vector<std::pair<int, int>> contour = ms.march(2., 0., 3.);
ms.dump_component_map(std::cout);
std::cout << "{" << std::endl;
for (size_t i = 0; i < contour.size(); ++i)
// ms.dump_component_map(std::cout);
// std::cout << "{" << std::endl;
// for (size_t i = 0; i < contour.size(); ++i)
// {
// const auto& pixel = contour[i];
// std::cout << "{" << pixel.first << "," << pixel.second << "}";
// if (i != contour.size() - 1)
// {
// std::cout << ",";
// }
// std::cout << std::endl;
// }
// std::cout << "}" << std::endl;
std::vector<std::pair<int, int>> blessed{
{2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {8, 1},
{8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {2, 1}};
ASSERT_EQ(blessed.size(), contour.size());
for (size_t i = 0; i < blessed.size(); ++i)
{
EXPECT_EQ(blessed[i], contour[i]);
}
// Expect there to be no more contours between 2 and 3
EXPECT_EQ(0, ms.march(2., 0., 3.).size());
}
{
std::vector<std::pair<int, int>> contour = ms.march(3., 0., 4.);
// ms.dump_component_map(std::cout);
// std::cout << "{" << std::endl;
// for (size_t i = 0; i < contour.size(); ++i)
// {
// const auto& pixel = contour[i];
// std::cout << "{" << pixel.first << "," << pixel.second << "}";
// if (i != contour.size() - 1)
// {
// std::cout << ",";
// }
// std::cout << std::endl;
// }
// std::cout << "}" << std::endl;
std::vector<std::pair<int, int>> blessed{{6, 6}, {7, 6}, {8, 6}, {9, 6},
{9, 5}, {9, 4}, {9, 3}, {9, 8},
{8, 8}, {7, 8}, {6, 8}, {6, 7}};
ASSERT_EQ(blessed.size(), contour.size());
for (size_t i = 0; i < blessed.size(); ++i)
{
const auto& pixel = contour[i];
std::cout << "{" << pixel.first << "," << pixel.second << "}";
if (i != contour.size() - 1)
{
std::cout << ",";
}
std::cout << std::endl;
EXPECT_EQ(blessed[i], contour[i]);
}
std::cout << "}" << std::endl;
std::vector<std::pair<int, int>> blessed;
// Expect there to be no more contours between 3 and 4
EXPECT_EQ(0, ms.march(3., 0., 4.).size());
}
{
std::vector<std::pair<int, int>> contour = ms.march(4., 0., 5.);
// ms.dump_component_map(std::cout);
// std::cout << "{" << std::endl;
// for (size_t i = 0; i < contour.size(); ++i)
// {
// const auto& pixel = contour[i];
// std::cout << "{" << pixel.first << "," << pixel.second << "}";
// if (i != contour.size() - 1)
// {
// std::cout << ",";
// }
// std::cout << std::endl;
// }
// std::cout << "}" << std::endl;
std::vector<std::pair<int, int>> blessed{
{4, 18}, {5, 18}, {5, 17}, {6, 17}, {7, 17}, {8, 17}, {8, 18},
{9, 18}, {9, 19}, {8, 19}, {7, 19}, {6, 19}, {4, 19}};
ASSERT_EQ(blessed.size(), contour.size());
for (size_t i = 0; i < blessed.size(); ++i)
{
EXPECT_EQ(blessed[i], contour[i]);
}
// Expect there to be no more contours between 4 and 5
EXPECT_EQ(0, ms.march(4., 0., 5.).size());
}
{
std::vector<std::pair<int, int>> contour = ms.march(5.);
// ms.dump_component_map(std::cout);
// std::cout << "{" << std::endl;
// for (size_t i = 0; i < contour.size(); ++i)
// {
// const auto& pixel = contour[i];
// std::cout << "{" << pixel.first << "," << pixel.second << "}";
// if (i != contour.size() - 1)
// {
// std::cout << ",";
// }
// std::cout << std::endl;
// }
// std::cout << "}" << std::endl;
std::vector<std::pair<int, int>> blessed{{0, 14}, {1, 14}, {2, 14}, {2, 15},
{2, 16}, {2, 17}, {1, 17}, {0, 17},
{0, 16}, {0, 15}};
// ASSERT_EQ(blessed.size(), contour.size());
ASSERT_EQ(blessed.size(), contour.size());
for (size_t i = 0; i < blessed.size(); ++i)
{
EXPECT_EQ(blessed[i], contour[i]);
}
// Expect there to be no more contours greater than 5
EXPECT_EQ(0, ms.march(5.).size());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment