Fawkes API  Fawkes Development Version
voronoi.h
1 
2 /***************************************************************************
3  * voronoi.h - generate navgraph from Voronoi using CGAL
4  *
5  * Created: Mon Jan 12 21:31:38 2015
6  * Copyright 2015 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21  */
22 
23 #ifndef __LIBS_NAVGRAPH_GENERATOR_VORONOI_H_
24 #define __LIBS_NAVGRAPH_GENERATOR_VORONOI_H_
25 
26 #include <navgraph/navgraph.h>
27 
28 #include <utils/math/polygon.h>
29 
30 namespace fawkes {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
36 {
37  public:
39  NavGraphGeneratorVoronoi(float bbox_p1_x, float bbox_p1_y,
40  float bbox_p2_x, float bbox_p2_y,
41  float near_threshold);
42  virtual ~NavGraphGeneratorVoronoi();
43 
44  virtual void compute(fawkes::LockPtr<fawkes::NavGraph> graph);
45 
46  void set_bounding_box(float bbox_p1_x, float bbox_p1_y,
47  float bbox_p2_x, float bbox_p2_y);
48  void set_near_threshold(float near_threshold);
49  void add_obstacle(float x, float y);
50  void clear();
51 
52  /** Get list of polygons.
53  * @return list of polygons, each polygon contains the vertices of a
54  * bounded face of the Voronoi diagram.
55  */
56  const std::list<Polygon2D> & face_polygons() const
57  { return polygons_; }
58 
59  private:
60 
61  bool bbox_enabled_;
62  float bbox_p1_x_;
63  float bbox_p1_y_;
64  float bbox_p2_x_;
65  float bbox_p2_y_;
66  float near_threshold_;
67 
68  std::list<std::pair<float, float>> obstacles_;
69  std::list<Polygon2D> polygons_;
70 };
71 
72 } // end of namespace fawkes
73 
74 #endif
Fawkes library namespace.
void set_bounding_box(float bbox_p1_x, float bbox_p1_y, float bbox_p2_x, float bbox_p2_y)
Set bounding box.
Definition: voronoi.cpp:153
void add_obstacle(float x, float y)
Add an obstacle point.
Definition: voronoi.cpp:181
const std::list< Polygon2D > & face_polygons() const
Get list of polygons.
Definition: voronoi.h:56
void set_near_threshold(float near_threshold)
Set distance threshold for considering nodes to be the same.
Definition: voronoi.cpp:169
Generate navgraph using a Voronoi diagram.
Definition: voronoi.h:35
virtual ~NavGraphGeneratorVoronoi()
Destructor.
Definition: voronoi.cpp:97
virtual void compute(fawkes::LockPtr< fawkes::NavGraph > graph)
Compute graph.
Definition: voronoi.cpp:202
void clear()
Clear all obstacle points.
Definition: voronoi.cpp:189
NavGraphGeneratorVoronoi()
Default constructor.
Definition: voronoi.cpp:67