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
- 2011/09/01
Functions for testing class DigitalSurface.
This file is part of the DGtal library.
Definition in file testDigitalSurface.cpp.
bool testDigitalSetBoundary |
( |
| ) |
|
Example of a test. To be completed.
Definition at line 61 of file testDigitalSurface.cpp.
63 unsigned int nbok = 0;
70 typedef Boundary::Tracker Tracker;
71 typedef Boundary::Surfel Surfel;
81 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 82 <<
"K.init() is ok" << std::endl;
83 Boundary boundary(
K, dig_set );
84 unsigned int nbsurfels = 0;
85 for (
ConstIterator it = boundary.begin(), it_end = boundary.end();
90 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
91 ++nb; nbok += nbsurfels == ( 12 + 44 ) ? 1 : 0;
92 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 93 <<
"nbsurfels == (12 + 44 )" << std::endl;
94 for (
ConstIterator it = boundary.begin(), it_end = boundary.end();
97 Tracker* ptrTracker = boundary.newTracker( *it );
98 Surfel s = ptrTracker->current();
101 unsigned int m1 = ptrTracker->adjacent( s1, trackDir,
true );
102 unsigned int m2 = ptrTracker->adjacent( s2, trackDir,
false );
103 trace.
info() <<
"s = " << s << std::endl;
104 trace.
info() <<
"s1 = " << s1 <<
" m1 = " << m1 << std::endl;
105 trace.
info() <<
"s2 = " << s2 <<
" m2 = " << m2 << std::endl;
106 ++nb; nbok += boundary.isInside( s1 ) ? 1 : 0;
107 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 108 <<
"boundary.isInside( s1 )" << std::endl;
109 ++nb; nbok += boundary.isInside( s2 ) ? 1 : 0;
110 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 111 <<
"boundary.isInside( s2 )" << std::endl;
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
MyDigitalSurface::ConstIterator ConstIterator
DGtal::uint32_t Dimension
const Point & upperBound() const
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
const Point & lowerBound() const
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
References DGtal::Trace::beginBlock(), domain, DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::KhalimskySpaceND< dim, TInteger >::sDirs(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().
Referenced by main().
template<typename KSpace >
bool testDigitalSurface |
( |
| ) |
|
Definition at line 491 of file testDigitalSurface.cpp.
493 unsigned int nbok = 0;
495 std::string msg(
"Testing block ... DigitalSurface in K" );
506 Point p0 = Point::diagonal( 0 );
507 Point p1 = Point::diagonal( -6 );
508 Point p2 = Point::diagonal( 6 );
516 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 517 <<
"K.init() is ok" << std::endl;
530 typedef typename MyDS::Surfel Surfel;
531 DSContainer* ptrBdry =
new DSContainer(
K, dig_set );
532 MyDS digsurf( ptrBdry );
538 ++nb; nbok += digsurf.size() == nbsurfels ? 1 : 0;
539 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 540 <<
"digsurf.size() = " << digsurf.size()
541 <<
" == " << nbsurfels << std::endl;
543 it_end = digsurf.end();
548 ++nb; nbok += digsurf.degree( s ) == 2*(
K.
dimension-1) ? 1 : 0;
550 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 551 <<
"digsurf.degree( s ) == " 558 unsigned int nb_dist_1 = 0;
560 while ( ! visitor.finished() )
563 if ( node.second == 1 ) ++nb_dist_1;
566 trace.
info() <<
"last node v=" << node.first <<
" d=" << node.second << std::endl;
567 ++nb; nbok += nb_dist_1 == 2*(
K.
dimension-1) ? 1 : 0;
568 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 569 <<
"nb surfels at distance 1 == " 571 const BFVMarkSet & visitedVtx = visitor.markedVertices();
572 Size nbsurfelsComp1 =
576 ++nb; nbok += visitedVtx.size() == nbsurfelsComp1 ? 1 : 0;
577 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 578 <<
"nb visited = " << visitedVtx.size() <<
" == " 579 << nbsurfelsComp1 << std::endl;
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
HyperRectDomain< Space > Domain
Aim: Defines the concept describing a const single pass range.
MyDigitalSurface::ConstIterator ConstIterator
const Node & current() const
const Point & upperBound() const
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
NumberTraits< Integer >::UnsignedVersion Size
Type used to represent sizes in the digital space.
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
std::pair< Vertex, Data > Node
FIXME.
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
const Point & lowerBound() const
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
static const constexpr Dimension dimension
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
References DGtal::Trace::beginBlock(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::current(), DGtal::KhalimskySpaceND< dim, TInteger >::dimension, domain, DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().
Referenced by main().
bool testExplicitDigitalSurface |
( |
| ) |
|
Definition at line 273 of file testDigitalSurface.cpp.
280 typedef Frontier::SCell
SCell;
282 unsigned int nbok = 0;
285 Point p1( -5, -5, -5 );
288 nbok +=
K.
init( p1, p2,
true ) ? 1 : 0;
290 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 291 <<
"K.init() is ok" << std::endl;
300 SurfelPredicate surfPredicate(
K, image, 2, 0 );
301 Frontier frontier20(
K, surfPredicate,
304 unsigned int nbsurfels = 0;
305 for (
ConstIterator it = frontier20.begin(), it_end = frontier20.end();
310 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
311 ++nb; nbok += nbsurfels == 9 ? 1 : 0;
312 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 313 <<
"frontier20: nbsurfels == 9" << std::endl;
318 SurfelPredicate surfPredicate(
K, image, 1, 0 );
319 Frontier frontier10(
K, surfPredicate,
322 unsigned int nbsurfels = 0;
323 for (
ConstIterator it = frontier10.begin(), it_end = frontier10.end();
328 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
329 ++nb; nbok += nbsurfels == 140 ? 1 : 0;
330 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 331 <<
"frontier10: nbsurfels == 140" << std::endl;
336 SurfelPredicate surfPredicate(
K, image, 1, 2 );
337 Frontier frontier12(
K, surfPredicate,
340 unsigned int nbsurfels = 0;
341 for (
ConstIterator it = frontier12.begin(), it_end = frontier12.end();
346 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
347 ++nb; nbok += nbsurfels == 36 ? 1 : 0;
348 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 349 <<
"frontier12: nbsurfels == 36" << std::endl;
354 typedef Boundary::SurfelConstIterator EConstIterator;
360 SecondSurfelPredicate surfPredicate(
K, image, 1 );
361 Boundary boundary1x(
K, surfPredicate,
364 unsigned int nbsurfels = 0;
365 for ( EConstIterator it = boundary1x.begin(), it_end = boundary1x.end();
370 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
371 ++nb; nbok += nbsurfels == 176 ? 1 : 0;
372 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 373 <<
"boundary1x: nbsurfels == 176" << std::endl;
void beginBlock(const std::string &keyword="")
HyperRectDomain< Space > Domain
Aim: The predicate on surfels that represents the frontier between two regions in an image....
Aim: implements association bewteen points lying in a digital domain and values.
MyDigitalSurface::ConstIterator ConstIterator
SCell sSpel(Point p, Sign sign=POS) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: The predicate on surfels that represents the frontier between a region and its complementary in ...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
ImageContainerBySTLVector< Domain, Value > Image
static const constexpr Sign POS
SCell sIncident(const SCell &c, Dimension k, bool up) const
Return the forward or backward signed cell incident to [c] along axis [k], depending on [up].
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
void fillImage3D(Image3D &img, typename Image3D::Point low, typename Image3D::Point up, typename Image3D::Value value)
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), fillImage3D(), image(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::KhalimskySpaceND< dim, TInteger >::POS, DGtal::KhalimskySpaceND< dim, TInteger >::sIncident(), DGtal::KhalimskySpaceND< dim, TInteger >::sSpel(), and DGtal::trace.
Referenced by main().
bool testLightExplicitDigitalSurface |
( |
| ) |
|
Definition at line 382 of file testDigitalSurface.cpp.
389 typedef Frontier::SCell
SCell;
391 unsigned int nbok = 0;
394 Point p1( -5, -5, -5 );
397 nbok +=
K.
init( p1, p2,
true ) ? 1 : 0;
399 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 400 <<
"K.init() is ok" << std::endl;
409 SurfelPredicate surfPredicate(
K, image, 2, 0 );
410 Frontier frontier20(
K, surfPredicate,
413 unsigned int nbsurfels = 0;
414 for (
ConstIterator it = frontier20.begin(), it_end = frontier20.end();
419 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
420 ++nb; nbok += nbsurfels == 9 ? 1 : 0;
421 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 422 <<
"frontier20: nbsurfels == 9" << std::endl;
427 SurfelPredicate surfPredicate(
K, image, 1, 0 );
428 Frontier frontier10(
K, surfPredicate,
431 unsigned int nbsurfels = 0;
432 for (
ConstIterator it = frontier10.begin(), it_end = frontier10.end();
437 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
438 ++nb; nbok += nbsurfels == 140 ? 1 : 0;
439 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 440 <<
"frontier10: nbsurfels == 140" << std::endl;
445 SurfelPredicate surfPredicate(
K, image, 1, 2 );
446 Frontier frontier12(
K, surfPredicate,
449 unsigned int nbsurfels = 0;
450 for (
ConstIterator it = frontier12.begin(), it_end = frontier12.end();
455 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
456 ++nb; nbok += nbsurfels == 36 ? 1 : 0;
457 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 458 <<
"frontier12: nbsurfels == 36" << std::endl;
463 typedef Boundary::SurfelConstIterator LEConstIterator;
469 SecondSurfelPredicate surfPredicate(
K, image, 1 );
470 Boundary boundary1x(
K, surfPredicate,
473 unsigned int nbsurfels = 0;
474 for ( LEConstIterator it = boundary1x.begin(), it_end = boundary1x.end();
479 trace.
info() << nbsurfels <<
" surfels found." << std::endl;
480 ++nb; nbok += nbsurfels == 176 ? 1 : 0;
481 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " 482 <<
"boundary1x: nbsurfels == 176" << std::endl;
void beginBlock(const std::string &keyword="")
HyperRectDomain< Space > Domain
Aim: The predicate on surfels that represents the frontier between two regions in an image....
Aim: implements association bewteen points lying in a digital domain and values.
MyDigitalSurface::ConstIterator ConstIterator
SCell sSpel(Point p, Sign sign=POS) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
Aim: The predicate on surfels that represents the frontier between a region and its complementary in ...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
ImageContainerBySTLVector< Domain, Value > Image
static const constexpr Sign POS
SCell sIncident(const SCell &c, Dimension k, bool up) const
Return the forward or backward signed cell incident to [c] along axis [k], depending on [up].
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
void fillImage3D(Image3D &img, typename Image3D::Point low, typename Image3D::Point up, typename Image3D::Value value)
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), fillImage3D(), image(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::KhalimskySpaceND< dim, TInteger >::POS, DGtal::KhalimskySpaceND< dim, TInteger >::sIncident(), DGtal::KhalimskySpaceND< dim, TInteger >::sSpel(), and DGtal::trace.
Referenced by main().