DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testBinomialConvolver.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/kernel/PointVector.h"
34
#include "DGtal/geometry/curves/BinomialConvolver.h"
35
#include "DGtal/geometry/curves/estimation/CCurveLocalGeometricEstimator.h"
37
38
using namespace
std
;
39
using namespace
DGtal
;
40
42
// Functions for testing class Signal.
44
48
bool
testBinomialConvolver
()
49
{
50
trace
.
beginBlock
(
"Testing block ..."
);
51
typedef
PointVector<2, double>
RealPoint
;
52
std::vector< RealPoint > points;
53
points.push_back(
RealPoint
( { 0.0, 0.0 } ) );
54
points.push_back(
RealPoint
( { 1.0, 0.0 } ) );
55
points.push_back(
RealPoint
( { 2.0, 0.0 } ) );
56
points.push_back(
RealPoint
( { 2.0, 1.0 } ) );
57
points.push_back(
RealPoint
( { 2.0, 2.0 } ) );
58
points.push_back(
RealPoint
( { 1.0, 2.0 } ) );
59
points.push_back(
RealPoint
( { 0.0, 2.0 } ) );
60
points.push_back(
RealPoint
( { 0.0, 1.0 } ) );
61
62
typedef
std::vector< RealPoint >::const_iterator ConstIteratorOnPoints;
63
typedef
BinomialConvolver<ConstIteratorOnPoints, double>
MyBinomialConvolver;
64
65
for
(
unsigned
int
n = 1; n < 10; ++n )
66
{
67
trace
.
info
() <<
"Binomial convolver n="
<< n << std::endl;
68
MyBinomialConvolver bcc( n );
69
bcc.init( 1.0, points.begin(), points.end(),
true
);
70
for
(
unsigned
int
i = 0; i < 8; ++i )
71
std::cout << i
72
<<
" "
<< bcc.x( i ).first
73
<<
" "
<< bcc.x( i ).second
74
<<
" "
<< bcc.tangent( i ).first
75
<<
" "
<< bcc.tangent( i ).second
76
<<
" "
<< bcc.curvature( i )
77
<< std::endl;
78
}
79
unsigned
int
n = MyBinomialConvolver::suggestedSize( 1.0, points.begin(), points.end() );
80
trace
.
info
() <<
"Binomial convolver suggested n="
81
<< n
82
<< std::endl;
83
84
typedef
TangentFromBinomialConvolverFunctor< MyBinomialConvolver, RealPoint >
85
TangentBCFct;
86
typedef
CurvatureFromBinomialConvolverFunctor< MyBinomialConvolver, double >
87
CurvatureBCFct;
88
typedef
BinomialConvolverEstimator< MyBinomialConvolver, TangentBCFct>
BCTangentEstimator;
89
typedef
BinomialConvolverEstimator< MyBinomialConvolver, CurvatureBCFct>
BCCurvatureEstimator;
90
BOOST_CONCEPT_ASSERT((
concepts::CCurveLocalGeometricEstimator< BCTangentEstimator >
));
91
BOOST_CONCEPT_ASSERT((
concepts::CCurveLocalGeometricEstimator< BCCurvatureEstimator >
));
92
BCTangentEstimator tgtEstimator;
93
BCCurvatureEstimator curvEstimator;
94
95
tgtEstimator.init( 1.0, points.begin(), points.end(),
true
);
96
curvEstimator.init( 1.0, points.begin(), points.end(),
true
);
97
for
( ConstIteratorOnPoints it = points.begin(), it_end = points.end();
98
it != it_end; ++it )
99
{
100
std::cout << *it
101
<<
" "
<< tgtEstimator.eval( it )
102
<<
" "
<< curvEstimator.eval( it )
103
<< std::endl;
104
}
105
trace
.
endBlock
();
106
107
return
true
;
108
}
109
111
// Standard services - public :
112
113
int
main
(
int
argc,
char
** argv )
114
{
115
trace
.
beginBlock
(
"Testing class BinomialConvolver"
);
116
trace
.
info
() <<
"Args:"
;
117
for
(
int
i = 0; i < argc; ++i )
118
trace
.
info
() <<
" "
<< argv[ i ];
119
trace
.
info
() << endl;
120
121
bool
res =
testBinomialConvolver
();
// && ... other tests
122
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
123
trace
.
endBlock
();
124
return
res ? 0 : 1;
125
}
126
// //
DGtal::BinomialConvolverEstimator
Aim: This class encapsulates a BinomialConvolver and a functor on BinomialConvolver so as to be a mod...
Definition
BinomialConvolver.h:325
DGtal::BinomialConvolver
Aim: This class represents a 2D contour convolved by some binomial. It computes first and second orde...
Definition
BinomialConvolver.h:74
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
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
std
STL namespace.
DGtal::CurvatureFromBinomialConvolverFunctor
Aim: This class is a functor for getting the curvature of a binomial convolver.
Definition
BinomialConvolver.h:292
DGtal::TangentFromBinomialConvolverFunctor
Aim: This class is a functor for getting the tangent vector of a binomial convolver.
Definition
BinomialConvolver.h:260
DGtal::concepts::CCurveLocalGeometricEstimator
Aim: This concept describes an object that can process a range so as to return one estimated quantity...
Definition
CCurveLocalGeometricEstimator.h:99
testBinomialConvolver
bool testBinomialConvolver()
Definition
testBinomialConvolver.cpp:48
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
RealPoint
PointVector< 3, double > RealPoint
Definition
testTriangulatedSurface.cpp:51
tests
geometry
curves
testBinomialConvolver.cpp
Generated on
for DGtal by
1.18.0