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"
56 using namespace DGtal;
61 template <
typename CI>
64 if ( isNotEmpty(ciBegin, ciEnd) )
78 int main(
int argc,
char** argv )
82 for (
int i = 0; i < argc; ++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 );
103 trace.
info() <<
"\t from a data file " << endl;
107 inputStream.open (square.c_str(), ios::in);
108 c1.initFromVectorStream(inputStream);
112 trace.
info() <<
"\t from a digital set " << endl;
121 if ( (*it - o ).norm1() <= 30 ) set.
insertNew( *it );
125 vector<SCell> contour;
131 c2.initFromSCellsVector( contour );
135 trace.
info() <<
"\t from a FreemanChain (from a file) " << endl;
138 inputStream.open (S.c_str(), ios::in);
144 c.initFromPointsRange( fc.
begin(), fc.
end() );
150 trace.
info() <<
"\t standard output " << endl;
156 trace.
info() <<
"\t into a data file " << endl;
159 ofstream outputStream(
"myGridCurve.dat");
160 if (outputStream.is_open())
161 c2.writeVectorToStream(outputStream);
162 outputStream.close();
165 trace.
info() <<
"\t into a vector graphics file " << endl;
169 aBoard.
setUnit(Board2D::UCentimeter);
171 aBoard.
saveEPS(
"myGridCurve.eps", Board2D::BoundingBox, 5000 );
175 trace.
info() <<
"\t into a FreemanChain " << endl;
180 FreemanChain::readFromPointsRange( c1.getPointsRange(), fc );
188 aBoard.
setUnit(Board2D::UCentimeter);
195 Curve::SCellsRange r = c1.getSCellsRange();
201 aBoard.
saveEPS(
"My1CellsRange.eps", Board2D::BoundingBox, 5000 );
206 Curve::IncidentPointsRange r = c1.getIncidentPointsRange();
212 aBoard.
saveEPS(
"MyIncidentPointsRange.eps", Board2D::BoundingBox, 5000 );
217 Curve::CodesRange r = c1.getCodesRange();
225 typedef Curve::CodesRange
Range;
226 Range r = c1.getCodesRange();
229 trace.
info() <<
"\t iterate over the range" << endl;
232 for ( ; it != itEnd; ++it)
238 trace.
info() <<
"\t iterate over the range in the reverse way" << endl;
241 for ( ; rit != ritEnd; ++rit)
247 trace.
info() <<
"\t iterate over the range in a circular way" << endl;
250 for (
unsigned i = 0; i < 20; ++i) ++c;
261 trace.
info() <<
"\t Generic function working with any (circular)iterator" << endl;
262 displayAll<Range::ConstIterator>(r.begin(),r.end());
263 displayAll<Range::ConstReverseIterator>(r.rbegin(),r.rend());
264 displayAll<Range::ConstCirculator>(r.c(),r.c());