DGtal 1.3.0
Loading...
Searching...
No Matches
Typedefs | Functions
testDepthFirstPropagation.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/graph/CUndirectedSimpleGraph.h"
#include "DGtal/graph/DepthFirstVisitor.h"
#include "DGtal/graph/CGraphVisitor.h"
#include <set>
#include <iterator>

Go to the source code of this file.

Typedefs

typedef ImageSelector< Z2i::Domain, int >::Type Image
 

Functions

void testDepthFirstPropagation ()
 
int main (int, char **)
 

Detailed Description

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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/06/18

Functions for testing objects as graph.

This file is part of the DGtal library.

Definition in file testDepthFirstPropagation.cpp.

Typedef Documentation

◆ Image

typedef ImageSelector<Z2i::Domain,int>::Type Image

Definition at line 53 of file testDepthFirstPropagation.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

Definition at line 183 of file testDepthFirstPropagation.cpp.

184{
186 return 0;
187}
void testDepthFirstPropagation()

References testDepthFirstPropagation().

◆ testDepthFirstPropagation()

void testDepthFirstPropagation ( )

Definition at line 54 of file testDepthFirstPropagation.cpp.

55{
56 typedef Z2i::Point Point;
57 typedef Z2i::Domain Domain;
59 typedef Z2i::Object4_8 Object;
60
61 BOOST_CONCEPT_ASSERT(( CUndirectedSimpleGraph<Z2i::Object4_8> ));
62
63 Point p1( -41, -36 );
64 Point p2( 18, 18 );
65 Domain domain( p1, p2 );
66 Point c1( -2, -1 );
67 Point c2( -14, 5 );
68 Point c3( -30, -15 );
69 Point c4( -10, -20 );
70 Point c5( 12, -1 );
71 DigitalSet shape_set( domain );
72
73 Shapes<Domain>::addNorm2Ball( shape_set, c1, 9 );
74 Shapes<Domain>::addNorm1Ball( shape_set, c2, 9 );
75 Shapes<Domain>::addNorm1Ball( shape_set, c3, 10 );
76 Shapes<Domain>::addNorm2Ball( shape_set, c4, 12 );
77 Shapes<Domain>::addNorm1Ball( shape_set, c5, 4 );
78
79 Object obj(Z2i::dt4_8, shape_set);
80
81
82 HueShadeColorMap<int,3> cmap_grad( 0, obj.size());
83 //cmap_grad.addColor( Color( 0, 0, 200 ) );
84 //cmap_grad.addColor( Color( 0, 0, 50 ) );
85
86 Board2D board;
87 board << SetMode( domain.className(), "Paving" )
88 << domain
89 << SetMode( p1.className(), "Paving" );
90
91 Image image = ImageFromSet<Image>::create(shape_set, 1);
92
94 BOOST_CONCEPT_ASSERT(( CGraphVisitor<Visitor> ));
95 Visitor bfv (obj, c1);
96
97 int cpt=0;
98
99 while( !bfv.finished() )
100 {
101 image.setValue(bfv.current().first, ++cpt);
102 bfv.expand();
103 }
104
105 string specificStyle = p1.className() + "/Paving";
106
107 for ( DigitalSet::ConstIterator it = shape_set.begin();
108 it != shape_set.end();
109 ++it )
110 {
111 if( image(*it) == 0)
112 {
113 board << CustomStyle( specificStyle,
115 Color::Red ) )
116 << *it;
117 }
118 else
119 {
120 if( image(*it) > 0 )
121 {
122 board << CustomStyle( specificStyle,
124 cmap_grad( image(*it) ) ) )
125 << *it;
126 }
127 else
128 {
129 board << CustomStyle( specificStyle,
131 cmap_grad( 0 ) ) )
132 << *it;
133 }
134 }
135 }
136 board.saveEPS("testDepthFirstPropagation.eps");
137
138 board.clear();
139
141
142
143 while( !bfv2.finished() )
144 {
145 image.setValue(bfv2.current().first, bfv2.current().second);
146 bfv2.expand();
147 }
148
149 specificStyle = p1.className() + "/Paving";
150
151 for ( DigitalSet::ConstIterator it = shape_set.begin();
152 it != shape_set.end();
153 ++it )
154 {
155 if( image(*it) == 0)
156 {
157 board << CustomStyle( specificStyle,
159 Color::Red ) )
160 << *it;
161 }
162 else
163 {
164 if( image(*it) > 0 )
165 {
166 board << CustomStyle( specificStyle,
168 cmap_grad( image(*it) ) ) )
169 << *it;
170 }
171 else
172 {
173 board << CustomStyle( specificStyle,
175 cmap_grad( 0 ) ) )
176 << *it;
177 }
178 }
179 }
180 board.saveEPS("testDepthFirstPropagation-distance.eps");
181}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
static const Color Red
Definition: Color.h:416
static const Color Black
Definition: Color.h:413
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
std::string className() const
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition: Object.h:120
static void addNorm1Ball(TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
static void addNorm2Ball(TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
BreadthFirstVisitor< MyDigitalSurface > Visitor
static const DT4_8 dt4_8
Definition: StdDefs.h:113
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
static Image create(const Set &aSet, const Value &defaultValue, const bool addBorder, typename Set::ConstIterator itBegin, typename Set::ConstIterator itEnd, const bool keepSetDomain=false)
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Aim: Defines the concept of a visitor onto a graph, that is an object that traverses vertices of the ...
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
MyPointD Point
Definition: testClone2.cpp:383
Domain domain
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet

References DGtal::Shapes< TDomain >::addNorm1Ball(), DGtal::Shapes< TDomain >::addNorm2Ball(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::begin(), DGtal::Color::Black, DGtal::HyperRectDomain< TSpace >::className(), LibBoard::Board::clear(), DGtal::ImageFromSet< TImage >::create(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::current(), DGtal::DepthFirstVisitor< TGraph, TMarkSet >::current(), domain, DGtal::Z2i::dt4_8, DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::end(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::DepthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::finished(), DGtal::DepthFirstVisitor< TGraph, TMarkSet >::finished(), DGtal::Color::Red, and LibBoard::Board::saveEPS().

Referenced by main().