43#include "DGtal/base/Common.h"
44#include "DGtal/base/IteratorCirculatorTraits.h"
45#include "DGtal/helpers/StdDefs.h"
48#include "DGtal/geometry/tools/Hull2DHelpers.h"
50#include "DGtal/geometry/tools/PolarPointComparatorBy2x2DetComputer.h"
51#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
52#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
53#include "DGtal/geometry/tools/determinant/InGeneralizedDiskOfGivenRadius.h"
55#include "DGtal/shapes/ShapeFactory.h"
56#include "DGtal/shapes/Shapes.h"
58#include "DGtal/topology/DigitalSetBoundary.h"
59#include "DGtal/topology/DigitalSurface.h"
60#include "DGtal/graph/DepthFirstVisitor.h"
62#include "DGtal/io/boards/Board2D.h"
78template <
typename ForwardIterator,
typename Board>
79void drawPolygon(
const ForwardIterator& itb,
const ForwardIterator& ite,
80 Board& aBoard,
bool isClosed =
true)
86 ForwardIterator it = itb;
92 aBoard <<
SetMode( p.className(),
"Grid" )
98 for (++it; it != ite; ++it, prev = p)
105 aBoard.drawArrow(prev[0], prev[1], p[0], p[1]);
112 aBoard.drawArrow(prev[0], prev[1], p1[0], p1[1]);
137 DigitalSurfaceContainer digitalSurfaceContainer( kspace, digitalSet );
138 CustomDigitalSurface digitalSurface( digitalSurfaceContainer );
143 CustomVisitor visitor( digitalSurface, *digitalSurface.begin() );
144 while ( ! visitor.finished() )
146 gridCurve.
pushBack( visitor.current().first );
153 vector<Z2i::Point> border;
154 unique_copy( pointsRange.begin(), pointsRange.end(), back_inserter( border ) );
157 using namespace functions::Hull2D;
161 vector<Z2i::Point> res;
168 Predicate predicate( functor );
172 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
178 board.
saveSVG(
"AlphaShape0.svg" );
180 board.
saveCairo(
"AlphaShape0.png", Board2D::CairoPNG);
187 vector<Z2i::Point> res;
193 Predicate predicate( functor );
195 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
200 board.
saveSVG(
"AlphaShape0bis.svg" );
202 board.
saveCairo(
"AlphaShape0bis.png", Board2D::CairoPNG);
210 vector<Z2i::Point> res;
218 Predicate predicate( functor );
220 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
225 board.
saveSVG(
"AlphaShapeM1.svg" );
227 board.
saveCairo(
"AlphaShapeM1.png", Board2D::CairoPNG);
233 trace.
info() <<
" alpha == -sqrt(5) " << endl;
234 vector<Z2i::Point> res;
242 Predicate predicate( functor );
244 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
249 board.
saveSVG(
"AlphaShapeMSqrt5.svg" );
251 board.
saveCairo(
"AlphaShapeMSqrt5.png", Board2D::CairoPNG);
258 vector<Z2i::Point> res;
266 Predicate predicate( functor );
268 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
273 board.
saveSVG(
"AlphaShapeM5.svg" );
275 board.
saveCairo(
"AlphaShapeM5.png", Board2D::CairoPNG);
283 vector<Z2i::Point> res;
290 Predicate predicate( functor );
293 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
298 board.
saveSVG(
"AlphaShapeP8.svg" );
300 board.
saveCairo(
"AlphaShapeP8.png", Board2D::CairoPNG);
308 vector<Z2i::Point> res;
316 Predicate predicate( functor );
318 closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate );
323 board.
saveSVG(
"AlphaShapeP9.svg" );
325 board.
saveCairo(
"AlphaShapeP9.png", Board2D::CairoPNG);
339int main(
int argc,
char** argv )
343 for (
int i = 0; i < argc; ++i )
Aim: Model of the concept StarShaped represents any circle in the plane.
RealPoint getUpperBound() const
RealPoint getLowerBound() const
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
void pushBack(const SCell &aSCell)
InnerPointsRange getInnerPointsRange() const
const Point & lowerBound() const
const Point & upperBound() const
Aim: This class implements an orientation functor that provides a way to determine the position of ...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
void beginBlock(const std::string &keyword="")
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
std::vector< Point > PointRange
void drawPolygon(const ForwardIterator &itb, const ForwardIterator &ite, Board &aBoard, bool isClosed=true)
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.
InHalfPlaneBySimple3x3Matrix< Point, double > Functor