#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/base/IteratorCirculatorTraits.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/tools/Hull2DHelpers.h"
#include "DGtal/geometry/tools/PolarPointComparatorBy2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
#include "DGtal/shapes/ShapeFactory.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/topology/DigitalSetBoundary.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/graph/DepthFirstVisitor.h"
#include "DGtal/io/boards/Board2D.h"
template <typename ForwardIterator, typename Board>
void drawPolygon(
const ForwardIterator& itb,
const ForwardIterator& ite,
Board& aBoard, bool isClosed = true)
{
ForwardIterator it = itb;
if (it != ite)
{
aBoard <<
SetMode( p.className(),
"Grid" )
<< p
for (++it; it != ite; ++it, prev = p)
{
p = *it;
aBoard << p;
if (prev != p)
aBoard.drawArrow(prev[0], prev[1], p[0], p[1]);
}
if (isClosed)
{
if (prev != p1)
aBoard.drawArrow(prev[0], prev[1], p1[0], p1[1]);
}
}
}
{
using namespace functions::Hull2D;
{
vector<Z2i::Point> res;
StrictPredicate predicate( functor );
andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate );
trace.
info() <<
" ConvexHull HV thickness: " << th << std::endl;
board.
drawCircle( antipodalS[0], antipodalS[1], 0.2) ;
board.
drawCircle(antipodalP[0], antipodalP[1], 0.2);
board.
drawCircle(antipodalQ[0], antipodalQ[1], 0.2);
board.
drawLine(antipodalP[0], antipodalP[1], antipodalQ[0], antipodalQ[1]);
board.
saveSVG(
"ConvexHullCCW.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"ConvexHullCCW.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> res;
LargePredicate predicate( functor );
board.
saveSVG(
"ConvexHullCCWWithPointsOnEdges.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"ConvexHullCCWWithPointsOnEdges.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> res;
StrictPredicate predicate( functor );
board.
saveSVG(
"ConvexHullCW.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"ConvexHullCW.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> res;
StrictPredicate predicate( functor );
board.
saveSVG(
"ConvexHullCCWbis.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"ConvexHullCCWbis.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> polygonalLine;
vector<Z2i::Point> resGraham, res;
StrictPredicate predicate( functor );
for (std::vector<Z2i::Point>::const_iterator
it = polygonalLine.begin(),
itEnd = polygonalLine.end();
it != itEnd; ++it)
drawPolygon( polygonalLine.begin(), polygonalLine.end(), board,
true );
board.
saveSVG(
"SimplePolygonalLine.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"SimplePolygonalLine.png", Board2D::CairoPNG);
#endif
drawPolygon( resGraham.begin(), resGraham.end(), board );
board.
saveSVG(
"SimplePolygonalLineGraham.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"SimplePolygonalLineGraham.png", Board2D::CairoPNG);
#endif
board.
saveSVG(
"SimplePolygonalLineMelkman.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"SimplePolygonalLineMelkman.png", Board2D::CairoPNG);
#endif
board.
saveSVG(
"SimplePolygonalLineMelkman2.svg" );
#ifdef WITH_CAIRO
board.
saveCairo(
"SimplePolygonalLineMelkman2.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> res;
std::copy( pointSet.begin(), pointSet.end(), back_inserter( res ) );
std::sort( res.begin(), res.end() );
#ifdef WITH_CAIRO
board.
saveCairo(
"AndrewWEVP.png", Board2D::CairoPNG);
#endif
}
{
vector<Z2i::Point> res;
std::copy( pointSet.begin(), pointSet.end(), back_inserter( res ) );
std::vector<Z2i::Point>::iterator itMax
= std::max_element( res.begin(), res.end() );
std::sort( res.begin(), res.end(), comparator );
#ifdef WITH_CAIRO
board.
saveCairo(
"GrahamWEVP.png", Board2D::CairoPNG);
#endif
}
}
int main(
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
return 0;
}
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
Aim: Class that implements a binary point predicate, which is able to compare the position of two giv...
void setPole(const Point &aPole)
Board & setPenColor(const DGtal::Color &color)
void drawLine(double x1, double y1, double x2, double y2, int depthValue=-1)
void clear(const DGtal::Color &color=DGtal::Color::None)
void drawCircle(double x, double y, double radius, int depthValue=-1)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
void drawPolygon(const ForwardIterator &itb, const ForwardIterator &ite, Board &aBoard, bool isClosed=true)
void andrewConvexHullAlgorithm(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate)
Procedure that retrieves the vertices of the hull of a set of 2D points given by the range [ itb ,...
void closedGrahamScanFromAnyPoint(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate)
Procedure that retrieves the vertices of the convex hull of a weakly externally visible polygon (WEVP...
double computeHullThickness(const ForwardIterator &itb, const ForwardIterator &ite, const ThicknessDefinition &def)
Procedure to compute the convex hull thickness given from different definitions (Horizontal/vertical ...
void melkmanConvexHullAlgorithm(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, Functor &aFunctor)
Procedure that retrieves the vertices of the hull of a set of 2D points given by the range [ itb ,...
@ HorizontalVerticalThickness
void grahamConvexHullAlgorithm(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, const Predicate &aPredicate, PolarComparator &aPolarComparator)
Procedure that retrieves the vertices of the convex hull of a set of 2D points given by the range [ i...
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/ForwardTraversal.html.
Go to http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/ReadableIterator.html.
DGtal::MelkmanConvexHull< Point, Functor > ch
InHalfPlaneBySimple3x3Matrix< Point, double > Functor