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/DomainMetricAdjacency.h"
41 #include "DGtal/topology/DomainAdjacency.h"
42 #include "DGtal/topology/DigitalTopology.h"
43 #include "DGtal/topology/Object.h"
44 #include "DGtal/graph/Expander.h"
48 using namespace DGtal;
50 #define INBLOCK_TEST(x) \
51 nbok += ( x ) ? 1 : 0; \
53 trace.info() << "(" << nbok << "/" << nb << ") " \
56 #define INBLOCK_TEST2(x,y) \
57 nbok += ( x ) ? 1 : 0; \
59 trace.info() << "(" << nbok << "/" << nb << ") " \
71 unsigned int nbok = 0;
77 typedef Point::Coordinate Coordinate;
94 Point p1( -50, -50, -50 );
95 Point p2( 50, 50, 50 );
100 Adj6 adj6(
domain, madj6 );
101 Adj18 adj18(
domain, madj18 );
108 double radius = (double) (r+1);
113 sstr <<
"Creating 3D ball( r < " << radius <<
" ) ...";
119 if ( (*it - c ).norm() < radius )
125 trace.
beginBlock (
"Testing Object instanciation and smart copy ..." );
126 ObjectType ball( dt6_18, ball_set );
127 ObjectType ball2( ball );
129 trace.
info() <<
"ball.size() = " << ball.size()
130 <<
" 4/3*pi*r^3 = " << ( 4.0*M_PI*radius*radius*radius/3.0 )
132 trace.
info() <<
"ball = " << ball << endl;
133 trace.
info() <<
"ball2 = " << ball2 << endl;
137 ObjectType sphere = ball.border();
140 trace.
info() <<
"sphere.size() = " << sphere.size()
141 <<
" 4*pi*r^2 = " << ( 4.0*M_PI*radius*radius )
145 trace.
beginBlock (
"Testing expansion by layers in the ball from center..." );
146 ObjectExpander expander( ball, c );
147 while ( ! expander.finished() )
150 expander.nextLayer();
152 nbok += expander.distance() <= sqrt(3.0)*radius ? 1 : 0;
154 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
155 <<
"expander.distance() = " << expander.distance()
156 <<
" <= " << sqrt(3.0)*radius << std::endl;
159 trace.
beginBlock (
"Testing expansion by layers on the sphere from a point ..." );
160 ObjectExpander expander2( sphere, l );
161 while ( ! expander2.finished() )
164 expander2.nextLayer();
166 nbok += expander2.distance() <= sqrt(2.0)*M_PI*radius ? 1 : 0;
168 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
169 <<
"expander2.distance() = " << expander2.distance()
170 <<
" <= " << sqrt(2.0)*M_PI*radius << std::endl;
180 int main(
int argc,
char** argv )
184 for (
int i = 0; i < argc; ++i )
189 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
void insertNew(const Point &p)
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 & end() const
const ConstIterator & begin() 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="")
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet