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"
45 #include "DGtal/io/boards/Board2D.h"
51 using namespace DGtal;
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
128 Point p1 ( -20, -10 );
144 if ( ( x*x + y*y < 82 ) ||
145 ( ( x - 14 ) * ( x - 14 ) + ( y + 1 ) * ( y + 1 ) < 17 ) ||
146 ( ( x + 14 ) * ( x + 14 ) + ( y - 1 ) * ( y - 1 ) < 17 ) )
150 ObjectType bubble ( dt8_4, bubble_set );
153 if (bubble.computeConnectedness() ==
CONNECTED)
154 trace.
info() <<
"The object is (8,4)connected." << endl;
156 trace.
info() <<
"The object is not (8,4)connected." << endl;
159 ObjectType bubbleBorder = bubble.border();
160 if (bubbleBorder.computeConnectedness() ==
CONNECTED)
161 trace.
info() <<
"The object (8,4) border is connected." << endl;
163 trace.
info() <<
"The object (8,4) border is not connected." << endl;
167 board.
setUnit ( Board::UCentimeter );
170 board.
saveSVG (
"bubble-set.svg" );
172 board <<
SetMode( bubbleBorder.className(),
"DrawAdjacencies" )
173 <<
CustomStyle ( bubbleBorder.className(),
new MyObjectStyleCustom )
175 board.
saveSVG (
"bubble-object-border.svg" );
182 DT8_4::ReverseTopology dt4_8 = dt8_4.reverseTopology();
184 ObjectType48 bubble2 ( dt4_8, bubble_set );
187 ObjectType48 bubbleBorder2 = bubble2.border();
188 if (bubbleBorder2.computeConnectedness() ==
CONNECTED)
189 trace.
info() <<
"The object (4,8) border is connected." << endl;
191 trace.
info() <<
"The object (4,8) border is not connected." << endl;
195 <<
SetMode( bubbleBorder2.className(),
"DrawAdjacencies" )
196 <<
CustomStyle ( bubbleBorder2.className(),
new MyObjectStyleCustom )
199 board.
saveSVG (
"bubble-object-border-48.svg" );
202 vector<ObjectType48> borders ( 30 );
203 unsigned int nbComponents;
205 vector<ObjectType48>::iterator it = borders.begin();
206 nbComponents = bubbleBorder2.writeComponents ( it );
208 trace.
info() <<
"The Bubble object has " << nbComponents <<
" (4,8)-connected components" << endl;
211 for (
unsigned int k = 0;k < nbComponents ; k++ )
214 board <<
SetMode( borders[k].className(),
"DrawAdjacencies" ) <<
CustomStyle ( borders[k].className(),
new MyObjectStyleCustom ) << borders[k];
216 board <<
SetMode( borders[k].className(),
"DrawAdjacencies" ) <<
CustomStyle ( borders[k].className(),
new MyObjectStyleCustom ) << borders[k];
220 board.
saveSVG (
"bubble-object-color-borders-48.svg" );
248 Point p1 ( -20, -10 );
264 if ( ( x*x + y*y < 82 ) ||
265 ( ( x - 14 ) * ( x - 14 ) + ( y + 1 ) * ( y + 1 ) < 17 ) ||
266 ( ( x + 14 ) * ( x + 14 ) + ( y - 1 ) * ( y - 1 ) < 17 ) )
270 ObjectType bubble ( dt8_4, bubble_set );
273 if (bubble.computeConnectedness() ==
CONNECTED)
274 trace.
info() <<
"The object is (8,4)connected." << endl;
276 trace.
info() <<
"The object is not (8,4)connected." << endl;
279 ObjectType bubbleBorder = bubble.border();
280 if (bubbleBorder.computeConnectedness() ==
CONNECTED)
281 trace.
info() <<
"The object (8,4) border is connected." << endl;
283 trace.
info() <<
"The object (8,4) border is not connected." << endl;
287 board.
setUnit ( Board::UCentimeter );
294 board.
saveSVG (
"bubble-set-dgtalboard.svg" );
296 board <<
SetMode( bubbleBorder.className(),
"DrawAdjacencies" )
297 <<
CustomStyle ( bubbleBorder.className(),
new MyDrawStyleCustomBlue )
299 board.
saveSVG (
"bubble-object-border-dgtalboard.svg" );