#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpImagePoint.h>
#if defined(VISP_HAVE_CATCH2)
#include <catch_amalgamated.hpp>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Test comparison operator", "[operator]")
{
CHECK(ip1 == ip2);
CHECK_FALSE(ip1 != ip2);
CHECK_FALSE(ip1 == ip3);
CHECK(ip1 != ip3);
}
TEST_CASE("Test pixel belongs to segment", "[operator]")
{
SECTION("Segment horizontal right")
{
auto j = start_pixel.get_j();
for (auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), j++) {
if (curr_pixel == end_pixel)
break;
}
}
SECTION("Segment horizontal left")
{
auto j = start_pixel.get_j();
for (auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), j--) {
if (curr_pixel == end_pixel)
break;
}
}
SECTION("Segment vertical bottom")
{
auto i = start_pixel.get_i();
for (auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), i++) {
if (curr_pixel == end_pixel)
break;
}
}
SECTION("Segment vertical top")
{
auto i = start_pixel.get_i();
for (auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel);
curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel), i--) {
if (curr_pixel == end_pixel)
break;
}
}
}
int main(int argc, char *argv[])
{
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
std::cout << (numFailed ? "Test failed" : "Test succeed") << std::endl;
return numFailed;
}
#else
int main()
{
std::cout << "We define ip1 with coordinates: " << ip1 << std::endl;
std::cout << "We define ip2 with coordinates: " << ip2 << std::endl;
std::cout << "We define ip3 with coordinates: " << ip3 << std::endl;
if (ip1 == ip2) {
std::cout << "ip1 == ip2" << std::endl;
}
else {
std::cout << "ip1 != ip2 (bad result)" << std::endl;
return EXIT_FAILURE;
}
if (ip1 != ip2) {
std::cout << "ip1 != ip2 (bad result)" << std::endl;
return EXIT_FAILURE;
}
else {
std::cout << "ip1 == ip2" << std::endl;
}
if (ip1 == ip3) {
std::cout << "ip1 == ip3 (bad result)" << std::endl;
return EXIT_FAILURE;
}
else {
std::cout << "ip1 != ip3" << std::endl;
}
if (ip1 != ip3) {
std::cout << "ip1 != ip3" << std::endl;
}
else {
std::cout << "ip1 == ip3 (bad result)" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#endif
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...