DGtal  1.5.beta
exampleParametricShapes.cpp File Reference
#include <iostream>
#include <DGtal/base/Common.h>
#include <DGtal/shapes/Shapes.h>
#include <DGtal/shapes/GaussDigitizer.h>
#include <DGtal/shapes/parametric/Astroid2D.h>
#include <DGtal/io/boards/Board2D.h>
Include dependency graph for exampleParametricShapes.cpp:

Go to the source code of this file.


int main (int argc, char **argv)

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/.

Adrien Krähenbühl (krahe.nosp@m.nbuh.nosp@m.l@uni.nosp@m.stra.nosp@m..fr ) Laboratoire des sciences de l'ingénieur, de l'informatique et de l'imagerie - ICube (UMR 7357), France

An example file named exampleParametricShapes.

This file is part of the DGtal library.

Definition in file exampleParametricShapes.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 

Definition at line 47 of file exampleParametricShapes.cpp.

48 {
49  trace.beginBlock ( "Example Parametric Shapes" );
51  typedef Z2i::Space Space;
53  /* This example consider the Lemniscate shape.
54  *
55  * To test other shapes, replace Astroid2D by the desirated shape
56  * and adapt parameters of the shape constructor.
57  */
58  typedef Astroid2D<Space> MyShape;
59  MyShape shape( 0, 0, 10, 5 );
61  // Grid step parameter for the Gauzz digitization
62  double h = 1;
64  // Gauss digitization
65  typedef GaussDigitizer< Z2i::Space, MyShape > MyGaussDigitizer;
66  MyGaussDigitizer dig;
67  dig.attach( shape );
68  dig.init( shape.getLowerBound(), shape.getUpperBound(), h );
70  // Create the digital point set from the digitizer
71  Z2i::DigitalSet aSet( dig.getDomain() );
74  // Draw the digitized shape in a file named "shape.svg"
75  Board2D board;
76  board << aSet;
77  board << CustomStyle( aSet.className(), new CustomFillColor(Color::Black));
78  board.saveSVG( "shape.svg" );
80  trace.endBlock();
81  return 0;
82 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
double endBlock()
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1011
Trace trace
Definition: Common.h:153
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:343

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::Trace::beginBlock(), DGtal::Color::Black, DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::className(), DGtal::Shapes< TDomain >::digitalShaper(), DGtal::Trace::endBlock(), LibBoard::Board::saveSVG(), and DGtal::trace.