#include <iostream>
#include <sstream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/geometry/curves/ArithmeticalDSL.h"
using namespace std;
{
using namespace Z2i;
NaiveDSL<Integer> line( 2, 5, 0 );
Point bottomLeft( 0, 0 );
Board2D board;
Point firstPoint( bottomLeft[0], (line.a()*bottomLeft[0]/line.b()) );
Point lastPoint( topRight[0], (line.a()*topRight[0]/line.b()) );
it = line.begin(firstPoint),
ite = line.end(lastPoint);
it != ite; ++it )
{
board << SetMode( it->className(), "Paving" )
<< *it;
}
board << SetMode(
domain.className(),
"Grid")
board.drawArrow(0.0, 0.0, 1.0, 0.0);
board.drawArrow(0.0, 0.0, 0.0, 1.0);
board.saveSVG("NaiveDSL.svg");
#ifdef WITH_CAIRO
board.saveCairo("NaiveDSL.png", Board2D::CairoPNG);
#endif
}
{
using namespace Z2i;
StandardDSL<Integer> line( 2, 5, 0 );
Point bottomLeft( 0, 0 );
Board2D board;
Point firstPoint( bottomLeft[0], (line.a()*bottomLeft[0]/line.b()) );
Point lastPoint( topRight[0], (line.a()*topRight[0]/line.b()) );
it = line.begin(firstPoint),
ite = line.end(lastPoint);
it != ite; ++it )
{
board << SetMode( it->className(), "Paving" )
<< *it;
}
board << SetMode(
domain.className(),
"Grid")
board.drawArrow(0.0, 0.0, 1.0, 0.0);
board.drawArrow(0.0, 0.0, 0.0, 1.0);
board.saveSVG("StandardDSL.svg");
#ifdef WITH_CAIRO
board.saveCairo("StandardDSL.png", Board2D::CairoPNG);
#endif
}
template<typename DSL>
unsigned short octant,
unsigned int n)
{
std::stringstream ssTitle;
ssTitle << " Arithmetical DSL "
<< "(" << a << ", " << b << ", 0)"
<< " in octant " << octant;
using namespace Z2i;
DSL line( a, b, 0 );
Vector v = line.steps().first;
Vector w = line.steps().second;
Board2D board;
it = line.begin(
Point(0,0) );
unsigned int c;
for (c = 0; c < n; ++it, ++c )
{
board << SetMode( p.className(), "Paving" )
<< p;
}
Point topRight, bottomLeft;
if (b > 0)
{
if (a > 0)
{
bottomLeft = firstPoint;
topRight = lastPoint;
}
else
{
bottomLeft =
Point( firstPoint[0], lastPoint[1] );
topRight =
Point( lastPoint[0], firstPoint[1] );
}
}
else
{
if (a > 0)
{
bottomLeft =
Point( lastPoint[0], firstPoint[1] );
topRight =
Point( firstPoint[0], lastPoint[1] );
}
else
{
bottomLeft = lastPoint;
topRight = firstPoint;
}
}
it = line.begin(
Point(0,0) );
for (c = 0; c < n; ++c )
{
if ( line.remainder( p ) == line.mu() )
{
board.setPenColorRGBi(250, 0, 0);
board.drawArrow(p[0], p[1], p[0]+s[0], p[1]+s[1]);
}
++it;
if (c < (n-1))
{
if ( (q-p) == v )
board.setPenColorRGBi(0, 0, 250);
else if ( (q-p) == w )
board.setPenColorRGBi(0, 250, 0);
else
board.setPenColorRGBi(0, 0, 0);
board.drawArrow(p[0], p[1], q[0], q[1]);
}
}
board << SetMode(
domain.className(),
"Grid")
board.setPenColorRGBi(0, 0, 0);
board.drawArrow(0.0, 0.0, 1.0, 0.0);
board.drawArrow(0.0, 0.0, 0.0, 1.0);
std::stringstream ssFileName;
ssFileName << "ArithmeticalDSL"
<< "-" << DSL::foregroundAdjacency
<< "-" << octant
<< "-" << a << "-" << b
<< ".png";
#ifdef WITH_CAIRO
board.saveCairo(ssFileName.str().c_str(), Board2D::CairoPNG);
#endif
}
{
using namespace Z2i;
drawArithmeticalDSL<NaiveDSL<Integer> >( 0, 1, 0, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 5, 8, 0, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 1, 1, 1, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 8, 5, 1, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 1, 0, 2, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 8, -5, 2, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 1, -1, 3, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 5, -8, 3, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( 0, -1, 4, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -5, -8, 4, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -1, -1, 5, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -8, -5, 5, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -1, 0, 6, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -8, 5, 6, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -1, 1, 7, 15 );
drawArithmeticalDSL<NaiveDSL<Integer> >( -5, 8, 7, 15 );
drawArithmeticalDSL<StandardDSL<Integer> >( 0, 1, 0, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 5, 8, 0, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 1, 1, 1, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 8, 5, 1, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 1, 0, 2, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 8, -5, 2, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 1, -1, 3, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 5, -8, 3, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( 0, -1, 4, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -5, -8, 4, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -1, -1, 5, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -8, -5, 5, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -1, 0, 6, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -8, 5, 6, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -1, 1, 7, 21 );
drawArithmeticalDSL<StandardDSL<Integer> >( -5, 8, 7, 21 );
}
{
NaiveDSL<DGtal::int16_t, DGtal::int32_t> line2( 17711, 28657, 1607895256 );
}
int main(
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
return 0;
}
void beginBlock(const std::string &keyword="")
void exampleStandardDSL()
Function that illustrates the basic usage of a standard DSL.
void exampleNaiveDSL()
Function that illustrates the basic usage of a naive DSL.
void exampleArithmeticalDSLTypes()
Function that creates a naive DSL with different types.
void exampleArithmeticalDSLOctant()
Function that draws the steps and the shift vector of a naive and a standard DSL in each octant.
void drawArithmeticalDSL(typename DSL::Integer a, typename DSL::Integer b, unsigned short octant, unsigned int n)
Function that draws the steps and the shift vector of a DSL of slope a / b and intercept 0.
DigitalPlane::Point Vector
Point::Coordinate Integer
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
HyperRectDomain< Space > Domain