43#include "DGtal/base/Common.h"
44#include "DGtal/helpers/StdDefs.h"
46#include "DGtal/io/boards/Board2D.h"
49#include "DGtal/geometry/curves/ArithmeticalDSL.h"
78 Point bottomLeft( 0, 0 );
79 Point topRight( 10, 5 );
85 Point firstPoint( bottomLeft[0], (line.
a()*bottomLeft[0]/line.
b()) );
86 Point lastPoint( topRight[0], (line.
a()*topRight[0]/line.
b()) );
91 it = line.
begin(firstPoint),
92 ite = line.
end(lastPoint);
95 board <<
SetMode( it->className(),
"Paving" )
111 board.
saveCairo(
"NaiveDSL.png", Board2D::CairoPNG);
138 Point bottomLeft( 0, 0 );
139 Point topRight( 10, 5 );
145 Point firstPoint( bottomLeft[0], (line.
a()*bottomLeft[0]/line.
b()) );
146 Point lastPoint( topRight[0], (line.
a()*topRight[0]/line.
b()) );
150 it = line.
begin(firstPoint),
151 ite = line.
end(lastPoint);
154 board <<
SetMode( it->className(),
"Paving" )
167 board.
saveSVG(
"StandardDSL.svg");
169 board.
saveCairo(
"StandardDSL.png", Board2D::CairoPNG);
184template<
typename DSL>
186 typename DSL::Integer b,
187 unsigned short octant,
190 std::stringstream ssTitle;
191 ssTitle <<
" Arithmetical DSL "
192 <<
"(" << a <<
", " << b <<
", 0)"
193 <<
" in octant " << octant;
202 Vector v = line.steps().first;
203 Vector w = line.steps().second;
210 typename DSL::ConstIterator it;
211 it = line.begin(
Point(0,0) );
213 for (c = 0; c < n; ++it, ++c )
218 board <<
SetMode( p.className(),
"Paving" )
223 Point topRight, bottomLeft;
224 Point firstPoint(0,0);
225 Point lastPoint = *it;
230 bottomLeft = firstPoint;
231 topRight = lastPoint;
235 bottomLeft =
Point( firstPoint[0], lastPoint[1] );
236 topRight =
Point( lastPoint[0], firstPoint[1] );
243 bottomLeft =
Point( lastPoint[0], firstPoint[1] );
244 topRight =
Point( firstPoint[0], lastPoint[1] );
248 bottomLeft = lastPoint;
249 topRight = firstPoint;
256 it = line.begin(
Point(0,0) );
257 for (c = 0; c < n; ++c )
262 if ( line.remainder( p ) == line.mu() )
265 board.
drawArrow(p[0], p[1], p[0]+s[0], p[1]+s[1]);
275 else if ( (q-p) == w )
294 std::stringstream ssFileName;
295 ssFileName <<
"ArithmeticalDSL"
296 <<
"-" << DSL::foregroundAdjacency
298 <<
"-" << a <<
"-" << b
301 board.
saveCairo(ssFileName.str().c_str(), Board2D::CairoPNG);
317 drawArithmeticalDSL<NaiveDSL<Integer> >( 0, 1, 0, 15 );
318 drawArithmeticalDSL<NaiveDSL<Integer> >( 5, 8, 0, 15 );
319 drawArithmeticalDSL<NaiveDSL<Integer> >( 1, 1, 1, 15 );
320 drawArithmeticalDSL<NaiveDSL<Integer> >( 8, 5, 1, 15 );
321 drawArithmeticalDSL<NaiveDSL<Integer> >( 1, 0, 2, 15 );
322 drawArithmeticalDSL<NaiveDSL<Integer> >( 8, -5, 2, 15 );
323 drawArithmeticalDSL<NaiveDSL<Integer> >( 1, -1, 3, 15 );
324 drawArithmeticalDSL<NaiveDSL<Integer> >( 5, -8, 3, 15 );
325 drawArithmeticalDSL<NaiveDSL<Integer> >( 0, -1, 4, 15 );
326 drawArithmeticalDSL<NaiveDSL<Integer> >( -5, -8, 4, 15 );
327 drawArithmeticalDSL<NaiveDSL<Integer> >( -1, -1, 5, 15 );
328 drawArithmeticalDSL<NaiveDSL<Integer> >( -8, -5, 5, 15 );
329 drawArithmeticalDSL<NaiveDSL<Integer> >( -1, 0, 6, 15 );
330 drawArithmeticalDSL<NaiveDSL<Integer> >( -8, 5, 6, 15 );
331 drawArithmeticalDSL<NaiveDSL<Integer> >( -1, 1, 7, 15 );
332 drawArithmeticalDSL<NaiveDSL<Integer> >( -5, 8, 7, 15 );
334 drawArithmeticalDSL<StandardDSL<Integer> >( 0, 1, 0, 21 );
335 drawArithmeticalDSL<StandardDSL<Integer> >( 5, 8, 0, 21 );
336 drawArithmeticalDSL<StandardDSL<Integer> >( 1, 1, 1, 21 );
337 drawArithmeticalDSL<StandardDSL<Integer> >( 8, 5, 1, 21 );
338 drawArithmeticalDSL<StandardDSL<Integer> >( 1, 0, 2, 21 );
339 drawArithmeticalDSL<StandardDSL<Integer> >( 8, -5, 2, 21 );
340 drawArithmeticalDSL<StandardDSL<Integer> >( 1, -1, 3, 21 );
341 drawArithmeticalDSL<StandardDSL<Integer> >( 5, -8, 3, 21 );
342 drawArithmeticalDSL<StandardDSL<Integer> >( 0, -1, 4, 21 );
343 drawArithmeticalDSL<StandardDSL<Integer> >( -5, -8, 4, 21 );
344 drawArithmeticalDSL<StandardDSL<Integer> >( -1, -1, 5, 21 );
345 drawArithmeticalDSL<StandardDSL<Integer> >( -8, -5, 5, 21 );
346 drawArithmeticalDSL<StandardDSL<Integer> >( -1, 0, 6, 21 );
347 drawArithmeticalDSL<StandardDSL<Integer> >( -8, 5, 6, 21 );
348 drawArithmeticalDSL<StandardDSL<Integer> >( -1, 1, 7, 21 );
349 drawArithmeticalDSL<StandardDSL<Integer> >( -5, 8, 7, 21 );
384int main(
int argc,
char** argv )
388 for (
int i = 0; i < argc; ++i )
ArithmeticalDSL negate() const
ConstIterator begin(const Point &aPoint) const
ConstIterator end(const Point &aPoint) const
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
std::string className() const
Aim: This class is an alias of ArithmeticalDSS for naive DSL. It represents a naive digital straight ...
Aim: This class is an alias of ArithmeticalDSS for standard DSL. It represents a standard digital str...
void beginBlock(const std::string &keyword="")
Board & setPenColorRGBi(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
void drawArrow(double x1, double y1, double x2, double y2, bool filled=true, int depthValue=-1)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
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.
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....
FreemanChain< int >::Vector Vector