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/topology/Expander.h"
45 #include "DGtal/io/boards/Board2D.h"
51 using namespace DGtal;
52 using namespace LibBoard;
61 virtual void setStyle (
Board2D & aboard )
const
68 virtual void setStyle (
Board2D & aboard )
const
76 virtual void setStyle (
Board2D & aboard )
const
87 virtual void setStyle (
Board2D & aboard )
const
98 virtual void setStyle (
Board2D & aboard )
const
113 bool testObjectBorder()
119 typedef Z2::Point
Point;
124 typedef Domain::ConstIterator DomainConstIterator;
129 Point p1 ( -20, -10 );
131 Domain domain ( p1, p2 );
135 DT8_4 dt8_4 ( adj8, adj4, JORDAN_DT );
140 DigitalSet bubble_set ( domain );
141 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
145 if ( ( x*x + y*y < 82 ) ||
146 ( ( x - 14 ) * ( x - 14 ) + ( y + 1 ) * ( y + 1 ) < 17 ) ||
147 ( ( x + 14 ) * ( x + 14 ) + ( y - 1 ) * ( y - 1 ) < 17 ) )
148 bubble_set.insertNew ( *it );
151 ObjectType bubble ( dt8_4, bubble_set );
154 if (bubble.computeConnectedness() ==
CONNECTED)
155 trace.
info() <<
"The object is (8,4)connected." << endl;
157 trace.
info() <<
"The object is not (8,4)connected." << endl;
160 ObjectType bubbleBorder = bubble.border();
161 if (bubbleBorder.computeConnectedness() ==
CONNECTED)
162 trace.
info() <<
"The object (8,4) border is connected." << endl;
164 trace.
info() <<
"The object (8,4) border is not connected." << endl;
168 board.
setUnit ( Board::UCentimeter );
170 board <<
SetMode( domain.className(),
"Grid" ) << domain << bubble_set;
171 board.
saveSVG (
"bubble-set.svg" );
173 board <<
SetMode( bubbleBorder.className(),
"DrawAdjacencies" )
176 board.
saveSVG (
"bubble-object-border.svg" );
183 DT8_4::ReverseTopology dt4_8 = dt8_4.reverseTopology();
185 ObjectType48 bubble2 ( dt4_8, bubble_set );
188 ObjectType48 bubbleBorder2 = bubble2.border();
189 if (bubbleBorder2.computeConnectedness() ==
CONNECTED)
190 trace.
info() <<
"The object (4,8) border is connected." << endl;
192 trace.
info() <<
"The object (4,8) border is not connected." << endl;
194 board <<
SetMode( domain.className(),
"Grid" ) << domain;
196 <<
SetMode( bubbleBorder2.className(),
"DrawAdjacencies" )
200 board.
saveSVG (
"bubble-object-border-48.svg" );
203 vector<ObjectType48> borders ( 30 );
204 unsigned int nbComponents;
206 vector<ObjectType48>::iterator it = borders.begin();
207 nbComponents = bubbleBorder2.writeComponents ( it );
209 trace.
info() <<
"The Bubble object has " << nbComponents <<
" (4,8)-connected components" << endl;
212 for (
unsigned int k = 0;k < nbComponents ; k++ )
221 board.
saveSVG (
"bubble-object-color-borders-48.svg" );
239 typedef Z2::Point Point;
244 typedef Domain::ConstIterator DomainConstIterator;
249 Point p1 ( -20, -10 );
251 Domain domain ( p1, p2 );
255 DT8_4 dt8_4 ( adj8, adj4, JORDAN_DT );
260 DigitalSet bubble_set ( domain );
261 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
265 if ( ( x*x + y*y < 82 ) ||
266 ( ( x - 14 ) * ( x - 14 ) + ( y + 1 ) * ( y + 1 ) < 17 ) ||
267 ( ( x + 14 ) * ( x + 14 ) + ( y - 1 ) * ( y - 1 ) < 17 ) )
268 bubble_set.insertNew ( *it );
271 ObjectType bubble ( dt8_4, bubble_set );
274 if (bubble.computeConnectedness() ==
CONNECTED)
275 trace.
info() <<
"The object is (8,4)connected." << endl;
277 trace.
info() <<
"The object is not (8,4)connected." << endl;
280 ObjectType bubbleBorder = bubble.border();
281 if (bubbleBorder.computeConnectedness() ==
CONNECTED)
282 trace.
info() <<
"The object (8,4) border is connected." << endl;
284 trace.
info() <<
"The object (8,4) border is not connected." << endl;
288 board.
setUnit ( Board::UCentimeter );
290 board <<
SetMode( domain.className(),
"Grid" )
295 board.
saveSVG (
"bubble-set-dgtalboard.svg" );
297 board <<
SetMode( bubbleBorder.className(),
"DrawAdjacencies" )
300 board.
saveSVG (
"bubble-object-border-dgtalboard.svg" );
312 bool res = testObjectBorder()