26 #include <tulip/Coord.h>
41 TLP_SCOPE
bool delaunayTriangulation(std::vector<Coord> &points,
42 std::vector<std::pair<unsigned int, unsigned int> > &edges,
43 std::vector<std::vector<unsigned int> > &simplices,
44 bool voronoiMode =
false);
50 class TLP_SCOPE VoronoiDiagram {
60 typedef std::pair<unsigned int, unsigned int> Edge;
63 typedef std::set<unsigned int> Cell;
66 unsigned int nbSites()
const {
71 unsigned int nbVertices()
const {
72 return vertices.size();
76 unsigned int nbEdges()
const {
81 const Site &site(
const unsigned int siteIdx) {
82 return sites[siteIdx];
86 const Vertex &vertex(
const unsigned int vertexIdx) {
87 return vertices[vertexIdx];
91 const Edge &edge(
const unsigned int edgeIdx) {
92 return edges[edgeIdx];
96 const Cell &cell(
const unsigned int cellIdx) {
97 return cells[cellIdx];
101 unsigned int degreeOfVertex(
const unsigned int vertexIdx) {
102 return verticesDegree[vertexIdx];
106 std::vector<Edge> voronoiEdgesForSite(
const unsigned int siteIdx) {
107 std::vector<Edge> ret;
109 for (
size_t i = 0 ; i < siteToCellEdges[siteIdx].size() ; ++i) {
110 ret.push_back(edges[siteToCellEdges[siteIdx][i]]);
117 const Cell &voronoiCellForSite(
const unsigned int siteIdx) {
118 return cells[siteToCell[siteIdx]];
122 std::vector<Site> sites;
123 std::vector<Vertex> vertices;
124 std::vector<Edge> edges;
125 std::vector<Cell> cells;
126 TLP_HASH_MAP<unsigned int, std::vector<unsigned int> > siteToCellEdges;
127 TLP_HASH_MAP<unsigned int, unsigned int> siteToCell;
128 TLP_HASH_MAP<unsigned int, unsigned int> verticesDegree;
140 TLP_SCOPE
bool voronoiDiagram(std::vector<Coord> &sites, VoronoiDiagram &voronoiDiagram);