Functions for testing class StabbingCircleComputer.
More...
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/shapes/ShapeFactory.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "DGtal/geometry/curves/CBidirectionalSegmentComputer.h"
#include "DGtal/geometry/curves/StabbingCircleComputer.h"
#include "DGtal/geometry/curves/SegmentComputerUtils.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
#include "DGtal/geometry/curves/SaturatedSegmentation.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/boards/CDrawableWithBoard2D.h"
#include "ConfigTest.h"
Go to the source code of this file.
Functions for testing class StabbingCircleComputer.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
- Author
- Tristan Roussillon (
trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr
) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
- Date
- 2011/09/26
This file is part of the DGtal library.
Definition in file testStabbingCircleComputer.cpp.
◆ ballGenerator()
template<typename TKSpace >
GridCurve<TKSpace> ballGenerator |
( |
double |
aCx, |
|
|
double |
aCy, |
|
|
double |
aR, |
|
|
bool |
aFlagIsCW |
|
) |
| |
Definition at line 70 of file testStabbingCircleComputer.cpp.
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() );
116 c.initFromVector(points2);
120 c.initFromVector(points);
127 <<
" error in finding a bel." << std::endl;
References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), domain, DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getLowerBound(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getUpperBound(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), and K.
◆ drawingTestStabbingCircleComputer()
template<typename TCurve >
bool drawingTestStabbingCircleComputer |
( |
const TCurve & |
curve, |
|
|
const string & |
suffix |
|
) |
| |
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 412 of file testStabbingCircleComputer.cpp.
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;
References DGtal::Trace::beginBlock(), drawingTestStabbingCircleComputer(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::GridCurve< TKSpace >::initFromVectorStream(), testRecognition(), testSegmentation(), testStabbingCircleComputer(), testStabbingCircleComputerConceptChecking(), and DGtal::trace.
◆ testRecognition()
Recogition of randomly generated digital circles
Definition at line 278 of file testStabbingCircleComputer.cpp.
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;
References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::longestSegment(), and DGtal::trace.
Referenced by main().
◆ testSegmentation()
template<typename TCurve >
bool testSegmentation |
( |
const TCurve & |
curve | ) |
|
Segmentations
Definition at line 336 of file testStabbingCircleComputer.cpp.
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;
References DGtal::SaturatedSegmentation< TSegmentComputer >::begin(), DGtal::Trace::beginBlock(), DGtal::SaturatedSegmentation< TSegmentComputer >::end(), DGtal::Trace::endBlock(), DGtal::Trace::info(), LibBoard::Board::saveSVG(), DGtal::SaturatedSegmentation< TSegmentComputer >::setMode(), and DGtal::trace.
Referenced by main().
◆ testStabbingCircleComputer()
template<typename TCurve >
bool testStabbingCircleComputer |
( |
const TCurve & |
curve | ) |
|
Basic methods
Definition at line 186 of file testStabbingCircleComputer.cpp.
189 typedef typename TCurve::IncidentPointsRange
Range;
193 unsigned int nbok = 0;
198 Range r = curve.getIncidentPointsRange();
210 trace.
info() << s4.isValid() << s4 << endl;
211 trace.
info() << s5.isValid() << s5 << endl;
214 &&(s2.
isValid())&&(s4.isValid())&&(s5.isValid())
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;
References DGtal::StabbingCircleComputer< TConstIterator >::begin(), DGtal::Trace::beginBlock(), DGtal::StabbingCircleComputer< TConstIterator >::end(), DGtal::Trace::endBlock(), DGtal::StabbingCircleComputer< TConstIterator >::extendBack(), DGtal::StabbingCircleComputer< TConstIterator >::extendFront(), DGtal::StabbingCircleComputer< TConstIterator >::getReverse(), DGtal::Trace::info(), DGtal::StabbingCircleComputer< TConstIterator >::init(), DGtal::StabbingCircleComputer< TConstIterator >::isExtendableFront(), DGtal::StabbingCircleComputer< TConstIterator >::isValid(), DGtal::longestSegment(), and DGtal::trace.
Referenced by main().
◆ testStabbingCircleComputerConceptChecking()
void testStabbingCircleComputerConceptChecking |
( |
| ) |
|
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
MyDigitalSurface::ConstIterator ConstIterator
bool drawingTestStabbingCircleComputer(const TCurve &curve, const string &suffix)
bool testStabbingCircleComputer(const TCurve &curve)
Aim: Represents a circle uniquely defined by three 2D points and that is able to return for any given...
ConstIterator begin() const
const Point & getUpperBound() const
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
bool initFromVectorStream(std::istream &in)
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
void attach(ConstAlias< EuclideanShape > shape)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
void beginBlock(const std::string &keyword="")
Aim: On-line recognition of a digital circular arcs (DCA) defined as a sequence of connected grid edg...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: The concept CDrawableWithBoard2D specifies what are the classes that admit an export with Board2...
Aim: Specific iterator to visit all the maximal segments of a saturated segmentation.
Aim: Model of the concept StarShaped represents any circle in the plane.
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....
const ConstIterator begin() const
const ConstIterator end() const
HyperRectDomain< Space > Domain
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
bool testSegmentation(const TCurve &curve)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Reverse getReverse() const
std::reverse_iterator< ConstIterator > ConstReverseIterator
SaturatedSegmentation< SegmentComputer > Segmentation
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
ConstIterator end() const
void testStabbingCircleComputerConceptChecking()
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
void init(const ConstIterator &anIt)
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
void longestSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &end, IteratorType)
Aim: Defines the concept describing a bidirectional segment computer, ie. a model of concepts::CSeg...
TConstIterator ConstIterator
const Point & getLowerBound() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...