A simple example illustrating different way to scan a Khalimsky space. This program outputs these images:
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/boards/Board2D.h"
int main(
int argc,
char** argv )
{
trace.
beginBlock (
"Example KhalimskySpaceScanner" );
for ( int i = 0; i < argc; ++i )
trace.
info() <<
" " << argv[ i ];
<< dom;
<< dom;
bool first=true;
do
{
boardScan1 << p;
if(first){
first=false;
prec=p;
continue;
}
shift =
K.uCoords(p)-
K.uCoords(prec);
Display2DFactory::draw(boardScan1, shift,
K.uCoords(prec));
prec=p;
}
while (
K.uNext( p,
K.uFirst(p),
K.uLast(p) ) );
bool firstq = true;
for ( KPS::Cell qq =
K.uGetMax(q, 0);
K.uIsInside(qq, 0); qq = KPS::uGetDecr(qq, 0) )
{
for ( KPS::uSetKCoord( qq,
K.uFirst( qq, 1 ), 1 );
K.uIsInside(qq, 1); qq = KPS::uGetIncr(qq, 1) )
{
boardScan2 << q;
if(firstq){
firstq = false;
precq = q;
continue;
}
shiftq =
K.uCoords(q) -
K.uCoords(precq);
Display2DFactory::draw(boardScan2, shiftq,
K.uCoords(precq));
precq = q;
}
}
boardScan1.
saveSVG(
"khalimskySpaceScanner1.svg");
boardScan1.
saveFIG(
"khalimskySpaceScanner1.fig");
boardScan2.
saveSVG(
"khalimskySpaceScanner2.svg");
boardScan2.
saveFIG(
"khalimskySpaceScanner2.fig");
return 0;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Structure representing an RGB triple with alpha component.
const Point & lowerBound() const
const Point & upperBound() const
std::string className() const
Aim: This class is a model of CPreCellularGridSpaceND. It represents the cubical grid as a cell compl...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
void beginBlock(const std::string &keyword="")
Board & setPenColor(const DGtal::Color &color)
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....