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"
68template<
typename TKSpace>
91 dig.
init( xLow, xUp, 1 );
99 <<
" error in creating KSpace." << std::endl;
109 std::vector<Point> points, points2;
115 points2.assign( points.rbegin(), points.rend() );
120 c.initFromVector(points);
127 <<
" error in finding a bel." << std::endl;
148template <
typename TCurve>
152 typedef typename TCurve::IncidentPointsRange
Range;
153 Range r = curve.getIncidentPointsRange();
162 std::stringstream ss;
163 ss <<
"StabbingCircleComputerDrawingTest" << suffix <<
".eps";
164 board.
saveEPS(ss.str().c_str());
174 std::stringstream ss;
175 ss <<
"StabbingCircleComputerDrawingTest" << suffix <<
"2.eps";
176 board.
saveEPS(ss.str().c_str());
185template <
typename TCurve>
189 typedef typename TCurve::IncidentPointsRange
Range;
193 unsigned int nbok = 0;
198 Range r = curve.getIncidentPointsRange();
215 &&(s2 == s4)&&(s2 != s5)&&(s2 != s1)
216 &&(s3 != s5)&&(s1 == s3);
218 nbok += myFlag ? 1 : 0;
226 Range r = curve.getIncidentPointsRange();
230 trace.
info() <<
"forward extension " << endl;
236 while ( (s.end() != itEnd) && (s.isExtendableFront()) && (s.extendFront()) ) {}
242 while ( (t.begin() != itBegin) && (t.extendBack()) ) {}
245 trace.
info() <<
"backward extension " << endl;
248 ConstReverseIterator ritBegin ( s.end() );
249 ConstReverseIterator ritEnd ( itBegin );
255 ConstReverseIterator ritLast (rs.
end()); --ritLast;
262 trace.
info() <<
"comparison... " << endl;
263 bool myFlag = (s == t)
266 nbok += myFlag ? 1 : 0;
271 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
284 unsigned int nbok = 0;
289 for (
unsigned int i = 0; i < 50; ++i)
292 double cx = (rand()%100 ) / 100.0;
293 double cy = (rand()%100 ) / 100.0;
294 double radius = (rand()%100 )+100;
295 c = ballGenerator<KSpace>( cx, cy, radius, ((i%2)==1) );
296 trace.
info() <<
" #ball #" << i <<
" c(" << cx <<
"," << cy <<
") r=" << radius << endl;
300 Range r = c.getIncidentPointsRange();
314 for (
ConstIterator it = s.begin(); ((it != s.end()) && flag) ; ++it)
316 FirstInCirclePred p1( s.getSeparatingCircle() );
317 SecondInCirclePred p2( s.getSeparatingCircle() );
318 flag = ( p1(it->first)&&p2(it->second) );
322 nbok += flag ? 1 : 0;
328 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
335template <
typename TCurve>
339 typedef typename TCurve::IncidentPointsRange
Range;
340 Range r = curve.getIncidentPointsRange();
345 unsigned int nbok = 0;
359 unsigned int suml = 0;
360 for ( ; it != itEnd; ++it, ++n) {
367 board.
saveSVG(
"StabbingCircleComputerGreedySegmentationTest.svg", Board2D::BoundingBox, 5000 );
369 trace.
info() << r.size() <<
";" << n <<
";" << suml << endl;
371 bool flag = ((r.size()==85)&&(n==6)&&(suml==90)&&((r.size()+n-1)==suml));
372 nbok += flag ? 1 : 0;
381 theSegmentation.
setMode(
"Last");
389 unsigned int suml = 0;
390 for ( ; it != itEnd; ++it, ++n) {
397 board.
saveSVG(
"StabbingCircleComputerSaturatedSegmentationTest.svg", Board2D::BoundingBox, 5000 );
399 trace.
info() << r.size() <<
";" << n <<
";" << suml << endl;
401 nbok += ((r.size()==85)&&(n==20)&&(suml==326)) ? 1 : 0;
406 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
412int main(
int argc,
char** argv )
416 for (
int i = 0; i < argc; ++i )
430 c = ballGenerator<KSpace>(0,0,6,
false);
431 std::vector<PointVector<2,int> > rv;
432 rc = ballGenerator<KSpace>(0,0,6,
true);
444 std::string filename = testPath +
"samples/sinus2D4.dat";
446 instream.open (filename.c_str(), ifstream::in);
455 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Model of the concept StarShaped represents any circle in the plane.
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: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
const Point & getUpperBound() const
void attach(ConstAlias< EuclideanShape > shape)
const Point & getLowerBound() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
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)
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
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
void setMode(const std::string &aMode)
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 circular arcs (DCA) defined as a sequence of connected grid edg...
ConstIterator begin() const
void init(const ConstIterator &anIt)
Reverse getReverse() const
ConstIterator end() const
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...
void beginBlock(const std::string &keyword="")
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
MyDigitalSurface::ConstIterator ConstIterator
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....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
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
HyperRectDomain< Space > Domain
bool drawingTestStabbingCircleComputer(const TCurve &curve, const string &suffix)
void testStabbingCircleComputerConceptChecking()
bool testStabbingCircleComputer(const TCurve &curve)
GridCurve< TKSpace > ballGenerator(double aCx, double aCy, double aR, bool aFlagIsCW)