DGtal
1.4.0
Loading...
Searching...
No Matches
testDigitalMetricAdapter.cpp
Go to the documentation of this file.
1
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtal/helpers/StdDefs.h"
35
#include "DGtal/geometry/volumes/distance/CDigitalMetricSpace.h"
36
#include "DGtal/geometry/volumes/distance/DigitalMetricAdapter.h"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
43
// Functions for testing class DigitalMetricAdapter.
45
49
bool
testConcepts
()
50
{
51
unsigned
int
nbok = 0;
52
unsigned
int
nb = 0;
53
54
typedef
Z2i::L2Metric
L2;
55
L2 l2;
56
typedef
DigitalMetricAdapter<L2>
Adapted;
57
58
Adapted adapted(l2);
59
60
BOOST_CONCEPT_ASSERT((
concepts::CDigitalMetricSpace<Adapted>
));
61
62
return
nbok == nb;
63
}
67
bool
testVal
()
68
{
69
unsigned
int
nbok = 0;
70
unsigned
int
nb = 0;
71
72
typedef
Z2i::L2Metric
L2;
73
L2 l2;
74
typedef
DigitalMetricAdapter<L2>
Adapted;
75
Adapted adapted(l2);
76
77
BOOST_CONCEPT_ASSERT((
concepts::CDigitalMetricSpace<Adapted>
));
78
79
L2::Point a(0,0), b(5,2);
80
81
Adapted::Value d = adapted(a,b);
82
trace
.
info
() <<
"distance= "
<< l2(a,b)<<
" and adapted= "
<< d << std::endl;
83
nbok += (d == 6) ? 1 : 0;
84
nb++;
85
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
86
<< std::endl;
87
return
nbok == nb;
88
}
89
91
// Standard services - public :
92
93
int
main
(
int
argc,
char
** argv )
94
{
95
trace
.
beginBlock
(
"Testing class DigitalMetricAdapter"
);
96
trace
.
info
() <<
"Args:"
;
97
for
(
int
i = 0; i < argc; ++i )
98
trace
.
info
() <<
" "
<< argv[ i ];
99
trace
.
info
() << endl;
100
101
bool
res =
testConcepts
() &&
testVal
();
// && ... other tests
102
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
103
trace
.
endBlock
();
104
return
res ? 0 : 1;
105
}
106
// //
DGtal::DigitalMetricAdapter
Aim: simple adapter class which adapts any models of concepts::CMetricSpace to a model of concepts::C...
Definition
DigitalMetricAdapter.h:72
DGtal::ExactPredicateLpSeparableMetric
Aim: implements separable l_p metrics with exact predicates.
Definition
ExactPredicateLpSeparableMetric.h:88
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
Definition
Common.h:153
std
STL namespace.
DGtal::concepts::CDigitalMetricSpace
Aim: defines the concept of digital metric spaces.
Definition
CDigitalMetricSpace.h:99
main
int main()
Definition
testBits.cpp:56
testConcepts
bool testConcepts()
Definition
testDigitalMetricAdapter.cpp:49
testVal
bool testVal()
Definition
testDigitalMetricAdapter.cpp:67
tests
geometry
volumes
distance
testDigitalMetricAdapter.cpp
Generated on Mon Jun 10 2024 17:36:11 for DGtal by
1.11.0