32#include "DGtal/base/Common.h"
33#include "DGtal/kernel/PointVector.h"
34#include "DGtal/topology/KhalimskySpaceND.h"
35#include "DGtal/geometry/curves/GridCurve.h"
37#include "DGtal/geometry/curves/CBidirectionalSegmentComputer.h"
39#include "DGtal/geometry/curves/StabbingLineComputer.h"
41#include "DGtal/geometry/curves/GreedySegmentation.h"
42#include "DGtal/geometry/curves/SaturatedSegmentation.h"
44#include "DGtal/io/boards/Board2D.h"
45#include "DGtal/io/boards/CDrawableWithBoard2D.h"
47#include "ConfigTest.h"
60template <
typename TCurve>
64 typedef typename TCurve::IncidentPointsRange
Range;
68 unsigned int nbok = 0;
73 Range r = curve.getIncidentPointsRange();
90 &&(s2 == s4)&&(s3 != s5)&&(s1 == s3)&&(s2 != s5);
92 nbok += myFlag ? 1 : 0;
99 Range r = curve.getIncidentPointsRange();
103 trace.
info() <<
"forward extension " << endl;
107 while ( (s.end() != itEnd) && (s.isExtendableFront()) && (s.extendFront()) ) {}
110 s.getParameters(a,b,c);
111 trace.
info() << a <<
" " << b <<
" " << c << endl;
113 t.init( (itBegin + (itEnd - itBegin)/2) );
114 while ( (t.end() != itEnd) && (t.extendFront())
115 && (t.begin() != itBegin) && (t.extendBack()) ) {}
118 trace.
info() <<
"backward extension " << endl;
120 ConstReverseIterator ritBegin (t.end());
121 ConstReverseIterator ritEnd (r.rend());
127 trace.
info() << ap <<
" " << bp <<
" " << cp << endl;
130 rt.
init( (ritBegin + (ritEnd - ritBegin)/2) );
135 trace.
info() <<
"comparison... " << endl;
136 bool myFlag = ( (s == t)&&(rs == rt) )
137 && ( s.Uf() == rs.
Uf() )
138 && ( s.Ul() == rs.
Ul() )
139 && ( s.Lf() == rs.
Lf() )
140 && ( s.Ll() == rs.
Ll() )
146 nbok += myFlag ? 1 : 0;
151 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
158template <
typename TCurve>
162 typedef typename TCurve::IncidentPointsRange
Range;
165 Range r = curve.getIncidentPointsRange();
170 while ( (s.end() != itEnd) && (s.extendFront()) ) {}
173 s.getParameters(a,b,c);
177 board.
saveEPS(
"StabbingLineComputerdrawingTest.eps");
190template <
typename TCurve>
194 typedef typename TCurve::IncidentPointsRange
Range;
195 Range r = curve.getIncidentPointsRange();
200 unsigned int nbok = 0;
215 unsigned int suml = 0;
216 for ( ; it != itEnd; ++it, ++n) {
222 board.
saveEPS(
"StabbingLineComputerGreedySegmentationTest.eps", Board2D::BoundingBox, 5000 );
224 trace.
info() << r.size() <<
";" << n <<
";" << suml << endl;
226 nbok += ((r.size()==85)&&(n==10)&&(suml==94)) ? 1 : 0;
242 unsigned int suml = 0;
243 for ( ; it != itEnd; ++it, ++n) {
249 board.
saveEPS(
"StabbingLineComputerSaturatedSegmentationTest.eps", Board2D::BoundingBox, 5000 );
251 trace.
info() << r.size() <<
";" << n <<
";" << suml << endl;
253 nbok += ((r.size()==85)&&(n==25)&&(suml==255)) ? 1 : 0;
259 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
265int main(
int argc,
char** argv )
269 for (
int i = 0; i < argc; ++i )
280 std::string filename = testPath +
"samples/DSS.dat";
282 instream.open (filename.c_str(), ifstream::in);
293 std::string filename = testPath +
"samples/sinus2D4.dat";
295 instream.open (filename.c_str(), ifstream::in);
304 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
bool initFromVectorStream(std::istream &in)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Specific iterator to visit all the maximal segments of a saturated segmentation.
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
SaturatedSegmentation::SegmentComputerIterator end() const
SaturatedSegmentation::SegmentComputerIterator begin() const
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
TConstIterator ConstIterator
std::reverse_iterator< ConstIterator > ConstReverseIterator
Aim: On-line recognition of a digital straight segment (DSS) defined as a sequence of connected grid ...
Reverse getReverse() const
ConstIterator end() const
ConstIterator begin() const
void init(const ConstIterator &anIt)
void getParameters(double &alpha, double &beta, double &gamma) const
void beginBlock(const std::string &keyword="")
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing a bidirectional segment computer, ie. a model of concepts::CSeg...
Aim: The concept CDrawableWithBoard2D specifies what are the classes that admit an export with Board2...
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
SaturatedSegmentation< SegmentComputer > Segmentation
void testStabbingLineComputerConceptChecking()
bool drawingTestStabbingLineComputer(const TCurve &curve)
bool testStabbingLineComputer(const TCurve &curve)