52 #include "DGtal/base/Common.h"
53 #include "DGtal/helpers/StdDefs.h"
54 #include "DGtal/geometry/surfaces/ChordGenericStandardPlaneComputer.h"
55 #include "DGtal/io/viewers/Viewer3D.h"
59 using namespace DGtal;
68 template <
typename Viewer3D,
typename Domain,
typename Predicate>
83 template <
typename Viewer3D,
typename InputIterator>
87 for ( ; it != itE; ++it )
95 template <
typename Domain>
106 std::vector<Point> pts;
107 Integer mup = mu + abs(a) + abs(b) + abs(c);
112 Integer r = a * p[ 0 ] + b * p[ 1 ] + c * p[ 2 ];
113 if ( ( mu <= r ) && ( r < mup ) )
120 int main(
int argc,
char** argv )
124 unsigned int nbok = 0;
126 QApplication application(argc,argv);
128 unsigned int diameter = argc > 1 ? atoi( argv[ 1 ] ) : 10;
129 int a = argc > 2 ? atoi( argv[ 2 ] ) : 2;
130 int b = argc > 3 ? atoi( argv[ 3 ] ) : 3;
131 int c = argc > 4 ? atoi( argv[ 4 ] ) : 5;
132 int mu = argc > 5 ? atoi( argv[ 5 ] ) : 0;
133 trace.
beginBlock (
"Testing class ChordGenericStandardPlaneComputer" );
135 << mu <<
" <= " << a <<
" * x + "
136 << b <<
" * y + " << c <<
" * z < "
137 << (mu+abs(a)+abs(b)+abs(c)) << std::endl;
138 Domain domain1(
Point( -diameter, -diameter, -diameter ),
139 Point( diameter, diameter, diameter ) );
143 typedef PlaneComputer::Primitive Primitive;
149 ++nb, nbok += plane.extend( recognized.begin(), recognized.end() ) ? 1 : 0;
151 <<
") All points are recognized." << std::endl;
154 Primitive strip = plane.primitive();
156 <<
" axis=" << strip.mainAxis()
157 <<
" axiswidth=" << strip.axisWidth()
158 <<
" diag=" << strip.mainDiagonal()
159 <<
" diagwidth=" << strip.diagonalWidth()
161 ++nb, nbok += ( strip.diagonalWidth() < sqrt(3.0) ) ? 1 : 0;
163 <<
") Diagonal width < sqrt(3)." << std::endl;
164 trace.
emphase() << ( (nb == nbok) ?
"Passed." :
"Error." ) << endl;
170 Color red( 255, 0, 0 );
171 Color green( 0, 255, 0 );
172 Color grey( 200, 200, 200 );
173 Domain domain2(
Point( -2*diameter, -2*diameter, -2*diameter ),
174 Point( 2*diameter, 2*diameter, 2*diameter ) );
176 for ( std::vector<Point>::const_iterator it = recognized.begin(),
177 itE = recognized.end(); it != itE; ++it )
178 if ( ! strip( *it ) ) viewer << *it;
183 viewer << MyViewer::updateDisplay;
184 trace.
info() <<
"- Points in green have been recognized as belonging to this standard plane." << std::endl;
185 trace.
info() <<
"- Points in grey belongs also to the parallel strip of the recognized standard plane." << std::endl;
186 trace.
info() <<
"- Points in red belongs to the parallel strip of the recognized standard plane but not to the input standard plane: NONE should be red." << std::endl;
188 return application.exec();
Aim: A class that recognizes pieces of digital planes of given diagonal width. When the width is ,...
void init(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...
Point::Coordinate Integer
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.
std::vector< typename Domain::Point > pointsInStandardPlane(const Domain &domain, typename Domain::Integer a, typename Domain::Integer b, typename Domain::Integer c, typename Domain::Integer mu)
int main(int argc, char **argv)
void displayRange(Viewer3D &viewer, InputIterator it, InputIterator itE)
void displayPredicate(Viewer3D &viewer, const Domain &domain, const Predicate &pred)