DGtal  1.0.0
Functions
lower-integer-convex-hull.cpp File Reference
#include "DGtal/base/Common.h"
#include "DGtal/arithmetic/LatticePolytope2D.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
Include dependency graph for lower-integer-convex-hull.cpp:

Go to the source code of this file.

Functions

void usage (int, char **argv)
 
int main (int argc, char **argv)
 

Detailed Description

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/02/06

An example file named lower-integer-convex-hull.

This file is part of the DGtal library.

Definition in file lower-integer-convex-hull.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Main.

[lower-integer-convex-hull-types]

[lower-integer-convex-hull-types]

[lower-integer-convex-hull-instantiation]

[lower-integer-convex-hull-instantiation]

[lower-integer-convex-hull-process]

[lower-integer-convex-hull-process]

[lower-integer-convex-hull-stats]

[lower-integer-convex-hull-stats]

Definition at line 67 of file lower-integer-convex-hull.cpp.

68 {
69  if ( argc < 4 )
70  {
71  usage( argc, argv );
72  return 0;
73  }
74 
76  using namespace Z2i;
77  typedef LatticePolytope2D<Space> CIP;
79 
81  CIP cip;
82  cip.push_front( Point( -10, -10 ) );
83  cip.push_front( Point( -10, 10 ) );
84  cip.push_front( Point( 10, 10 ) );
85  cip.push_front( Point( 10, -10 ) );
86  Domain domain = cip.boundingBoxDomain();
87  Board2D board;
88  board << domain
89  << CustomStyle( cip.className(),
90  new CustomColors( Color::Red, Color::None ) )
91  << cip;
92  board.saveEPS( "lower-integer-convex-hull.eps" );
93  board.clear();
95 
96  int a = atoi( argv[ 1 ] );
97  int b = atoi( argv[ 2 ] );
98  int c = atoi( argv[ 3 ] );
99 
101  typedef LatticePolytope2D<Z2>::HalfSpace HalfSpace;
102  HalfSpace hs( Vector( a, b ), c );
103  cip.cut( hs );
104  DigitalSet aSet( domain );
106  board << domain
107  << CustomStyle( aSet.className(),
108  new CustomColors( Color::Green, Color::Green ) )
109  << SetMode( Point().className(), "Grid" )
110  << aSet
111  << CustomStyle( cip.className(),
112  new CustomColors( Color::Red, Color::None ) )
113  << cip;
114  board.saveEPS( "lower-integer-convex-hull-cut.eps" );
116 
118  std::cout << "Number of vertices = " << cip.size() << std::endl;
119  std::cout << "Area = " << (((double)cip.twiceArea())/2.0) << std::endl;
120  std::cout << "Number of interior points = " << cip.numberInteriorPoints() << std::endl;
121  std::cout << "Number of boundary points = " << cip.numberBoundaryPoints() << std::endl;
123  return 0;
124 }
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
void push_front(const Point &K)
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
Domain domain
void usage(int, char **argv)
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
MyPointD Point
Definition: testClone2.cpp:383
Aim: A half-space specified by a vector N and a constant c. The half-space is the set .
FreemanChain< int >::Vector Vector
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: Represents a 2D polytope, i.e. a convex polygon, in the two-dimensional digital plane....
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::className(), LibBoard::Board::clear(), domain, DGtal::Color::Green, DGtal::Shapes< TDomain >::makeSetFromPointPredicate(), DGtal::Color::None, DGtal::LatticePolytope2D< TSpace, TSequence >::push_front(), DGtal::Color::Red, LibBoard::Board::saveEPS(), and usage().

◆ usage()

void usage ( int  ,
char **  argv 
)

Definition at line 57 of file lower-integer-convex-hull.cpp.

58 {
59  std::cerr << "Usage: " << argv[ 0 ] << " <a> <b> <c>" << std::endl;
60  std::cerr << "\t - Cuts a square by ax+by <= c. Displays everything in files "
61  << "lower-integer-convex-hull*.eps" << std::endl;
62 }

Referenced by main().