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"
{
trace.beginBlock (
"Example for 2d gridcurves" );
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();
Curve c;
auto points = c.getPointsRange();
std::vector<Point> T( points.begin(), points.end() );
auto c_cover = dconv.makeCellCover( T.begin(), T.end(), 1, 1 );
const float sx = -0.5;
const float sy = -0.5;
trace.beginBlock(
"Compute fully subconvex sets" );
for ( size_t i = 0; i < T.size(); ++i )
for ( size_t j = i+2; j < T.size(); ++j )
{
size_t k = (i+j)/2;
if ( ! dconv.isSimplexFullDimensional( { T[i], T[j], T[k] } ) ) continue;
auto triangle = dconv.makeSimplex( { T[i], T[j], T[k] } );
if ( dconv.isFullySubconvex( triangle, c_cover ) )
{
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;
return 0;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: A helper class to build polytopes from digital sets and to check digital k-convexity and full co...
ConstIterator end() const
ConstIterator begin() const
bool initFromPointsRange(const TIterator &itb, const TIterator &ite)
Board & setPenColor(const DGtal::Color &color)
void drawLine(double x1, double y1, double x2, double y2, int depthValue=-1)
Board & setPenColorRGBi(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.