This repository has been archived by the owner on Nov 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvoronoi.h
86 lines (61 loc) · 1.6 KB
/
voronoi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <set>
#include <cassert>
#include <algorithm>
#include <tuple>
#include <vector>
#include <memory>
#include <iostream>
#include "geometry.h"
using std::sqrt;
using std::tuple;
using std::get;
struct Voronoi
{
private:
class Implementation;
public:
typedef std::shared_ptr<Voronoi> Ptr;
typedef std::shared_ptr<const Voronoi> ConstPtr;
struct Node;
class Edge
{
public:
typedef std::shared_ptr<Edge> Ptr;
// original points that this edge separates
std::set<size_t> parents;
// endpoints for the edge
std::shared_ptr<Node> nodes[2];
// other edges adjacent to this one
std::set<std::shared_ptr<Edge>> neighbors;
};
class Node
{
public:
typedef std::shared_ptr<Node> Ptr;
// position
float x, y;
// original points that this node separates (2 or 3)
std::set<size_t> parents;
// edges attached to this node
std::set<std::shared_ptr<Edge>> edges;
// other nodes attached to this one by an edge
std::set<std::shared_ptr<Node>> neighbors;
private:
friend Voronoi::Implementation;
};
Voronoi(const std::vector<Point>& points);
const std::vector<Edge::Ptr> getEdges() const
{
return m_edges;
}
const std::vector<Node::Ptr> getNodes() const
{
return m_nodes;
}
private:
std::vector<Edge::Ptr> m_edges;
std::vector<Node::Ptr> m_nodes;
};
//Voronoi computeVoronoi(const std::vector<Point>& points);
Voronoi::Ptr computeVoronoi(const std::vector<Point>& points);