#include <visp3/core/vpPolygon.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpRect.h>
#if defined(VISP_HAVE_CATCH2)
#include <catch_amalgamated.hpp>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Check polygon construction")
{
SECTION("From vpRect")
{
const vpRect rect { 0, 0, 200, 400 };
const std::vector<vpImagePoint> rect_corners { rect.
getTopLeft(), rect.getTopRight(), rect.getBottomRight(),
rect.getBottomLeft() };
#if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)))
for (const auto &poly_corner : poly.getCorners()) {
REQUIRE(std::find(cbegin(rect_corners), cend(rect_corners), poly_corner) != cend(rect_corners));
}
#else
for (const auto &poly_corner : poly.getCorners()) {
REQUIRE(std::find(begin(rect_corners), end(rect_corners), poly_corner) != end(rect_corners));
}
#endif
}
}
int main(int argc, char *argv[])
{
Catch::Session session;
session.applyCommandLine(argc, argv);
int numFailed = session.run();
return numFailed;
}
#else
int main()
{
return EXIT_SUCCESS;
}
#endif
Defines a generic 2D polygon.
vpPolygon & buildFrom(const std::vector< vpImagePoint > &corners, const bool &create_convex_hull=false)
Defines a rectangle in the plane.
vpImagePoint getTopLeft() const