|
template<typename Integer > |
Integer | getRandomInteger (Integer first, Integer after_last) |
|
template<typename Integer , typename NaivePlaneComputer > |
bool | checkPlane (Integer a, Integer b, Integer c, Integer d, int diameter, unsigned int nbtries) |
|
template<typename Integer , typename NaivePlaneComputer > |
bool | checkPlaneGroupExtension (Integer a, Integer b, Integer c, Integer d, int diameter, unsigned int nbtries) |
|
template<typename Integer , typename GenericNaivePlaneComputer > |
bool | checkGenericPlane (Integer a, Integer b, Integer c, Integer d, int diameter, unsigned int nbtries) |
|
template<typename Integer , typename NaivePlaneComputer > |
bool | checkPlanes (unsigned int nbplanes, int diameter, unsigned int nbtries) |
|
template<typename Integer , typename NaivePlaneComputer > |
bool | checkWidth (Integer a, Integer b, Integer c, Integer d, int diameter, unsigned int nbtries) |
|
template<typename Integer , typename NaivePlaneComputer > |
bool | checkWidths (unsigned int nbplanes, int diameter, unsigned int nbtries) |
|
bool | testChordNaivePlaneComputer () |
|
template<typename NaivePlaneComputer > |
bool | checkManyPlanes (unsigned int diameter, unsigned int nbplanes, unsigned int nbpoints) |
|
template<typename GenericNaivePlaneComputer > |
bool | checkExtendWithManyPoints (unsigned int diameter, unsigned int nbplanes, unsigned int nbpoints) |
|
int | main (int, char **) |
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
- Author
- Jacques-Olivier Lachaud (
jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr
) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
- Date
- 2012/03/05
Functions for testing class ChordNaivePlaneComputer.
This file is part of the DGtal library.
Definition in file testChordNaivePlaneComputer.cpp.
template<typename Integer , typename GenericNaivePlaneComputer >
Checks the naive plane d <= ax+by+cz <= d + max(|a|,|b|,|c|)-1
Definition at line 283 of file testChordNaivePlaneComputer.cpp.
287 typedef typename Point::Component PointInteger;
294 if ( ( absA >= absB ) && ( absA >= absC ) )
296 else if ( ( absB >= absA ) && ( absB >= absC ) )
301 GenericNaivePlaneComputer plane;
305 unsigned int nbok = 0;
306 while ( nb != nbtries )
308 p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
309 p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
310 p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
319 bool ok_ext = plane.isExtendable( p );
320 bool ok = plane.extend( p );
321 ++nb; nbok += ok_ext ? 1 : 0;
322 ++nb; nbok += ok ? 1 : 0;
325 std::cerr <<
"[ERROR] p=" << p <<
" NOT IN plane=" << plane << std::endl;
328 std::cerr <<
" " << *it;
330 std::cerr <<
"d <= a*x+b*y+c*z <= d+max(a,b,c)"
331 << d <<
" <= " << a <<
"*" << p[0]
332 <<
"+" << b <<
"*" << p[1]
333 <<
"+" << c <<
"*" << p[2]
334 <<
" = " << (a*p[0]+b*p[1]+c*p[2])
340 std::cerr <<
"[ERROR] p=" << p <<
" was NOT extendable IN plane=" << plane << std::endl;
348 while ( nb != (nbtries * 11 ) / 10 )
350 p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
351 p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
352 p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
361 PointInteger tmp = getRandomInteger<PointInteger>( 2, 5 )
362 * (2*getRandomInteger<PointInteger>( 0, 2 ) - 1 );
364 bool ok_ext = ! plane.isExtendable( p );
365 bool ok = ! plane.extend( p );
366 ++nb; nbok += ok ? 1 : 0;
367 ++nb; nbok += ok_ext ? 1 : 0;
370 std::cerr <<
"[ERROR] p=" << p <<
" IN plane=" << plane << std::endl;
375 std::cerr <<
"[ERROR] p=" << p <<
" was extendable IN plane=" << plane << std::endl;
381 std::cerr <<
"plane = " << plane << std::endl;
static Integer abs(IntegerParamType a)
MyDigitalSurface::ConstIterator ConstIterator
References DGtal::IntegerComputer< TInteger >::abs(), and DGtal::IntegerComputer< TInteger >::ceilDiv().
template<typename Integer , typename NaivePlaneComputer >
Checks the naive plane d <= ax+by+cz <= d + max(|a|,|b|,|c|)-1
Definition at line 61 of file testChordNaivePlaneComputer.cpp.
65 typedef typename Point::Component PointInteger;
72 if ( ( absA >= absB ) && ( absA >= absC ) )
74 else if ( ( absB >= absA ) && ( absB >= absC ) )
80 plane.
init( axis, 1, 1 );
83 unsigned int nbok = 0;
84 while ( nb != nbtries )
86 p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
87 p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
88 p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
98 bool ok = plane.
extend( p );
99 ++nb; nbok += ok_ext ? 1 : 0;
100 ++nb; nbok += ok ? 1 : 0;
103 std::cerr <<
"[ERROR] p=" << p <<
" NOT IN plane=" << plane << std::endl;
106 std::cerr <<
" " << *it;
108 std::cerr <<
"d <= a*x+b*y+c*z <= d+max(a,b,c)"
109 << d <<
" <= " << a <<
"*" << p[0]
110 <<
"+" << b <<
"*" << p[1]
111 <<
"+" << c <<
"*" << p[2]
112 <<
" = " << (a*p[0]+b*p[1]+c*p[2])
118 std::cerr <<
"[ERROR] p=" << p <<
" was NOT extendable IN plane=" << plane << std::endl;
126 while ( nb != (nbtries * 11 ) / 10 )
128 p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
129 p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
130 p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
139 PointInteger tmp = getRandomInteger<PointInteger>( 2, 5 )
140 * (2*getRandomInteger<PointInteger>( 0, 2 ) - 1 );
143 bool ok = ! plane.
extend( p );
144 ++nb; nbok += ok ? 1 : 0;
145 ++nb; nbok += ok_ext ? 1 : 0;
148 std::cerr <<
"[ERROR] p=" << p <<
" IN plane=" << plane << std::endl;
153 std::cerr <<
"[ERROR] p=" << p <<
" was extendable IN plane=" << plane << std::endl;
void init(Dimension axis, InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE)
PointSet::const_iterator ConstIterator
ConstIterator end() const
ConstIterator begin() const
bool isExtendable(const Point &p) const
bool extend(const Point &p)
References DGtal::IntegerComputer< TInteger >::abs(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::begin(), DGtal::IntegerComputer< TInteger >::ceilDiv(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::end(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::extend(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::init(), and DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::isExtendable().
template<typename Integer , typename NaivePlaneComputer >
Checks the naive plane d <= ax+by+cz <= d + max(|a|,|b|,|c|)-1
Definition at line 167 of file testChordNaivePlaneComputer.cpp.
171 typedef typename Point::Component PointInteger;
178 if ( ( absA >= absB ) && ( absA >= absC ) )
180 else if ( ( absB >= absA ) && ( absB >= absC ) )
186 plane.
init( axis, 1, 1 );
189 unsigned int nbok = 0;
190 while ( nb < nbtries )
192 std::vector<Point> points( 5 );
193 for (
unsigned int i = 0; i < 5; ++i )
195 Point & pp = points[ i ];
196 pp[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
197 pp[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
198 pp[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
204 ( ic.
ceilDiv( d - b * y - c * z, a ) );
break;
206 ( ic.
ceilDiv( d - a * x - c * z, b ) );
break;
208 ( ic.
ceilDiv( d - a * x - b * y, c ) );
break;
211 bool ok_ext = plane.
isExtendable( points.begin(), points.end() );
212 bool ok = plane.
extend( points.begin(), points.end() );
213 ++nb; nbok += ok_ext ? 1 : 0;
214 ++nb; nbok += ok ? 1 : 0;
217 std::cerr <<
"[ERROR] p=" << points[ 0 ] <<
" NOT IN plane=" << plane << std::endl;
220 std::cerr <<
" " << *it;
222 std::cerr <<
"d <= a*x+b*y+c*z <= d+max(a,b,c)"
223 << d <<
" <= " << a <<
"*" << p[0]
224 <<
"+" << b <<
"*" << p[1]
225 <<
"+" << c <<
"*" << p[2]
226 <<
" = " << (a*p[0]+b*p[1]+c*p[2])
232 std::cerr <<
"[ERROR] p=" << p <<
" was NOT extendable IN plane=" << plane << std::endl;
240 while ( nb < (nbtries * 11 ) / 10 )
242 p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
243 p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
244 p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
253 PointInteger tmp = getRandomInteger<PointInteger>( 2, 5 )
254 * (2*getRandomInteger<PointInteger>( 0, 2 ) - 1 );
257 bool ok = ! plane.
extend( p );
258 ++nb; nbok += ok ? 1 : 0;
259 ++nb; nbok += ok_ext ? 1 : 0;
262 std::cerr <<
"[ERROR] p=" << p <<
" IN plane=" << plane << std::endl;
267 std::cerr <<
"[ERROR] p=" << p <<
" was extendable IN plane=" << plane << std::endl;
References DGtal::IntegerComputer< TInteger >::abs(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::begin(), DGtal::IntegerComputer< TInteger >::ceilDiv(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::end(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::extend(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::init(), and DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::isExtendable().
template<typename Integer , typename NaivePlaneComputer >
Checks the naive plane d <= ax+by+cz <= d + max(|a|,|b|,|c|)-1
Definition at line 426 of file testChordNaivePlaneComputer.cpp.
430 typedef typename NaivePlaneComputer::InternalScalar InternalScalar;
437 if ( ( absA >= absB ) && ( absA >= absC ) )
439 else if ( ( absB >= absA ) && ( absB >= absC ) )
445 unsigned int nbok = 0;
446 std::vector<Point> points( nbtries );
447 for (
unsigned int i = 0; i != nbtries; ++i )
449 Point & p = points[ i ];
450 p[ 0 ] = getRandomInteger<Integer>( -diameter+1, diameter );
451 p[ 1 ] = getRandomInteger<Integer>( -diameter+1, diameter );
452 p[ 2 ] = getRandomInteger<Integer>( -diameter+1, diameter );
464 << d <<
" <= " << a <<
"*x"
467 <<
" <= d + max(|a|,|b|,|c|)"
469 trace.
info() <<
"- " << points.size() <<
" points tested in diameter " << diameter
472 for (
unsigned int i = 0; i < 3; ++i )
474 std::pair<InternalScalar, InternalScalar> width
475 = NaivePlaneComputer::computeAxisWidth( i, points.begin(), points.end() );
478 trace.
info() <<
" (" << i <<
") width=" << (wn/wd) << std::endl;
479 if ( min < 0.0 ) min = wn/wd;
480 else if ( wn/wd < min ) min = wn/wd;
482 ++nb; nbok += (min < 1.0 ) ? 1 : 0;
483 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") min width = " << min
484 <<
" < 1.0" << std::endl;
485 ++nb; nbok += (0.9 < min ) ? 1 : 0;
486 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") min width = " << min
487 <<
" > 0.9" << std::endl;
References DGtal::IntegerComputer< TInteger >::abs(), DGtal::Trace::beginBlock(), DGtal::IntegerComputer< TInteger >::ceilDiv(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.
bool testChordNaivePlaneComputer |
( |
| ) |
|
Example of a test. To be completed.
Definition at line 525 of file testChordNaivePlaneComputer.cpp.
527 unsigned int nbok = 0;
542 trace.
beginBlock (
"Testing block: ChordNaivePlaneComputer instantiation." );
544 Point pt0( 0, 0, 0 );
545 plane.
init( 2, 1, 1 );
546 bool pt0_inside = plane.
extend( pt0 );
547 ++nb; nbok += pt0_inside ==
true ? 1 : 0;
548 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << plane
551 bool pt1_inside = plane.
extend( pt1 );
552 ++nb; nbok += pt1_inside ==
true ? 1 : 0;
553 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt1
554 <<
" Plane=" << plane << std::endl;
556 bool pt2_inside = plane.
extend( pt2 );
557 ++nb; nbok += pt2_inside ==
true ? 1 : 0;
558 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt2
559 <<
" Plane=" << plane << std::endl;
562 bool pt3_inside = plane.
extend( pt3 );
563 ++nb; nbok += pt3_inside ==
true ? 1 : 0;
564 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt3
565 <<
" Plane=" << plane << std::endl;
568 bool pt4_inside = plane.
extend( pt4 );
569 ++nb; nbok += pt4_inside ==
false ? 1 : 0;
570 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") impossible add " << pt4
571 <<
" Plane=" << plane << std::endl;
574 bool pt5_inside = plane.
extend( pt5 );
575 ++nb; nbok += pt5_inside ==
true ? 1 : 0;
576 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt5
577 <<
" Plane=" << plane << std::endl;
580 bool pt6_inside = plane.
extend( pt6 );
581 ++nb; nbok += pt6_inside ==
true ? 1 : 0;
582 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") add " << pt6
583 <<
" Plane=" << plane << std::endl;
586 plane2.
init( 2, 1, 1 );
590 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
591 <<
" Plane2=" << plane2 << std::endl;
593 ++nb; nbok += checkPlane<Integer,NaivePlaneComputer>( 11, 5, 19, 20, 100, 100 ) ? 1 : 0;
595 <<
") checkPlane<Integer,NaivePlaneComputer>( 11, 5, 19, 20, 100, 100 )"
598 ++nb; nbok += checkGenericPlane<Integer,GenericNaivePlaneComputer>( 11, 5, 19, 20, 100, 100 ) ? 1 : 0;
600 <<
") checkGenericPlane<Integer,GenericNaivePlaneComputer>( 11, 5, 19, 20, 100, 100 )"
602 ++nb; nbok += checkGenericPlane<Integer,GenericNaivePlaneComputer>( 17, 33, 7, 10, 100, 100 ) ? 1 : 0;
604 <<
") checkGenericPlane<Integer,GenericNaivePlaneComputer>( 17, 33, 7, 10, 100, 100 )"
606 ++nb; nbok += checkPlane<Integer,NaivePlaneComputer>( 15, 8, 13, 15, 100, 100 ) ? 1 : 0;
608 <<
") checkPlane<Integer,NaivePlaneComputer>( 15, 8, 13, 15, 100, 100 )"
610 ++nb; nbok += checkGenericPlane<Integer,GenericNaivePlaneComputer>( 15, 8, 13, 15, 100, 100 ) ? 1 : 0;
612 <<
") checkGenericPlane<Integer,GenericNaivePlaneComputer>( 15, 8, 13, 15, 100, 100 )"
617 trace.
beginBlock (
"Testing block: ChordNaivePlaneComputer vertical instantiation." );
619 Point pppt0( 0, 0, 0 );
620 ppplane.
init( 2, 5, 2 );
621 bool pppt0_inside = ppplane.
extend( pppt0 );
622 ++nb; nbok += pppt0_inside ==
true ? 1 : 0;
623 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << ppplane
625 Point pppt1( 3, 2, 2 );
626 bool pppt1_inside = ppplane.
extend( pppt1 );
627 ++nb; nbok += pppt1_inside ==
true ? 1 : 0;
628 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << ppplane
630 Point pppt2( 0, 0, 1 );
631 bool pppt2_inside = ppplane.
extend( pppt2 );
632 ++nb; nbok += pppt2_inside ==
true ? 1 : 0;
633 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << ppplane
636 bool pppt3_inside = ppplane.
extend( pppt3 );
637 ++nb; nbok += pppt3_inside ==
true ? 1 : 0;
638 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << ppplane
641 bool pppt4_inside = ppplane.
extend( pt4 );
642 ++nb; nbok += pppt4_inside ==
true ? 1 : 0;
643 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << ppplane
649 trace.
beginBlock (
"Testing block: ChordNaivePlaneComputer vertical instantiation 2." );
651 pplane.
init( 1, 1, 1 );
652 Point ppt0( -6, -3, 5 );
653 bool ppt0_inside = pplane.
extend( ppt0 );
654 ++nb; nbok += ppt0_inside ==
true ? 1 : 0;
655 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << pplane
657 Point ppt1( 4, 4, -5 );
658 bool ppt1_inside = pplane.
extend( ppt1 );
659 ++nb; nbok += ppt1_inside ==
true ? 1 : 0;
660 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << pplane
662 Point ppt2( -5, -2, 4 );
663 bool ppt2_inside = pplane.
extend( ppt2 );
664 ++nb; nbok += ppt2_inside ==
true ? 1 : 0;
665 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") Plane=" << pplane
Aim: A class that recognizes pieces of digital planes of given axis width. When the width is 1,...
COBANaivePlaneComputer< Z3, InternalInteger > NaivePlaneComputer
Aim: Defines the concept describing an object that computes some primitive from input points given gr...
Aim: Defines a predicate on a point.
Go to http://www.sgi.com/tech/stl/ForwardContainer.html.
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::extend(), DGtal::Trace::info(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::init(), and DGtal::trace.
Referenced by main().