This example shows the basic usage of a 8-connected and a 4-connected arithmetical DSS.
- See also
- Digital straight lines and segments
#include <iostream>
#include <exception>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/geometry/curves/ArithmeticalDSS.h"
using namespace std;
using namespace Z2i;
{
using namespace Z2i;
);
it != ite; ++it )
{
<< ") ";
}
board <<
SetMode(
"PointVector",
"Both");
<< segment;
board <<
SetMode(segment.className(),
"BoundingBox")
<< segment;
#ifdef WITH_CAIRO
board.
saveCairo(
"NaiveDSS8.png", Board2D::CairoPNG);
#endif
}
{
using namespace Z2i;
);
board <<
SetMode(
"PointVector",
"Grid")
<<
SetMode(segment.className(),
"Points")
<< segment;
board <<
SetMode(segment.className(),
"BoundingBox")
<< segment;
#ifdef WITH_CAIRO
board.
saveCairo(
"StandardDSS4.png", Board2D::CairoPNG);
#endif
board <<
SetMode(
"PointVector",
"Both");
board <<
SetMode(segment.className(),
"Points")
<< segment;
board <<
SetMode(segment.className(),
"BoundingBox")
<< segment;
board.
saveSVG(
"StandardDSS4bis.svg");
#ifdef WITH_CAIRO
board.
saveCairo(
"StandardDSS4bis.png", Board2D::CairoPNG);
#endif
}
{
using namespace Z2i;
{
}
{
}
{
}
{
}
std::vector<Point> r;
{
);
if (!segment.isValid()) throw std::exception();
std::copy( segment.begin(), segment.end(), std::back_inserter(r) );
}
{
}
}
{
using namespace Z2i;
);
if (!S.isValid()) throw std::exception();
{
board <<
SetMode(
"PointVector",
"Both");
board <<
SetMode(S.className(),
"Points")
<< S
<<
SetMode(S.className(),
"BoundingBox")
<< S;
board <<
SetMode(M.className(),
"Both")
<< M;
board.
saveSVG(
"NaiveDSS8ExtInit.svg");
#ifdef WITH_CAIRO
board.
saveCairo(
"NaiveDSS8ExtInit.png", Board2D::CairoPNG);
#endif
}
bool resExtention = S.extendFront( M );
if (!resExtention) throw std::exception();
{
board <<
SetMode(
"PointVector",
"Both");
board <<
SetMode(S.className(),
"Points")
<< S
<<
SetMode(S.className(),
"BoundingBox")
<< S;
board.
saveSVG(
"NaiveDSS8ExtDone.svg");
#ifdef WITH_CAIRO
board.
saveCairo(
"NaiveDSS8ExtDone.png", Board2D::CairoPNG);
#endif
}
bool resRetraction = S.retractFront();
if (!resRetraction) throw std::exception();
if ( !S.equalsTo(copyOfS) ) throw std::exception();
}
int main(
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
return 0;
}
std::string className() const