54#include "DGtal/base/Common.h"
55#include "DGtal/helpers/StdDefs.h"
56#include "DGtal/io/viewers/Viewer3D.h"
57#include "DGtal/geometry/surfaces/COBAGenericStandardPlaneComputer.h"
70template <
typename Viewer3D,
typename Domain,
typename Predicate>
85template <
typename Viewer3D,
typename InputIterator>
89 for ( ; it != itE; ++it )
97template <
typename Domain>
108 std::vector<Point> pts;
109 Integer mup = mu + abs(a) + abs(b) + abs(c);
114 Integer r = a * p[ 0 ] + b * p[ 1 ] + c * p[ 2 ];
115 if ( ( mu <= r ) && ( r < mup ) )
122int main(
int argc,
char** argv )
126 unsigned int nbok = 0;
128 QApplication application(argc,argv);
130 unsigned int diameter = argc > 1 ? atoi( argv[ 1 ] ) : 10;
131 int a = argc > 2 ? atoi( argv[ 2 ] ) : 2;
132 int b = argc > 3 ? atoi( argv[ 3 ] ) : 3;
133 int c = argc > 4 ? atoi( argv[ 4 ] ) : 5;
134 int mu = argc > 5 ? atoi( argv[ 5 ] ) : 0;
137 << mu <<
" <= " << a <<
" * x + "
138 << b <<
" * y + " << c <<
" * z < "
139 << (mu+abs(a)+abs(b)+abs(c)) << std::endl;
140 Domain domain1(
Point( -diameter, -diameter, -diameter ),
141 Point( diameter, diameter, diameter ) );
144 typedef PlaneComputer::Primitive Primitive;
146 plane.
init( 2*diameter, 1, 1 );
150 ++nb, nbok += plane.extend( recognized.begin(), recognized.end() ) ? 1 : 0;
152 <<
") All points are recognized." << std::endl;
155 Primitive strip = plane.primitive();
157 <<
" axis=" << strip.mainAxis()
158 <<
" axiswidth=" << strip.axisWidth()
159 <<
" diag=" << strip.mainDiagonal()
160 <<
" diagwidth=" << strip.diagonalWidth()
162 ++nb, nbok += ( strip.diagonalWidth() < sqrt(3.0) ) ? 1 : 0;
164 <<
") Diagonal width < sqrt(3)." << std::endl;
165 trace.
emphase() << ( (nb == nbok) ?
"Passed." :
"Error." ) << endl;
171 Color red( 255, 0, 0 );
172 Color green( 0, 255, 0 );
173 Color grey( 200, 200, 200 );
174 Domain domain2(
Point( -2*diameter, -2*diameter, -2*diameter ),
175 Point( 2*diameter, 2*diameter, 2*diameter ) );
177 for ( std::vector<Point>::const_iterator it = recognized.begin(),
178 itE = recognized.end(); it != itE; ++it )
179 if ( ! strip( *it ) ) viewer << *it;
185 trace.
info() <<
"- Points in green have been recognized as belonging to this standard plane." << std::endl;
186 trace.
info() <<
"- Points in grey belongs also to the parallel strip of the recognized standard plane." << std::endl;
187 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;
189 return application.exec();
Aim: A class that recognizes pieces of digital planes of given axis width. When the diagonal width is...
void init(InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE)
Structure representing an RGB triple with alpha component.
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() 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.
void displayRange(Viewer3D &viewer, InputIterator it, InputIterator itE)
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)
void displayPredicate(Viewer3D &viewer, const Domain &domain, const Predicate &pred)