35#include "DGtal/base/Common.h"
36#include "DGtal/helpers/StdDefs.h"
37#include "DGtal/kernel/CPointPredicate.h"
38#include "DGtal/geometry/surfaces/CAdditivePrimitiveComputer.h"
39#include "DGtal/geometry/surfaces/COBAGenericStandardPlaneComputer.h"
51template <
typename Integer>
55 return ( r % (after_last - first) ) + first;
58template <
typename Domain>
69 std::vector<Point> pts;
70 Integer mup = mu + abs(a) + abs(b) + abs(c);
75 Integer r = a * p[ 0 ] + b * p[ 1 ] + c * p[ 2 ];
76 if ( ( mu <= r ) && ( r < mup ) )
82template <
typename PlaneComputer >
84( PlaneComputer & computer,
unsigned int nbplanes,
int diameter )
86 typedef typename PlaneComputer::Space
Space;
91 unsigned int nbok = 0;
93 Point( diameter, diameter, diameter ) );
95 std::random_device rd;
98 for (
unsigned int p = 0; p < nbplanes; ++p )
105 while ( ( a == 0 ) && ( b == 0 ) && ( c == 0 ) );
108 computer.init( 2*diameter, 1, 1 );
109 ++nb; nbok += computer.extend( pts.begin(), pts.end() ) ? 1 : 0;
110 trace.
info() <<
"Primitive=" << computer.primitive() << std::endl;
111 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") extend "
112 << pts.size() <<
" points of plane "
113 << mu <<
" <= " << a <<
"*x+" << b <<
"*y+" << c <<
"*z+"
114 <<
" < " << (mu+a+b+c) << std::endl;
115 computer.init( 2*diameter, 1, 1 );
116 std::shuffle( pts.begin(), pts.end(), g );
117 ++nb; nbok += computer.extend( pts.begin(), pts.end() ) ? 1 : 0;
118 trace.
info() <<
"Primitive=" << computer.primitive() << std::endl;
119 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") extend "
120 << pts.size() <<
" shuffled points of plane "
121 << mu <<
" <= " << a <<
"*x+" << b <<
"*y+" << c <<
"*z+"
122 <<
" < " << (mu+a+b+c) << std::endl;
136 plane.
init( 100, 1, 1 );
137 ok = plane.extend(
Point(0,0,0) );
138 trace.
info() <<
"Point(0,0,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
140 ok = plane.extend(
Point(1,0,0) );
141 trace.
info() <<
"Point(1,0,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
143 ok = plane.extend(
Point(0,1,0) );
144 trace.
info() <<
"Point(0,1,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
146 ok = plane.extend(
Point(1,1,0) );
147 trace.
info() <<
"Point(1,1,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
149 ok = plane.extend(
Point(2,0,0) );
150 trace.
info() <<
"Point(2,0,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
152 ok = plane.extend(
Point(0,2,0) );
153 trace.
info() <<
"Point(0,2,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
155 ok = plane.extend(
Point(0,2,0) );
156 trace.
info() <<
"Point(0,2,0) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
158 ok = plane.extend(
Point(1,1,1) );
159 trace.
info() <<
"Point(1,1,1) is " << ( ok ?
"ok" :
"ko" ) << std::endl;
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)
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() const
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Point::Coordinate Integer
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
bool checkCOBAGenericStandardPlaneComputer(PlaneComputer &computer, unsigned int nbplanes, int diameter)
Integer getRandomInteger(const Integer &first, const Integer &after_last)
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)
HyperRectDomain< Space > Domain