33#include "DGtal/base/Common.h"
34#include "DGtal/kernel/SpaceND.h"
35#include "DGtal/kernel/domains/DomainPredicate.h"
36#include "DGtal/kernel/domains/HyperRectDomain.h"
37#include "DGtal/kernel/sets/DigitalSetSelector.h"
38#include "DGtal/kernel/sets/DigitalSetConverter.h"
39#include "DGtal/topology/MetricAdjacency.h"
40#include "DGtal/topology/DomainAdjacency.h"
41#include "DGtal/topology/DigitalTopology.h"
42#include "DGtal/topology/Object.h"
43#include "DGtal/graph/Expander.h"
49#define INBLOCK_TEST(x) \
50 nbok += ( x ) ? 1 : 0; \
52 trace.info() << "(" << nbok << "/" << nb << ") " \
55#define INBLOCK_TEST2(x,y) \
56 nbok += ( x ) ? 1 : 0; \
58 trace.info() << "(" << nbok << "/" << nb << ") " \
70 unsigned int nbok = 0;
75 typedef Z3::Point
Point;
76 typedef Point::Coordinate Coordinate;
93 Point p1( -50, -50, -50 );
94 Point p2( 50, 50, 50 );
107 double radius = (double) (r+1);
112 sstr <<
"Creating 3D ball( r < " << radius <<
" ) ...";
118 if ( (*it - c ).norm() < radius )
120 ball_set.insertNew( *it );
124 trace.
beginBlock (
"Testing Object instanciation and smart copy ..." );
125 ObjectType ball( dt6_18, ball_set );
126 ObjectType ball2( ball );
128 trace.
info() <<
"ball.size() = " << ball.size()
129 <<
" 4/3*pi*r^3 = " << ( 4.0*M_PI*radius*radius*radius/3.0 )
131 trace.
info() <<
"ball = " << ball << endl;
132 trace.
info() <<
"ball2 = " << ball2 << endl;
136 ObjectType sphere = ball.border();
139 trace.
info() <<
"sphere.size() = " << sphere.size()
140 <<
" 4*pi*r^2 = " << ( 4.0*M_PI*radius*radius )
144 trace.
beginBlock (
"Testing expansion by layers in the ball from center..." );
145 ObjectExpander expander( ball, c );
146 while ( ! expander.finished() )
149 expander.nextLayer();
151 nbok += expander.distance() <= sqrt(3.0)*radius ? 1 : 0;
153 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
154 <<
"expander.distance() = " << expander.distance()
155 <<
" <= " << sqrt(3.0)*radius << std::endl;
158 trace.
beginBlock (
"Testing expansion by layers on the sphere from a point ..." );
159 ObjectExpander expander2( sphere, l );
160 while ( ! expander2.finished() )
163 expander2.nextLayer();
165 nbok += expander2.distance() <= sqrt(2.0)*M_PI*radius ? 1 : 0;
167 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
168 <<
"expander2.distance() = " << expander2.distance()
169 <<
" <= " << sqrt(2.0)*M_PI*radius << std::endl;
179int main(
int argc,
char** argv )
183 for (
int i = 0; i < argc; ++i )
187 bool res = testExpander();
188 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a digital topology as a couple of adjacency relations.
Aim: Given a domain and an adjacency, limits the given adjacency to the specified domain for all adja...
Aim: This class is useful to visit an object by adjacencies, layer by layer.
Iterator for HyperRectDomain.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const ConstIterator & begin() const
const ConstIterator & end() const
Aim: Describes digital adjacencies in digital spaces that are defined with the 1-norm and the infinit...
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
void beginBlock(const std::string &keyword="")
MetricAdjacency< Space, 2 > Adj18
MetricAdjacency< Space, 1 > Adj6
DigitalTopology< Adj6, Adj18 > DT6_18
DGtal is the top-level namespace which contains all DGtal functions and types.
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet