DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
tests
shapes
testHalfPlane.cpp
1
34
#include <cstdio>
35
#include <cmath>
36
#include <fstream>
37
#include <vector>
38
#include <iostream>
39
#include <iterator>
40
41
42
43
44
#include "DGtal/base/Common.h"
45
#include "DGtal/base/Exceptions.h"
46
#include "DGtal/kernel/SpaceND.h"
47
#include "DGtal/kernel/domains/DomainPredicate.h"
48
#include "DGtal/kernel/domains/HyperRectDomain.h"
49
#include "DGtal/io/boards/Board2D.h"
50
51
#include "DGtal/shapes/fromPoints/StraightLineFrom2Points.h"
52
#include "DGtal/shapes/fromPoints/Point2ShapePredicate.h"
53
54
55
using namespace
DGtal;
56
57
using namespace
LibBoard;
58
59
60
61
62
int
main(
int
,
char
**)
63
{
64
65
66
67
typedef
int
Coordinate;
68
typedef
PointVector<2,Coordinate>
Point
;
69
typedef
StraightLineFrom2Points<Point>
StraightLine;
70
71
Point p(0,0);
72
Point q(5,2);
73
Point r1(2,0);
74
Point r2(0,2);
75
Point r3(10,4);
76
77
StraightLine line(p,q);
78
79
80
//halfplane upward oriented and closed
82
typedef
Point2ShapePredicate<StraightLine,true,true>
UpClosedHalfPlane;
84
85
//halfplane upward oriented and open
86
typedef
Point2ShapePredicate<StraightLine,true,false>
UpOpenHalfPlane;
87
//halfplane downward oriented and closed
88
typedef
Point2ShapePredicate<StraightLine,false,true>
DownClosedHalfPlane;
89
90
//Location
91
trace
.
beginBlock
(
"Creation of a halfplane and test some points"
);
92
93
std::string res;
94
95
trace
.
info
() <<
"created line:"
<< std::endl;
96
trace
.
info
() << line << std::endl;
97
99
//line is an instance of StraightLine
100
UpClosedHalfPlane hp(line);
101
trace
.
info
() << hp << std::endl;
102
trace
.
info
() <<
"Does "
<< r1 <<
" belongs to hp (no)?"
<< std::endl;
103
res = hp(r1)?
"yes"
:
"no"
;
104
trace
.
info
() << res << std::endl;
106
107
trace
.
info
() <<
"Does "
<< r2 <<
" belongs to hp (yes)?"
<< std::endl;
108
res = hp(r2)?
"yes"
:
"no"
;
109
trace
.
info
() << res << std::endl;
110
111
trace
.
info
() <<
"Does "
<< r3 <<
" belongs to hp (yes)?"
<< std::endl;
112
res = hp(r3)?
"yes"
:
"no"
;
113
trace
.
info
() << res << std::endl;
114
115
116
UpOpenHalfPlane hp2(line);
117
trace
.
info
() << hp2 << std::endl;
118
119
trace
.
info
() <<
"Does "
<< r1 <<
" belongs to hp2 (no)?"
<< std::endl;
120
res = hp2(r1)?
"yes"
:
"no"
;
121
trace
.
info
() << res << std::endl;
122
123
trace
.
info
() <<
"Does "
<< r2 <<
" belongs to hp2 (yes)?"
<< std::endl;
124
res = hp2(r2)?
"yes"
:
"no"
;
125
trace
.
info
() << res << std::endl;
126
127
trace
.
info
() <<
"Does "
<< r3 <<
" belongs to hp2 (no)?"
<< std::endl;
128
res = hp2(r3)?
"yes"
:
"no"
;
129
trace
.
info
() << res << std::endl;
130
131
DownClosedHalfPlane hp3(line);
132
trace
.
info
() << hp3 << std::endl;
133
134
trace
.
info
() <<
"Does "
<< r1 <<
" belongs to hp3 (yes)?"
<< std::endl;
135
res = hp3(r1)?
"yes"
:
"no"
;
136
trace
.
info
() << res << std::endl;
137
138
trace
.
info
() <<
"Does "
<< r2 <<
" belongs to hp3 (no)?"
<< std::endl;
139
res = hp3(r2)?
"yes"
:
"no"
;
140
trace
.
info
() << res << std::endl;
141
142
trace
.
info
() <<
"Does "
<< r3 <<
" belongs to hp3 (yes)?"
<< std::endl;
143
res = hp3(r3)?
"yes"
:
"no"
;
144
trace
.
info
() << res << std::endl;
145
146
trace
.
endBlock
();
147
148
149
return
0;
150
}
Generated on Wed Dec 19 2012 19:10:39 for DGtal by
1.8.1.1