42 #include "DGtal/base/Common.h"
43 #include "DGtal/helpers/StdDefs.h"
44 #include "DGtal/io/boards/Board2D.h"
47 #include "DGtal/geometry/curves/ArithmeticalDSS.h"
52 using namespace DGtal;
60 void exampleNaiveDSS()
69 Point(0,0), Point(8,5),
70 Point(0,0), Point(8,5),
71 Point(3,1), Point(3,1)
86 << segment.position( *it ) <<
","
87 << segment.remainder( *it )
97 Domain domain( Point(0,0), Point(8,5) );
102 board <<
SetMode(
"PointVector",
"Both");
103 board <<
SetMode(segment.className(),
"Points")
107 board <<
SetMode(segment.className(),
"BoundingBox")
113 board.
saveSVG(
"NaiveDSS8.svg");
115 board.
saveCairo(
"NaiveDSS8.png", Board2D::CairoPNG);
126 void exampleStandardDSS()
135 Point(0,0), Point(8,5),
136 Point(0,0), Point(8,5),
137 Point(4,1), Point(4,1)
145 Domain domain( Point(0,0), Point(8,5) );
154 board <<
SetMode(
"PointVector",
"Grid")
155 <<
SetMode(segment.className(),
"Points")
159 board <<
SetMode(segment.className(),
"BoundingBox")
164 board.
saveSVG(
"StandardDSS4.svg");
166 board.
saveCairo(
"StandardDSS4.png", Board2D::CairoPNG);
176 board <<
SetMode(
"PointVector",
"Both");
177 board <<
SetMode(segment.className(),
"Points")
181 board <<
SetMode(segment.className(),
"BoundingBox")
185 board.
saveSVG(
"StandardDSS4bis.svg");
187 board.
saveCairo(
"StandardDSS4bis.png", Board2D::CairoPNG);
197 void exampleConstructors()
237 std::vector<Point> r;
242 Point(0,0), Point(8,5),
243 Point(0,0), Point(8,5),
244 Point(3,1), Point(3,1)
247 if (!segment.isValid())
throw std::exception();
252 std::copy( segment.begin(), segment.end(), std::back_inserter(r) );
280 Point(0,0), Point(10,6),
281 Point(0,0), Point(8,5),
282 Point(3,1), Point(3,1)
287 if (!S.isValid())
throw std::exception();
299 Domain domain( Point(0,0), M );
303 board <<
SetMode(
"PointVector",
"Both");
304 board <<
SetMode(S.className(),
"Points")
306 <<
SetMode(S.className(),
"BoundingBox")
312 board <<
SetMode(M.className(),
"Both")
318 board.
saveSVG(
"NaiveDSS8ExtInit.svg");
320 board.
saveCairo(
"NaiveDSS8ExtInit.png", Board2D::CairoPNG);
326 bool resExtention = S.extendFront( M );
329 if (!resExtention)
throw std::exception();
338 Domain domain( Point(0,0), M );
342 board <<
SetMode(
"PointVector",
"Both");
343 board <<
SetMode(S.className(),
"Points")
345 <<
SetMode(S.className(),
"BoundingBox")
352 board.
saveSVG(
"NaiveDSS8ExtDone.svg");
354 board.
saveCairo(
"NaiveDSS8ExtDone.png", Board2D::CairoPNG);
360 bool resRetraction = S.retractFront();
363 if (!resRetraction)
throw std::exception();
370 if ( !S.equalsTo(copyOfS) )
throw std::exception();
378 int main(
int argc,
char** argv )
382 for (
int i = 0; i < argc; ++i )
387 exampleStandardDSS();
388 exampleConstructors();
void beginBlock(const std::string &keyword="")
ConstIterator begin() const
void drawArrow(double x1, double y1, double x2, double y2, bool filled=true, int depthValue=-1)
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
std::string className() const
Aim: This class is an alias of ArithmeticalDSS for naive DSL. It represents a naive digital straight ...
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 4-co...
void clear(const DGtal::Color &color=DGtal::Color::None)
DGtal is the top-level namespace which contains all DGtal functions and types.
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Structure representing an RGB triple with alpha component.
Aim: This class represents a standard digital straight segment (DSS), ie. the sequence of simply 8-co...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...