This snippet shows how to identify and display digital fully subconvex sets of a grid curve form its tangent bundle.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "DGtal/geometry/volumes/DigitalConvexity.h"
#include "DGtal/io/boards/Board2D.h"
using namespace std;
using namespace Z2i;
int main(
int argc,
char** argv )
{
string S = examplesPath + "samples/contourS.fc";
const Point lowerBound( -200, -200 );
const Point upperBound( 200, 200 );
fstream inputStream( S.c_str(), ios::in );
inputStream.close();
c.initFromPointsRange( fc.
begin(), fc.
end() );
auto points = c.getPointsRange();
std::vector<Point> T( points.begin(), points.end() );
aBoard.
setUnit(Board2D::UCentimeter);
const float sx = -0.5;
const float sy = -0.5;
for ( unsigned int i = 0; i < T.size(); ++i )
for ( unsigned int j = i+2; j < T.size(); ++j )
{
unsigned int k = (i+j)/2;
auto triangle = dconv.
makeSimplex( { T[i], T[j], T[k] } );
{
aBoard.
drawLine( sx+(
float)T[i][0], sy+(float)T[i][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
aBoard.
drawLine( sx+(
float)T[i][0], sy+(float)T[i][1],
sx+(float)T[k][0], sy+(float)T[k][1] );
aBoard.
drawLine( sx+(
float)T[k][0], sy+(float)T[k][1],
sx+(float)T[j][0], sy+(float)T[j][1] );
}
else
j = T.size();
}
aBoard << c;
aBoard.
saveEPS(
"myGridCurve.eps", Board2D::BoundingBox );
return 0;
}