32#include "DGtal/base/Common.h"
35#include "DGtal/kernel/SpaceND.h"
36#include "DGtal/kernel/domains/HyperRectDomain.h"
37#include "DGtal/topology/KhalimskySpaceND.h"
40#include "DGtal/shapes/ShapeFactory.h"
41#include "DGtal/shapes/Shapes.h"
42#include "DGtal/topology/helpers/Surfaces.h"
43#include "DGtal/shapes/GaussDigitizer.h"
44#include "DGtal/geometry/curves/GridCurve.h"
47#include "DGtal/geometry/curves/CBidirectionalSegmentComputer.h"
49#include "DGtal/geometry/curves/StabbingCircleComputer.h"
51#include "DGtal/geometry/curves/SegmentComputerUtils.h"
52#include "DGtal/geometry/curves/GreedySegmentation.h"
53#include "DGtal/geometry/curves/SaturatedSegmentation.h"
56#include "DGtal/io/boards/Board2D.h"
57#include "DGtal/io/boards/CDrawableWithBoard2D.h"
59#include "ConfigTest.h"
69template<
typename TP,
typename TI>
79template<
typename TKSpace,
typename Integer>
96 std::vector<Point> points, points2;
101 points2.assign( points.rbegin(), points.rend() );
112 <<
" error in finding a bel." << std::endl;
132template <
typename TCurve>
136 typedef typename TCurve::IncidentPointsRange
Range;
137 Range r = curve.getIncidentPointsRange();
146 std::stringstream ss;
147 ss <<
"StabbingCircleComputerDrawingTest" << suffix <<
".eps";
148 board.
saveEPS(ss.str().c_str());
158 std::stringstream ss;
159 ss <<
"StabbingCircleComputerDrawingTest" << suffix <<
"2.eps";
160 board.
saveEPS(ss.str().c_str());
169template <
typename TCurve>
173 typedef typename TCurve::IncidentPointsRange
Range;
177 unsigned int nbok = 0;
180 trace.beginBlock (
"Constructors, copy, assignement" );
182 Range r = curve.getIncidentPointsRange();
199 &&(s2 == s4)&&(s2 != s5)&&(s2 != s1)
200 &&(s3 != s5)&&(s1 == s3);
202 nbok += myFlag ? 1 : 0;
208 trace.beginBlock (
"Extension operations" );
210 Range r = curve.getIncidentPointsRange();
214 trace.info() <<
"forward extension " << endl;
221 trace.info() << s << endl;
227 trace.info() << t << endl;
229 trace.info() <<
"backward extension " << endl;
232 ConstReverseIterator ritBegin ( s.
end() );
233 ConstReverseIterator ritEnd ( itBegin );
237 trace.info() << rs << endl;
239 ConstReverseIterator ritLast (rs.
end()); --ritLast;
244 trace.info() << rt << endl;
246 trace.info() <<
"comparison... " << endl;
247 bool myFlag = (s == t)
250 nbok += myFlag ? 1 : 0;
255 trace.info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
269 unsigned int nbok = 0;
272 trace.beginBlock (
"Recognition" );
275 for (
unsigned int i = 1; i < 200 && flag; ++i)
278 KSpace kspace( Point::diagonal(-2*radius), Point::diagonal(2*radius),
true );
281 trace.info() <<
" #ball c(0,0) r=" << radius
282 <<
" cw=" << ((i%2)==0) << endl;
295 trace.info()<<
"Complete circle not recognized"<<std::endl;
307 flag = ( p1(it->first)&&p2(it->second) );
312 << it->second << std::endl;
317 nbok += flag ? 1 : 0;
323 trace.info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
330template <
typename TCurve>
334 typedef typename TCurve::IncidentPointsRange
Range;
335 Range r = curve.getIncidentPointsRange();
340 unsigned int nbok = 0;
343 trace.beginBlock (
"Greedy segmentation" );
351 typename Segmentation::SegmentComputerIterator it = theSegmentation.
begin();
352 typename Segmentation::SegmentComputerIterator itEnd = theSegmentation.
end();
354 unsigned int suml = 0;
355 for ( ; it != itEnd; ++it, ++n) {
364 trace.info() << r.size() <<
";" << n <<
";" << suml << endl;
366 bool flag = ((r.size()==85)&&(n==6)&&(suml==90)&&((r.size()+n-1)==suml));
367 nbok += flag ? 1 : 0;
372 trace.beginBlock (
"Saturated segmentation" );
376 theSegmentation.
setMode(
"Last");
381 typename Segmentation::SegmentComputerIterator it = theSegmentation.
begin();
382 typename Segmentation::SegmentComputerIterator itEnd = theSegmentation.
end();
384 unsigned int suml = 0;
385 for ( ; it != itEnd; ++it, ++n) {
394 trace.info() << r.size() <<
";" << n <<
";" << suml << endl;
396 nbok += ((r.size()==85)&&(n==20)&&(suml==326)) ? 1 : 0;
401 trace.info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
407int main(
int argc,
char** argv )
409 trace.beginBlock (
"Testing class StabbingCircleComputer" );
410 trace.info() <<
"Args:";
411 for (
int i = 0; i < argc; ++i )
412 trace.info() <<
" " << argv[ i ];
413 trace.info() << endl;
424 KSpace kspace(Point::diagonal(-10),Point::diagonal(10),
true);
439 std::string filename = testPath +
"samples/sinus2D4.dat";
441 instream.open (filename.c_str(), ifstream::in);
450 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
407int main(
int argc,
char** argv ) {
…}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: Represents a circle uniquely defined by three 2D points and that is able to return for any given...
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 initFromPointsVector(const std::vector< Point > &aVectorOfPoints)
bool initFromVectorStream(std::istream &in)
IncidentPointsRange getIncidentPointsRange() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
PointVector< dim, Integer > Point
SignedKhalimskyCell< dim, Integer > SCell
SpaceND< dim, Integer > Space
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
SaturatedSegmentation::SegmentComputerIterator end() const
void setMode(const std::string &aMode)
SaturatedSegmentation::SegmentComputerIterator begin() const
boost::reverse_iterator< ConstIterator > ConstReverseIterator
ConstIterator ConstIterator
PointVector< dim, Integer > Point
Aim: On-line recognition of a digital circular arcs (DCA) defined as a sequence of connected grid edg...
ConstIterator begin() const
void init(const ConstIterator &anIt)
Reverse getReverse() const
Circle getSeparatingCircle() const
ConstIterator end() const
StabbingCircleComputer< ReverseIterator< ConstIterator > > Reverse
static void track2DBoundaryPoints(std::vector< Point > &aVectorOfPoints, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Aim: Predicate returning 'true' iff a given point is in the 'interior' of a given shape,...
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Point::Coordinate Integer
DGtal is the top-level namespace which contains all DGtal functions and types.
void longestSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &end, IteratorType)
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
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...
MyBallPredicate(const Integer &aR)
bool operator()(const Point &aP) const
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
SaturatedSegmentation< SegmentComputer > Segmentation
bool drawingTestStabbingCircleComputer(const TCurve &curve, const string &suffix)
void testStabbingCircleComputerConceptChecking()
void ballGenerator(const TKSpace &aKSpace, GridCurve< TKSpace > &aGC, const Integer &aR, const bool &aFlagIsCW)
bool testStabbingCircleComputer(const TCurve &curve)