LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
voronoi_diagram.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
30#ifndef RCSC_GEOM_VORONOI_DIAGRAM_H
31#define RCSC_GEOM_VORONOI_DIAGRAM_H
32
33#include <rcsc/geom/vector_2d.h>
35#include <rcsc/geom/ray_2d.h>
36#include <rcsc/geom/rect_2d.h>
38
39#include <vector>
40#include <set>
41
42namespace rcsc {
43
49public:
50 typedef std::set< Vector2D, Vector2D::XYCmp > Vector2DCont;
51 typedef std::vector< Segment2D > Segment2DCont;
52 typedef std::vector< Ray2D > Ray2DCont;
53
54private:
55
56 Rect2D * M_bounding_rect;
57
58 DelaunayTriangulation M_triangulation;
59
60 Vector2DCont M_vertices;
61 Segment2DCont M_segments;
62 Ray2DCont M_rays;
63
64public:
69
74 VoronoiDiagram( const std::vector< Vector2D > & v );
75
80
85 void setBoundingRect( const Rect2D & rect );
86
91 void addPoint( const Vector2D & p )
92 {
93 M_triangulation.addVertex( p );
94 }
95
100 void addPoint( const std::vector< Vector2D > & v )
101 {
102 M_triangulation.addVertices( v );
103 }
104
108 void clear();
109
114
119
123 void compute();
124
130 {
131 return M_triangulation;
132 }
133
138 const Vector2DCont & vertices() const
139 {
140 return M_vertices;
141 }
142 const Vector2DCont & resultPoints() const
143 {
144 return M_vertices;
145 }
146
151 const Segment2DCont & segments() const
152 {
153 return M_segments;
154 }
155 const Segment2DCont & resultSegments() const
156 {
157 return M_segments;
158 }
159
164 const Ray2DCont & rays() const
165 {
166 return M_rays;
167 }
168 const Ray2DCont & resultRays() const
169 {
170 return M_rays;
171 }
172
179 void getPointsOnSegments( const double min_length,
180 const unsigned int max_division,
181 std::vector< Vector2D > * result ) const;
182};
183
184}
185
186#endif
Delaunay triangulation.
Definition: delaunay_triangulation.h:49
void addVertices(const std::vector< Vector2D > &v)
set vertices.
int addVertex(const double x, const double y)
add new vertex
2D rectangle regin class.
Definition: rect_2d.h:59
2D point vector class
Definition: vector_2d.h:46
2D voronoi diagram class
Definition: voronoi_diagram.h:48
const Segment2DCont & segments() const
get result set of segments
Definition: voronoi_diagram.h:151
void addPoint(const std::vector< Vector2D > &v)
add points
Definition: voronoi_diagram.h:100
const Ray2DCont & rays() const
get result set of rays
Definition: voronoi_diagram.h:164
VoronoiDiagram()
create voronoi diagram handler
VoronoiDiagram(const std::vector< Vector2D > &v)
create voronoi diagram handler with points
void clearBoundingRect()
delete bounding rectangle object if exists.
const DelaunayTriangulation & triangulation() const
get the triangulation, the dual of this voronoi diagram
Definition: voronoi_diagram.h:129
void addPoint(const Vector2D &p)
add point to voronoi diagram as one of input points
Definition: voronoi_diagram.h:91
void setBoundingRect(const Rect2D &rect)
set bounding rectangle.
const Vector2DCont & vertices() const
get result set of points
Definition: voronoi_diagram.h:138
void clear()
clear all variables.
void compute()
generates voronoi diagram
~VoronoiDiagram()
destructor.
void getPointsOnSegments(const double min_length, const unsigned int max_division, std::vector< Vector2D > *result) const
get point set on segments
void clearResults()
clear result variables.
Delaunay Triangulation class Header File.
2D ray line class Header File.
2D rectangle region Header File.
2D segment line Header File.
2d vector class Header File.