43#include "DGtal/base/Common.h"
44#include "DGtal/helpers/StdDefs.h"
45#include "ConfigExamples.h"
47#include "DGtal/geometry/curves/FreemanChain.h"
48#include "DGtal/geometry/curves/GridCurve.h"
50#include "DGtal/topology/helpers/Surfaces.h"
51#include "DGtal/io/boards/Board2D.h"
78int main(
int argc,
char** argv )
80 trace.beginBlock (
"Example for 2d gridcurves" );
81 trace.info() <<
"Args:";
82 for (
int i = 0; i < argc; ++i )
83 trace.info() <<
" " << argv[ i ];
86 string square = examplesPath +
"samples/smallSquare.dat";
87 string S = examplesPath +
"samples/contourS.fc";
90 Point lowerBound( -50, -50 );
91 Point upperBound( 50, 50 );
98 K2 ks; ks.
init( lowerBound, upperBound,
true );
102 trace.emphase() <<
"Input" << endl;
103 trace.info() <<
"\t from a data file " << endl;
107 inputStream.open (square.c_str(), ios::in);
112 trace.info() <<
"\t from a digital set " << endl;
121 if ( (*it - o ).norm1() <= 30 ) set.insertNew( *it );
125 vector<SCell> contour;
135 trace.info() <<
"\t from a FreemanChain (from a file) " << endl;
138 inputStream.open (S.c_str(), ios::in);
149 trace.emphase() <<
"Output" << endl;
150 trace.info() <<
"\t standard output " << endl;
153 trace.info() << c1 << std::endl;
156 trace.info() <<
"\t into a data file " << endl;
159 ofstream outputStream(
"myGridCurve.dat");
160 if (outputStream.is_open())
162 outputStream.close();
165 trace.info() <<
"\t into a vector graphics file " << endl;
175 trace.info() <<
"\t into a FreemanChain " << endl;
181 trace.info() <<
"\t" << fc << endl;
185 trace.emphase() <<
"Ranges Ouput" << endl;
197 trace.info() << r << endl;
199 aBoard <<
SetMode(aDomain.className(),
"Grid") << aDomain;
208 trace.info() << r << endl;
210 aBoard <<
SetMode(aDomain.className(),
"Grid") << aDomain;
219 trace.info() << r << endl;
223 trace.emphase() <<
"Ranges Iterators" << endl;
229 trace.info() <<
"\t iterate over the range" << endl;
232 for ( ; it != itEnd; ++it)
236 trace.info() << endl;
238 trace.info() <<
"\t iterate over the range in the reverse way" << endl;
241 for ( ; rit != ritEnd; ++rit)
243 trace.info() << *rit;
245 trace.info() << endl;
247 trace.info() <<
"\t iterate over the range in a circular way" << endl;
250 for (
unsigned i = 0; i < 20; ++i) ++c;
258 trace.info() << endl;
261 trace.info() <<
"\t Generic function working with any (circular)iterator" << endl;
78int main(
int argc,
char** argv ) {
…}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
ConstIterator end() const
ConstIterator begin() const
static void readFromPointsRange(const TConstIterator &itBegin, const TConstIterator &itEnd, FreemanChain &c)
ConstRangeAdapter< typename Storage::const_iterator, functors::Identity, SCell > SCellsRange
SCellsRange getSCellsRange() const
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToCode< KSpace >, char > CodesRange
IncidentPointsRange getIncidentPointsRange() const
bool initFromSCellsVector(const std::vector< SCell > &aVectorOfSCells)
void writeVectorToStream(std::ostream &out)
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
bool initFromPointsRange(const TIterator &itb, const TIterator &ite)
GridCurve::CodesRange getCodesRange() const
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
boost::reverse_iterator< ConstIterator > ConstReverseIterator
DGtal::Circulator< ConstIterator > ConstCirculator
ConstIterator ConstIterator
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
static void track2DBoundary(std::vector< SCell > &aSCellContour2D, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void displayAll(const CI &ciBegin, const CI &ciEnd)
[GridCurveGenericFunctionDisplayAll]
Z2i this namespace gathers the standard of types for 2D imagery.
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
DGtal is the top-level namespace which contains all DGtal functions and types.
bool isNotEmpty(const IC &itb, const IC &ite)
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....