33 #include <QtGui/qapplication.h>
34 #include "DGtal/io/viewers/Viewer3D.h"
35 #include "DGtal/base/Common.h"
36 #include "DGtal/helpers/StdDefs.h"
37 #include "DGtal/geometry/surfaces/COBANaivePlane.h"
41 using namespace DGtal;
45 template <
typename Viewer3D,
typename Domain,
typename Predicate>
48 const Domain & domain,
const Predicate & pred )
50 for (
typename Domain::ConstIterator itB = domain.begin(), itE = domain.end();
58 int main(
int argc,
char** argv )
62 QApplication application(argc,argv);
65 unsigned int nbok = 0;
70 plane.
init( 2, 100, 1, 1 );
72 bool pt0_inside = plane.extend( pt0 );
73 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << plane
76 bool pt1_inside = plane.extend( pt1 );
77 ++nb, nbok += pt1_inside ==
true ? 1 : 0;
78 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt1
79 <<
" Plane=" << plane << std::endl;
81 bool pt2_inside = plane.extend( pt2 );
82 ++nb, nbok += pt2_inside ==
true ? 1 : 0;
83 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt2
84 <<
" Plane=" << plane << std::endl;
86 Point pt3( 0, 5, 12 );
87 bool pt3_inside = plane.extend( pt3 );
88 ++nb, nbok += pt3_inside ==
false ? 1 : 0;
89 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt3
90 <<
" Plane=" << plane << std::endl;
92 Point pt4( -5, -5, 10 );
93 bool pt4_inside = plane.extend( pt4 );
94 ++nb, nbok += pt4_inside ==
false ? 1 : 0;
95 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt4
96 <<
" Plane=" << plane << std::endl;
98 Point pt5 = pt0 + pt1 + pt2 +
Point( 0, 0, 1 );
99 bool pt5_inside = plane.extend( pt5 );
100 ++nb, nbok += pt5_inside ==
true ? 1 : 0;
101 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt5
102 <<
" Plane=" << plane << std::endl;
104 trace.
emphase() << ( nbok == nb ?
"Passed." :
"Error." ) << endl;
109 Color red( 255, 0, 0 );
110 Color green( 0, 255, 0 );
111 Color grey( 200, 200, 200 );
113 viewer << ( pt0_inside ?
CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt0;
114 viewer << ( pt1_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt1;
115 viewer << ( pt2_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt2;
116 viewer << ( pt3_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt3;
117 viewer << ( pt4_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt4;
118 viewer << ( pt5_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt5;
119 viewer << CustomColors3D( grey, grey );
120 displayPredicate( viewer, domain, plane );
122 viewer << Viewer3D::updateDisplay;
125 return application.exec();