DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lower-integer-convex-hull.cpp
Go to the documentation of this file.
1
41
44
#include "DGtal/base/Common.h"
45
#include "DGtal/arithmetic/LatticePolytope2D.h"
46
#include "DGtal/io/boards/Board2D.h"
47
#include "DGtal/shapes/Shapes.h"
48
#include "DGtal/helpers/StdDefs.h"
50
52
53
using namespace
DGtal
;
54
56
57
void
usage
(
int
,
char
** argv )
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
}
63
67
int
main
(
int
argc,
char
** argv )
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
);
105
Shapes<Domain>::makeSetFromPointPredicate
( aSet, hs );
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
}
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color::Red
static const Color Red
Definition
Color.h:425
DGtal::Color::None
static const Color None
Definition
Color.h:421
DGtal::Color::Green
static const Color Green
Definition
Color.h:426
DGtal::DigitalSetByAssociativeContainer::className
std::string className() const
DGtal::LatticePolytope2D
Aim: Represents a 2D polytope, i.e. a convex polygon, in the two-dimensional digital plane....
Definition
LatticePolytope2D.h:83
DGtal::LatticePolytope2D::push_front
void push_front(const Point &K)
DGtal::LatticePolytope2D::HalfSpace
ClosedIntegerHalfPlane< Space > HalfSpace
Definition
LatticePolytope2D.h:98
DGtal::Shapes::makeSetFromPointPredicate
static void makeSetFromPointPredicate(DigitalSet &aSet, const PointPredicate &aPP)
DGtal::Point
DGtal::Domain
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition
Board.cpp:151
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition
Board2D.h:279
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
usage
void usage(int, char **argv)
Definition
testPolynomial.cpp:58
domain
Domain domain
Definition
testProjection.cpp:88
DigitalSet
Z2i::DigitalSet DigitalSet
Definition
testVoronoiMapComplete.cpp:40
examples
arithmetic
lower-integer-convex-hull.cpp
Generated on
for DGtal by
1.18.0