DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testHalfPlane.cpp
Go to the documentation of this file.
1
16
28
33
34
#include <cstdio>
35
#include <cmath>
36
#include <fstream>
37
#include <vector>
38
#include <iostream>
39
#include <iterator>
40
#include "DGtal/base/Common.h"
41
#include "DGtal/base/Exceptions.h"
42
#include "DGtal/kernel/SpaceND.h"
43
#include "DGtal/kernel/domains/DomainPredicate.h"
44
#include "DGtal/kernel/domains/HyperRectDomain.h"
45
#include "DGtal/io/boards/Board2D.h"
46
#include "DGtal/shapes/fromPoints/StraightLineFrom2Points.h"
47
#include "DGtal/shapes/fromPoints/Point2ShapePredicate.h"
48
49
#include "DGtalCatch.h"
50
51
52
using namespace
DGtal
;
53
using namespace
DGtal::functors
;
54
using namespace
LibBoard
;
55
56
TEST_CASE
(
"HalfplaneUnit tests"
)
57
{
58
typedef
int
Coordinate
;
59
typedef
PointVector<2,Coordinate>
Point
;
60
typedef
StraightLineFrom2Points<Point>
StraightLine;
61
62
Point
p(0,0);
63
Point
q(5,2);
64
Point
r1(2,0);
65
Point
r2(0,2);
66
Point
r3(10,4);
67
StraightLine line(p,q);
68
69
//halfplane upward oriented and closed
71
typedef
Point2ShapePredicate<StraightLine,true,true>
UpClosedHalfPlane;
73
74
//halfplane upward oriented and open
75
typedef
Point2ShapePredicate<StraightLine,true,false>
UpOpenHalfPlane;
76
//halfplane downward oriented and closed
77
typedef
Point2ShapePredicate<StraightLine,false,true>
DownClosedHalfPlane;
78
79
//Location
80
trace
.
beginBlock
(
"Creation of a halfplane and test some points"
);
81
std::string res;
82
trace
.
info
() <<
"created line:"
<< std::endl;
83
trace
.
info
() << line << std::endl;
84
86
//line is an instance of StraightLine
87
UpClosedHalfPlane hp(line);
88
trace
.
info
() << hp << std::endl;
89
trace
.
info
() <<
"Does "
<< r1 <<
" belongs to hp (no)?"
<< std::endl;
90
REQUIRE
( !hp(r1) );
92
REQUIRE
(hp(r2));
93
REQUIRE
(hp(r3));
94
95
96
UpOpenHalfPlane hp2(line);
97
REQUIRE
(! hp2(r1));
98
REQUIRE
(hp2(r2));
99
REQUIRE
( ! hp2(r3) );
100
101
DownClosedHalfPlane hp3(line);
102
REQUIRE
(hp3(r1));
103
REQUIRE
(!hp3(r2));
104
REQUIRE
(hp3(r3));
105
}
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
DGtal::StraightLineFrom2Points
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
Definition
StraightLineFrom2Points.h:69
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::info
std::ostream & info()
DGtal::functors::Point2ShapePredicate
Aim: Predicate returning 'true' iff a given point is in the 'interior' of a given shape,...
Definition
Point2ShapePredicate.h:96
DGtal::functors
functors namespace gathers all DGtal functors.
Definition
BasicBoolFunctors.h:49
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
LibBoard
Definition
Board.cpp:86
DGtal::Coordinate
LibBoard::Point
Struct representing a 2D point.
Definition
Point.h:27
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
shapes
testHalfPlane.cpp
Generated on
for DGtal by
1.18.0