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);
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.
DigitalPlane::Point Vector
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....