DGtal
1.1.0
tests
geometry
tools
testConvexHull2DReverse.cpp
Go to the documentation of this file.
1
30
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtalCatch.h"
35
#include "DGtal/helpers/StdDefs.h"
36
#include "DGtal/geometry/tools/Hull2DHelpers.h"
37
#include "DGtal/geometry/tools/MelkmanConvexHull.h"
38
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
39
40
42
43
using namespace
std;
44
using namespace
DGtal
;
45
47
// Functions for testing class ConvexHull2D
49
50
TEST_CASE
(
"Testing MelkmanConvexHull insertion from front and back using reverse()"
)
51
{
52
typedef
PointVector<2, double_t>
Point
;
53
typedef
InHalfPlaneBySimple3x3Matrix<Point, double>
Functor
;
54
DGtal::MelkmanConvexHull<Point, Functor>
ch
;
55
56
// sequence of points splited from test testConvexHull2D_Thickness:
57
// using reverse() should produce the same convex hull.
58
59
ch
.add(
Point
(102.2, 50.2));
60
ch
.add(
Point
(101.0, 50.0));
61
ch
.add(
Point
(101.0, 49.1));
62
ch
.add(
Point
(101.2, 48.2));
63
ch
.add(
Point
(100.0, 48.2));
64
ch
.add(
Point
(100.4, 47.4));
65
ch
.reverse();
66
ch
.add(
Point
(102.2, 51.0));
67
ch
.add(
Point
(102.3, 52.3));
68
ch
.add(
Point
(103.3, 52.3));
69
ch
.add(
Point
(103.2, 53.4));
70
ch
.add(
Point
(104.2, 53.2));
71
ch
.add(
Point
(104.0, 54.2));
72
73
Point
pHV
,
qHV
,
sHV
,
pE
,
qE
,
sE
;
74
75
const
double
thicknessHV
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
76
DGtal::functions::Hull2D::HorizontalVerticalThickness
,
77
pHV
,
qHV
,
sHV
);
78
79
const
double
thicknessE
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
80
DGtal::functions::Hull2D::EuclideanThickness
,
81
pE
,
qE
,
sE
);
82
83
CAPTURE
(
thicknessHV
);
84
CAPTURE
(
thicknessE
);
85
86
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
87
{
88
REQUIRE
(
pHV
==
Point
(101.2, 48.2) );
89
REQUIRE
(
qHV
==
Point
(104.2, 53.2) );
90
REQUIRE
(
sHV
==
Point
(102.3, 52.3) );
91
}
92
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
93
{
94
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
95
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
96
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
97
}
98
ch
.reverse();
99
100
const
double
thicknessEb
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
101
DGtal::functions::Hull2D::EuclideanThickness
,
102
pE
,
qE
,
sE
);
103
104
CAPTURE
(
thicknessEb
);
105
106
SECTION
(
"Testing same antipodal points after hull reversing "
)
107
{
108
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
109
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
110
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
111
}
112
}
113
pE
Point pE
Definition:
testConvexHull2DReverse.cpp:73
thicknessE
const double thicknessE
Definition:
testConvexHull2DReverse.cpp:79
sE
Point sE
Definition:
testConvexHull2DReverse.cpp:73
ch
DGtal::MelkmanConvexHull< Point, Functor > ch
Definition:
testConvexHull2DReverse.cpp:54
Functor
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Definition:
testConvexHull2DReverse.cpp:51
REQUIRE
REQUIRE(domain.isInside(aPoint))
pHV
Point pHV
Definition:
testConvexHull2DReverse.cpp:73
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition:
testContainerTraits.cpp:53
CAPTURE
CAPTURE(thicknessHV)
qE
Point qE
Definition:
testConvexHull2DReverse.cpp:73
SECTION
SECTION("Testing antipodal points of ConvexHull2D")
Definition:
testConvexHull2DReverse.cpp:86
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition:
ClosedIntegerHalfPlane.h:49
DGtal::functions::Hull2D::computeHullThickness
double computeHullThickness(const ForwardIterator &itb, const ForwardIterator &ite, const ThicknessDefinition &def)
Procedure to compute the convex hull thickness given from different definitions (Horizontal/vertical ...
DGtal::InHalfPlaneBySimple3x3Matrix< Point, double >
qHV
Point qHV
Definition:
testConvexHull2DReverse.cpp:73
thicknessHV
const double thicknessHV
Definition:
testConvexHull2DReverse.cpp:75
DGtal::functions::Hull2D::HorizontalVerticalThickness
@ HorizontalVerticalThickness
Definition:
Hull2DHelpers.h:78
DGtal::functions::Hull2D::EuclideanThickness
@ EuclideanThickness
Definition:
Hull2DHelpers.h:78
DGtal::MelkmanConvexHull
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
Definition:
MelkmanConvexHull.h:90
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition:
PointVector.h:593
sHV
Point sHV
Definition:
testConvexHull2DReverse.cpp:73
thicknessEb
const double thicknessEb
Definition:
testConvexHull2DReverse.cpp:100
Point
MyPointD Point
Definition:
testClone2.cpp:383
Generated on Fri Oct 9 2020 08:58:17 for DGtal by
1.8.20