Fawkes API
Fawkes Development Version
polygon_edge_constraint.cpp
1
/***************************************************************************
2
* polygon_constraint.cpp -
3
*
4
* Created: Mon Jan 19 11:20:31 2015 (next to Super-C waiting for demo)
5
* Copyright 2015 Tim Niemueller
6
****************************************************************************/
7
8
/* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Library General Public License for more details.
17
*
18
* Read the full text in the LICENSE.GPL file in the doc directory.
19
*/
20
21
#include <navgraph/constraints/polygon_edge_constraint.h>
22
23
#include <algorithm>
24
25
namespace
fawkes
{
26
27
/** @class NavGraphPolygonEdgeConstraint <navgraph/constraints/polygon_constraint.h>
28
* Constraint that blocks nodes within and edges touching a polygon.
29
* @author Tim Niemueller
30
*/
31
32
/** Constructor.
33
* @param name name of node constraint
34
*/
35
NavGraphPolygonEdgeConstraint::NavGraphPolygonEdgeConstraint
(
const
std::string &name)
36
: NavGraphEdgeConstraint(name)
37
{
38
}
39
40
/** Constructor.
41
* @param name name of node constraint
42
* @param polygon polygon to add immediately
43
*/
44
NavGraphPolygonEdgeConstraint::NavGraphPolygonEdgeConstraint
(
const
std::string &name,
45
const
Polygon & polygon)
46
:
NavGraphEdgeConstraint
(name),
NavGraphPolygonConstraint
(polygon)
47
{
48
}
49
50
/** Virtual empty destructor. */
51
NavGraphPolygonEdgeConstraint::~NavGraphPolygonEdgeConstraint
()
52
{
53
}
54
55
bool
56
NavGraphPolygonEdgeConstraint::compute
(
void
)
throw
()
57
{
58
if
(!polygons_.empty()) {
59
return
true
;
60
}
else
{
61
return
false
;
62
}
63
}
64
65
bool
66
NavGraphPolygonEdgeConstraint::blocks
(
const
fawkes::NavGraphNode
&from,
67
const
fawkes::NavGraphNode
&to)
throw
()
68
{
69
for
(
auto
p : polygons_) {
70
Point
from_p(from.x(), from.y());
71
Point
to_p(to.x(), to.y());
72
if
(on_poly(from_p, to_p, p.second)) {
73
return
true
;
74
}
75
}
76
77
return
false
;
78
}
79
80
}
// end of namespace fawkes
fawkes::NavGraphNode
Definition:
navgraph_node.h:38
fawkes::NavGraphPolygonConstraint::Point_
Simple point representation for polygon.
Definition:
polygon_constraint.h:44
fawkes::NavGraphPolygonEdgeConstraint::NavGraphPolygonEdgeConstraint
NavGraphPolygonEdgeConstraint(const std::string &name)
Constructor.
Definition:
polygon_edge_constraint.cpp:38
fawkes::NavGraphPolygonEdgeConstraint::~NavGraphPolygonEdgeConstraint
virtual ~NavGraphPolygonEdgeConstraint()
Virtual empty destructor.
Definition:
polygon_edge_constraint.cpp:54
fawkes::NavGraphPolygonEdgeConstraint::blocks
virtual bool blocks(const fawkes::NavGraphNode &from, const fawkes::NavGraphNode &to)
Definition:
polygon_edge_constraint.cpp:69
fawkes::NavGraphEdgeConstraint
Definition:
edge_constraint.h:38
fawkes
fawkes::NavGraphPolygonConstraint
Definition:
polygon_constraint.h:36
fawkes::NavGraphPolygonEdgeConstraint::compute
virtual bool compute(void)
Perform compuations before graph search and to indicate re-planning.
Definition:
polygon_edge_constraint.cpp:59
src
libs
navgraph
constraints
polygon_edge_constraint.cpp
Generated by
1.8.16