Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
catchPolygon2.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Test vpPolygon class.
32
*/
33
39
#include <visp3/core/vpPolygon.h>
40
41
// Core
42
#include <visp3/core/vpConfig.h>
43
#include <visp3/core/vpRect.h>
44
45
#if defined(VISP_HAVE_CATCH2)
46
47
#include <catch_amalgamated.hpp>
48
49
#ifdef ENABLE_VISP_NAMESPACE
50
using namespace
VISP_NAMESPACE_NAME
;
51
#endif
52
53
TEST_CASE(
"Check polygon construction"
)
54
{
55
SECTION(
"From vpRect"
)
56
{
57
const
vpRect
rect { 0, 0, 200, 400 };
58
const
std::vector<vpImagePoint> rect_corners { rect.
getTopLeft
(), rect.
getTopRight
(), rect.
getBottomRight
(),
59
rect.
getBottomLeft
() };
60
61
vpPolygon
poly {};
62
poly.
buildFrom
(rect_corners,
true
);
63
64
// Check if std:c++14 or higher
65
#if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)))
66
for
(
const
auto
&poly_corner : poly.
getCorners
()) {
67
REQUIRE(std::find(cbegin(rect_corners), cend(rect_corners), poly_corner) != cend(rect_corners));
68
}
69
#else
70
for
(
const
auto
&poly_corner : poly.
getCorners
()) {
71
REQUIRE(std::find(begin(rect_corners), end(rect_corners), poly_corner) != end(rect_corners));
72
}
73
#endif
74
}
75
}
76
77
int
main(
int
argc,
char
*argv[])
78
{
79
Catch::Session session;
80
session.applyCommandLine(argc, argv);
81
int
numFailed = session.run();
82
return
numFailed;
83
}
84
85
#else
86
87
int
main()
88
{
89
return
EXIT_SUCCESS;
90
}
91
#endif
vpPolygon
Defines a generic 2D polygon.
Definition
vpPolygon.h:103
vpPolygon::buildFrom
vpPolygon & buildFrom(const std::vector< vpImagePoint > &corners, const bool &create_convex_hull=false)
Definition
vpPolygon.cpp:195
vpPolygon::getCorners
const std::vector< vpImagePoint > & getCorners() const
Definition
vpPolygon.h:140
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
vpRect::getBottomLeft
vpImagePoint getBottomLeft() const
Definition
vpRect.h:104
vpRect::getTopLeft
vpImagePoint getTopLeft() const
Definition
vpRect.h:199
vpRect::getTopRight
vpImagePoint getTopRight() const
Definition
vpRect.h:212
vpRect::getBottomRight
vpImagePoint getBottomRight() const
Definition
vpRect.h:117
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
modules
core
test
tools
geometry
catchPolygon2.cpp
Generated by
1.17.0