DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testConvexHull2DReverse.cpp
Go to the documentation of this file.
1
16
29
31
#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"
40
41
using namespace
std
;
42
using namespace
DGtal
;
43
45
// Functions for testing class ConvexHull2D
47
48
TEST_CASE
(
"Testing MelkmanConvexHull insertion from front and back using reverse()"
)
49
{
50
typedef
PointVector<2, double_t>
Point
;
51
typedef
InHalfPlaneBySimple3x3Matrix<Point, double>
Functor
;
52
DGtal::MelkmanConvexHull<Point, Functor>
ch
;
53
54
// sequence of points split from test testConvexHull2D_Thickness:
55
// using reverse() should produce the same convex hull.
56
57
ch
.add(
Point
(102.2, 50.2));
58
ch
.add(
Point
(101.0, 50.0));
59
ch
.add(
Point
(101.0, 49.1));
60
ch
.add(
Point
(101.2, 48.2));
61
ch
.add(
Point
(100.0, 48.2));
62
ch
.add(
Point
(100.4, 47.4));
63
ch
.reverse();
64
ch
.add(
Point
(102.2, 51.0));
65
ch
.add(
Point
(102.3, 52.3));
66
ch
.add(
Point
(103.3, 52.3));
67
ch
.add(
Point
(103.2, 53.4));
68
ch
.add(
Point
(104.2, 53.2));
69
ch
.add(
Point
(104.0, 54.2));
70
71
Point
pHV
,
qHV
,
sHV
,
pE
,
qE
,
sE
;
72
73
const
double
thicknessHV
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
74
DGtal::functions::Hull2D::HorizontalVerticalThickness
,
75
pHV
,
qHV
,
sHV
);
76
77
const
double
thicknessE
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
78
DGtal::functions::Hull2D::EuclideanThickness
,
79
pE
,
qE
,
sE
);
80
81
CAPTURE
(
thicknessHV
);
82
CAPTURE
(
thicknessE
);
83
84
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
85
{
86
REQUIRE
(
pHV
==
Point
(101.2, 48.2) );
87
REQUIRE
(
qHV
==
Point
(104.2, 53.2) );
88
REQUIRE
(
sHV
==
Point
(102.3, 52.3) );
89
}
90
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
91
{
92
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
93
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
94
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
95
}
96
ch
.reverse();
97
98
const
double
thicknessEb
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
99
DGtal::functions::Hull2D::EuclideanThickness
,
100
pE
,
qE
,
sE
);
101
102
CAPTURE
(
thicknessEb
);
103
104
SECTION
(
"Testing same antipodal points after hull reversing "
)
105
{
106
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
107
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
108
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
109
}
110
}
111
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition
InHalfPlaneBySimple3x3Matrix.h:92
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
DGtal::Point
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::functions::Hull2D::HorizontalVerticalThickness
@ HorizontalVerticalThickness
Definition
Hull2DHelpers.h:78
DGtal::functions::Hull2D::EuclideanThickness
@ EuclideanThickness
Definition
Hull2DHelpers.h:78
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
Functor
Definition
testFunctorHolder.cpp:45
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
thicknessEb
const double thicknessEb
Definition
testConvexHull2DReverse.cpp:98
pHV
Point pHV
Definition
testConvexHull2DReverse.cpp:71
qHV
Point qHV
Definition
testConvexHull2DReverse.cpp:71
qE
Point qE
Definition
testConvexHull2DReverse.cpp:71
ch
DGtal::MelkmanConvexHull< Point, Functor > ch
Definition
testConvexHull2DReverse.cpp:52
pE
Point pE
Definition
testConvexHull2DReverse.cpp:71
thicknessE
const double thicknessE
Definition
testConvexHull2DReverse.cpp:77
CAPTURE
CAPTURE(thicknessHV)
sE
Point sE
Definition
testConvexHull2DReverse.cpp:71
sHV
Point sHV
Definition
testConvexHull2DReverse.cpp:71
thicknessHV
const double thicknessHV
Definition
testConvexHull2DReverse.cpp:73
SECTION
SECTION("Testing constant forward iterators")
Definition
testSimpleRandomAccessRangeFromPoint.cpp:66
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
geometry
tools
testConvexHull2DReverse.cpp
Generated on
for DGtal by
1.18.0