DGtal 1.3.0
No Matches

Example of DGtal kernel with Domain.

See also
DGtal Space
Iteration over a domain with displacements depicted as arrows.
#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"
using namespace std;
using namespace DGtal;
int main()
trace.beginBlock ( "Example kernelDomain" );
typedef DGtal::Z2i::Space MySpace;
//Point lying in the Z2i::Space
typedef MySpace::Point MyPoint;
MyPoint p(13,-5);
trace.info() << "Point p="<<p<<endl;
//We create a domain
typedef HyperRectDomain<MySpace> MyDomain;
MyPoint a(-3,-4);
MyPoint b(10,4);
MyDomain domain(a,b);
//We trace domain information
trace.info() <<"Domain domain="<<domain<<endl;
//We generate a board
Board2D board;
board << domain;
MyPoint c(5,1);
if ( domain.isInside(c) )
trace.info() << "C is inside the domain"<<endl;
trace.info() << "C is outside the domain"<<endl;
board << c;
//PointVector example
MyPoint q;
MyPoint::Coordinate coord = 24;
for(MySpace::Dimension d = 0 ; d < MySpace::dimension; d++)
q[d] = coord;
MyPoint r;
for(MyPoint::Iterator it=r.begin(), itend=r.end() ;
it != itend;
(*it) = coord;
//We scan the domain
for( MyDomain::ConstIterator it = domain.begin(), itend = domain.end();
it != itend;
trace.info() << "Processing point"<< (*it) << endl;
board << domain;
//We draw an arrow between two consecutive points during the iteration.
MyDomain::ConstIterator itPrec = domain.begin();
MyDomain::ConstIterator it = itPrec;
MyDomain::Vector shift;
board << (*itPrec); //We display the first point as a pixel.
for( MyDomain::ConstIterator itend = domain.end();
it != itend;
++it, ++itPrec)
shift = (*it) -(*itPrec);
Display2DFactory::draw(board, shift, (*itPrec));
return 0;
// //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
int main()
Definition: testBits.cpp:56
Domain domain