32 #include "DGtal/base/Common.h"
33 #include "DGtal/kernel/PointVector.h"
34 #include "DGtal/geometry/curves/BinomialConvolver.h"
38 using namespace DGtal;
47 bool testBinomialConvolver()
49 unsigned int nbok = 0;
54 std::vector< RealPoint > points;
55 #ifdef CPP11_INITIALIZER_LIST
56 points.push_back( RealPoint( { 0.0, 0.0 } ) );
57 points.push_back( RealPoint( { 1.0, 0.0 } ) );
58 points.push_back( RealPoint( { 2.0, 0.0 } ) );
59 points.push_back( RealPoint( { 2.0, 1.0 } ) );
60 points.push_back( RealPoint( { 2.0, 2.0 } ) );
61 points.push_back( RealPoint( { 1.0, 2.0 } ) );
62 points.push_back( RealPoint( { 0.0, 2.0 } ) );
63 points.push_back( RealPoint( { 0.0, 1.0 } ) );
65 points.push_back( RealPoint( 0.0, 0.0 ) );
66 points.push_back( RealPoint( 1.0, 0.0 ) );
67 points.push_back( RealPoint( 2.0, 0.0 ) );
68 points.push_back( RealPoint( 2.0, 1.0 ) );
69 points.push_back( RealPoint( 2.0, 2.0 ) );
70 points.push_back( RealPoint( 1.0, 2.0 ) );
71 points.push_back( RealPoint( 0.0, 2.0 ) );
72 points.push_back( RealPoint( 0.0, 1.0 ) );
75 typedef std::vector< RealPoint >::const_iterator ConstIteratorOnPoints;
78 for (
unsigned int n = 1; n < 10; ++n )
80 trace.
info() <<
"Binomial convolver n=" << n << std::endl;
81 MyBinomialConvolver bcc( n );
82 bcc.init( 1.0, points.begin(), points.end(), true );
83 for (
unsigned int i = 0; i < 8; ++i )
85 <<
" " << bcc.x( i ).first
86 <<
" " << bcc.x( i ).second
87 <<
" " << bcc.tangent( i ).first
88 <<
" " << bcc.tangent( i ).second
89 <<
" " << bcc.curvature( i )
92 unsigned int n = MyBinomialConvolver::suggestedSize( 1.0, points.begin(), points.end() );
93 trace.
info() <<
"Binomial convolver suggested n="
103 tgtEstimator.
init( 1.0, points.begin(), points.end(), true );
104 curvEstimator.
init( 1.0, points.begin(), points.end(), true );
105 for ( ConstIteratorOnPoints it = points.begin(), it_end = points.end();
109 <<
" " << tgtEstimator.
eval( it )
110 <<
" " << curvEstimator.
eval( it )
113 nbok +=
true ? 1 : 0;
115 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
116 <<
"true == true" << std::endl;
125 int main(
int argc,
char** argv )
129 for (
int i = 0; i < argc; ++i )
133 bool res = testBinomialConvolver();
134 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;