53 #include "DGtal/base/Common.h"
54 #include "DGtal/helpers/StdDefs.h"
55 #include "DGtal/geometry/surfaces/ChordNaivePlaneComputer.h"
56 #include "DGtal/io/viewers/Viewer3D.h"
61 using namespace DGtal;
65 template <
typename Viewer3D,
typename Domain,
typename Predicate>
78 int main(
int argc,
char** argv )
82 QApplication application(argc,argv);
85 unsigned int nbok = 0;
88 typedef PlaneComputer::Primitive Primitive;
91 plane.
init( 2, 1, 1 );
93 bool pt0_inside = plane.extend( pt0 );
94 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << plane
97 bool pt1_inside = plane.extend( pt1 );
98 ++nb; nbok += pt1_inside ==
true ? 1 : 0;
99 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt1
100 <<
" Plane=" << plane << std::endl;
101 Point pt2( 2, 7, 1 );
102 bool pt2_inside = plane.extend( pt2 );
103 ++nb; nbok += pt2_inside ==
true ? 1 : 0;
104 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt2
105 <<
" Plane=" << plane << std::endl;
107 Point pt3( 0, 5, 12 );
108 bool pt3_inside = plane.extend( pt3 );
109 ++nb; nbok += pt3_inside ==
false ? 1 : 0;
110 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt3
111 <<
" Plane=" << plane << std::endl;
113 Point pt4( -5, -5, 10 );
114 bool pt4_inside = plane.extend( pt4 );
115 ++nb; nbok += pt4_inside ==
false ? 1 : 0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt4
117 <<
" Plane=" << plane << std::endl;
119 Point pt5 = pt0 + pt1 + pt2 +
Point( 0, 0, 1 );
120 bool pt5_inside = plane.extend( pt5 );
121 ++nb; nbok += pt5_inside ==
true ? 1 : 0;
122 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt5
123 <<
" Plane=" << plane << std::endl;
126 bool pt6_inside = plane.extend( pt6 );
127 ++nb; nbok += pt6_inside ==
true ? 1 : 0;
128 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt5
129 <<
" Plane=" << plane << std::endl;
131 Primitive strip = plane.primitive();
133 <<
" axis=" << strip.mainAxis()
134 <<
" axiswidth=" << strip.axisWidth()
135 <<
" diag=" << strip.mainDiagonal()
136 <<
" diagwidth=" << strip.diagonalWidth()
138 ++nb; nbok += strip.axisWidth() < 1.0 ? 1 : 0;
139 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") axiswidth < 1 "
141 ++nb; nbok += strip.diagonalWidth() < sqrt(3.0) ? 1 : 0;
142 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") axiswidth < sqrt(3) "
145 trace.
emphase() << ( nbok == nb ?
"Passed." :
"Error." ) << endl;
151 Color red( 255, 0, 0 );
152 Color green( 0, 255, 0 );
153 Color grey( 200, 200, 200 );
165 viewer << MyViewer::updateDisplay;
168 return application.exec();
Aim: A class that contains the chord-based algorithm for recognizing pieces of digital planes of give...
void init(Dimension axis, InternalScalar widthNumerator=NumberTraits< InternalScalar >::ONE, InternalScalar widthDenominator=NumberTraits< InternalScalar >::ONE)
Structure representing an RGB triple with alpha component.
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
void displayPredicate(Viewer3D &viewer, const Domain &domain, const Predicate &pred)