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"
using namespace std;
int main(
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
Board2D boardScan1;
Board2D boardScan2;
boardScan1 << SetMode( dom.className(), "Paving" )
<< dom;
boardScan2 << SetMode( dom.className(), "Paving" )
<< dom;
K.init( dom.lowerBound(),dom.upperBound(),
true );
bool first=true;
do
{
boardScan1 << p;
if(first){
first=false;
prec=p;
continue;
}
boardScan1.setPenColor( Color( 30, 30, 200 ));
shift =
K.uCoords(p)-
K.uCoords(prec);
prec=p;
}
while (
K.uNext( p,
K.uFirst(p),
K.uLast(p) ) );
bool firstq = true;
using KPS = Z2i::KPreSpace;
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);
boardScan2.setPenColor( Color( 30, 30, 200 ));
precq = q;
}
}
boardScan1.saveSVG("khalimskySpaceScanner1.svg");
boardScan1.saveFIG("khalimskySpaceScanner1.fig");
boardScan2.saveSVG("khalimskySpaceScanner2.svg");
boardScan2.saveFIG("khalimskySpaceScanner2.fig");
return 0;
}
void beginBlock(const std::string &keyword="")
DigitalPlane::Point Vector
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
void draw(const Iterator &itb, const Iterator &ite, Board &aBoard)
HyperRectDomain< Space > Domain