DGtal  0.9.3
Functions
kernelDomain.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/io/boards/Board2D.h"
Include dependency graph for kernelDomain.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
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
2011/03/05

An example file named kernelDomain.

This file is part of the DGtal library.

Definition in file kernelDomain.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 55 of file kernelDomain.cpp.

References DGtal::Trace::beginBlock(), LibBoard::Board::clear(), domain(), draw(), DGtal::Trace::endBlock(), DGtal::Trace::info(), LibBoard::Board::saveSVG(), and DGtal::trace.

56 {
57  trace.beginBlock ( "Example kernelDomain" );
58 
59  typedef DGtal::Z2i::Space MySpace;
60 
61  //Point lying in the Z2i::Space
62  typedef MySpace::Point MyPoint;
63 
64  MyPoint p(13,-5);
65 
66  trace.info() << "Point p="<<p<<endl;
67 
68  //We create a domain
69  typedef HyperRectDomain<MySpace> MyDomain;
70  MyPoint a(-3,-4);
71  MyPoint b(10,4);
72  MyDomain domain(a,b);
73 
74  //We trace domain information
75  trace.info() <<"Domain domain="<<domain<<endl;
76 
77  //We generate a board
78  Board2D board;
79  board << domain;
80  board.saveSVG("kernel-domain.svg");
81 
82  MyPoint c(5,1);
83 
84  if ( domain.isInside(c) )
85  trace.info() << "C is inside the domain"<<endl;
86  else
87  trace.info() << "C is outside the domain"<<endl;
88 
89  board << c;
90  board.saveSVG("kernel-domain-point.svg");
91 
92 
93  //PointVector example
94  MyPoint q;
95  MyPoint::Coordinate coord = 24;
96  for(MySpace::Dimension d = 0 ; d < MySpace::dimension; d++)
97  q[d] = coord;
98  trace.info()<<"Q="<<q<<endl;
99 
100  MyPoint r;
101  for(MyPoint::Iterator it=r.begin(), itend=r.end() ;
102  it != itend;
103  ++it)
104  (*it) = coord;
105  trace.info()<<"R="<<r<<endl;
106 
107 
108  //We scan the domain
109  for( MyDomain::ConstIterator it = domain.begin(), itend = domain.end();
110  it != itend;
111  ++it)
112  trace.info() << "Processing point"<< (*it) << endl;
113 
114 
115  board.clear();
116  board << domain;
117  //We draw an arrow between two consecutive points during the iteration.
118  MyDomain::ConstIterator itPrec = domain.begin();
119  MyDomain::ConstIterator it = itPrec;
120  MyDomain::Vector shift;
121  ++it;
122 
123  board << (*itPrec); //We display the first point as a pixel.
124  for( MyDomain::ConstIterator itend = domain.end();
125  it != itend;
126  ++it, ++itPrec)
127  {
128  shift = (*it) -(*itPrec);
129  Display2DFactory::draw(board, shift, (*itPrec));
130  }
131  board.saveSVG("kernel-domain-it-arrow.svg");
132 
133  trace.endBlock();
134  return 0;
135 }
void beginBlock(const std::string &keyword="")
const Domain domain(Point(1, 2), Point(6, 5))
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
FreemanChain< int >::Vector Vector
void draw(const Iterator &itb, const Iterator &ite, Board &aBoard)
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70