A simple example illustrating different way to scan a Khalimsky space. This program outputs these images:
- See also
- Moving within the cellular grid space
#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 )
<< 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;
}
prec=p;
}
bool firstq = true;
{
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;
}
precq = q;
}
}
boardScan1.
saveSVG(
"khalimskySpaceScanner1.svg");
boardScan1.
saveFIG(
"khalimskySpaceScanner1.fig");
boardScan2.
saveSVG(
"khalimskySpaceScanner2.svg");
boardScan2.
saveFIG(
"khalimskySpaceScanner2.fig");
return 0;
}
Integer uFirst(const PreCell &p, Dimension k) const
Return the k-th Khalimsky coordinate of the first cell of the space with the same type as [p].
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
Board & setPenColor(const DGtal::Color &color)
Structure representing an RGB triple with alpha component.
Cell uSpel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Integer uLast(const PreCell &p, Dimension k) const
Return the k-th Khalimsky coordinate of the last cell of the space with the same type as [p].
std::string className() const
void beginBlock(const std::string &keyword="")
Aim: This class is a model of CPreCellularGridSpaceND. It represents the cubical grid as a cell compl...
void draw(const Iterator &itb, const Iterator &ite, Board &aBoard)
DGtal is the top-level namespace which contains all DGtal functions and types.
bool uIsInside(const PreCell &p, Dimension k) const
Useful to check if you are going out of the space.
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Point uCoords(const Cell &c) const
Return its digital coordinates.
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
int main(int argc, char **argv)
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Cell uGetMax(Cell p, Dimension k) const
Useful to check if you are going out of the space.
bool uNext(Cell &p, const Cell &lower, const Cell &upper) const
Increment the cell [p] to its next position (as classically done in a scanning).
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...