DGtal  0.9.3
Typedefs | Functions
testBreadthFirstPropagation.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/GradientColorMap.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/graph/CUndirectedSimpleGraph.h"
#include "DGtal/graph/BreadthFirstVisitor.h"
#include "DGtal/graph/CGraphVisitor.h"
#include <set>
#include <iterator>
Include dependency graph for testBreadthFirstPropagation.cpp:

Go to the source code of this file.

Typedefs

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

Functions

void testBreadthFirstPropagation ()
 
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
Jérémy Gaillard (jerem.nosp@m.y.ga.nosp@m.illar.nosp@m.d@in.nosp@m.sa-ly.nosp@m.on.f.nosp@m.r )
Date
2012/06/18

Functions for testing objects as graph.

This file is part of the DGtal library.

Definition in file testBreadthFirstPropagation.cpp.

Typedef Documentation

◆ Image

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

Definition at line 52 of file testBreadthFirstPropagation.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

Definition at line 139 of file testBreadthFirstPropagation.cpp.

References testBreadthFirstPropagation().

140 {
142  return 0;
143 }
void testBreadthFirstPropagation()

◆ testBreadthFirstPropagation()

void testBreadthFirstPropagation ( )

Definition at line 53 of file testBreadthFirstPropagation.cpp.

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::HyperRectDomain< TSpace >::className(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::current(), domain(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::finished(), image(), and LibBoard::Board::saveEPS().

Referenced by main().

54 {
55  typedef Z2i::Point Point;
56  typedef Z2i::Domain Domain;
58  typedef Z2i::Object4_8 Object;
59 
60  BOOST_CONCEPT_ASSERT(( CUndirectedSimpleGraph<Z2i::Object4_8> ));
61 
62  Point p1( -41, -36 );
63  Point p2( 18, 18 );
64  Domain domain( p1, p2 );
65  Point c1( -2, -1 );
66  Point c2( -14, 5 );
67  Point c3( -30, -15 );
68  Point c4( -10, -20 );
69  Point c5( 12, -1 );
70  DigitalSet shape_set( domain );
71 
72  Shapes<Domain>::addNorm2Ball( shape_set, c1, 9 );
73  Shapes<Domain>::addNorm1Ball( shape_set, c2, 9 );
74  Shapes<Domain>::addNorm1Ball( shape_set, c3, 10 );
75  Shapes<Domain>::addNorm2Ball( shape_set, c4, 12 );
76  Shapes<Domain>::addNorm1Ball( shape_set, c5, 4 );
77 
78  Object obj(Z2i::dt4_8, shape_set);
79 
80 
81  GradientColorMap<int> cmap_grad( 0, 52);
82  cmap_grad.addColor( Color( 0, 0, 255 ) );
83  cmap_grad.addColor( Color( 0, 255, 0 ) );
84  cmap_grad.addColor( Color( 255, 0, 0 ) );
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 
98  while( !bfv.finished() )
99  {
100  image.setValue(bfv.current().first, bfv.current().second);
101  bfv.expand();
102  }
103 
104  string specificStyle = p1.className() + "/Paving";
105 
106  for ( DigitalSet::ConstIterator it = shape_set.begin();
107  it != shape_set.end();
108  ++it )
109  {
110  if( image(*it) == 0)
111  {
112  board << CustomStyle( specificStyle,
113  new CustomColors( Color::Black,
114  Color::Red ) )
115  << *it;
116  }
117  else
118  {
119  if( image(*it) > 0 )
120  {
121  board << CustomStyle( specificStyle,
122  new CustomColors( Color::Black,
123  cmap_grad( image(*it) ) ) )
124  << *it;
125  }
126  else
127  {
128  board << CustomStyle( specificStyle,
129  new CustomColors( Color::Black,
130  cmap_grad( 0 ) ) )
131  << *it;
132  }
133  }
134  }
135 
136  board.saveEPS("testBreadthFirstPropagation.eps");
137 }
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition: Object.h:119
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
HyperRectDomain< Space > Domain
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
const Domain domain(Point(1, 2), Point(6, 5))
MyDigitalSurface::ConstIterator ConstIterator
Aim: Define utilities to convert a digital set into an image.
Definition: ImageFromSet.h:63
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
BreadthFirstVisitor< MyDigitalSurface > Visitor
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
std::string className() const
MyPointD Point
Definition: testClone2.cpp:383
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Definition: Board2D.h:247
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Image image(domain)
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70
Aim: Defines the concept of a visitor onto a graph, that is an object that traverses vertices of the ...