DGtal  1.2.0
Functions
dgtalBoard2D-4-colormaps.cpp File Reference
#include <cmath>
#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/helpers/StdDefs.h"
Include dependency graph for dgtalBoard2D-4-colormaps.cpp:

Go to the source code of this file.

Functions

int main ()
 

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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Date
2010/11/26

An example file named dgtalboard-4-colormaps.

This file is part of the DGtal library.

Definition in file dgtalBoard2D-4-colormaps.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 56 of file dgtalBoard2D-4-colormaps.cpp.

57 {
58  trace.beginBlock ( "Example dgtalBoard2D-4-colormaps" );
59 
60  Point p1( -10, -7 );
61  Point p2( 10, 7 );
62  Domain domain( p1, p2 );
63  Point c1( -5, -1 );
64  Point c2( 5, 1 );
65  DigitalSet shape_set( domain );
66  Shapes<Domain>::addNorm1Ball( shape_set, c1, 5 );
67  Shapes<Domain>::addNorm1Ball( shape_set, c2, 5 );
68  shape_set.erase( c1 );
69  shape_set.erase( c2 );
70 
71  // Creating colormap.
72  GradientColorMap<int> cmap_grad( 0, 15 );
73  cmap_grad.addColor( Color( 50, 50, 255 ) );
74  cmap_grad.addColor( Color( 255, 0, 0 ) );
75  cmap_grad.addColor( Color( 255, 255, 10 ) );
76 
77  // Creating board.
78  Board2D board;
79  board << SetMode( domain.className(), "Paving" )
80  << domain
81  << SetMode( p1.className(), "Paving" );
82  // This is the name of the style for a Point in mode "Paving".
83  string specificStyle = p1.className() + "/Paving";
84  for ( DigitalSet::ConstIterator it = shape_set.begin();
85  it != shape_set.end();
86  ++it )
87  {
88  unsigned int d = (unsigned int) ceil( ( *it - c1 ).norm() );
89  // specific color depending on the distance to point c1.
90  board << CustomStyle( specificStyle,
91  new CustomColors( Color::Black,
92  cmap_grad( d ) ) )
93  << *it;
94  }
95  board.saveSVG( "dgtalBoard2D-4-colormaps.svg");
96  board.saveEPS( "dgtalBoard2D-4-colormaps.eps");
97  board.saveTikZ( "dgtalBoard2D-4-colormaps.tikz");
98 
99 #ifdef WITH_CAIRO
100  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.pdf", Board2D::CairoPDF);
101  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.png", Board2D::CairoPNG);
102  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.ps", Board2D::CairoPS);
103  board.saveCairo("dgtalBoard2D-4-colormaps-cairo.svg", Board2D::CairoSVG);
104 #endif
105 
106  trace.endBlock();
107  return 0;
108 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
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: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
double endBlock()
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1139
Trace trace
Definition: Common.h:154
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Domain domain

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::className(), domain, DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::end(), DGtal::Trace::endBlock(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::erase(), LibBoard::Board::saveCairo(), LibBoard::Board::saveEPS(), LibBoard::Board::saveSVG(), LibBoard::Board::saveTikZ(), and DGtal::trace.