25 #include <unordered_map> 27 #include <tulip/Coord.h> 43 TLP_SCOPE
bool delaunayTriangulation(std::vector<Coord> &points,
44 std::vector<std::pair<unsigned int, unsigned int>> &edges,
45 std::vector<std::vector<unsigned int>> &simplices,
46 bool voronoiMode =
false);
52 class TLP_SCOPE VoronoiDiagram {
61 typedef std::pair<unsigned int, unsigned int> Edge;
64 typedef std::set<unsigned int> Cell;
67 unsigned int nbSites()
const {
72 unsigned int nbVertices()
const {
73 return vertices.size();
77 unsigned int nbEdges()
const {
82 const Site &site(
const unsigned int siteIdx) {
83 return sites[siteIdx];
87 const Vertex &vertex(
const unsigned int vertexIdx) {
88 return vertices[vertexIdx];
92 const Edge &edge(
const unsigned int edgeIdx) {
93 return edges[edgeIdx];
97 const Cell &cell(
const unsigned int cellIdx) {
98 return cells[cellIdx];
102 unsigned int degreeOfVertex(
const unsigned int vertexIdx) {
103 return verticesDegree[vertexIdx];
107 std::vector<Edge> voronoiEdgesForSite(
const unsigned int siteIdx) {
108 std::vector<Edge> ret;
110 for (
size_t i = 0; i < siteToCellEdges[siteIdx].size(); ++i) {
111 ret.push_back(edges[siteToCellEdges[siteIdx][i]]);
118 const Cell &voronoiCellForSite(
const unsigned int siteIdx) {
119 return cells[siteToCell[siteIdx]];
123 std::vector<Site> sites;
124 std::vector<Vertex> vertices;
125 std::vector<Edge> edges;
126 std::vector<Cell> cells;
127 std::unordered_map<unsigned int, std::vector<unsigned int>> siteToCellEdges;
128 std::unordered_map<unsigned int, unsigned int> siteToCell;
129 std::unordered_map<unsigned int, unsigned int> verticesDegree;
141 TLP_SCOPE
bool voronoiDiagram(std::vector<Coord> &sites, VoronoiDiagram &voronoiDiagram);