2
0
mirror of https://github.com/boostorg/polygon.git synced 2026-01-28 07:22:29 +00:00

Polygon: Updating Voronoi diagram page documentation. Updating Voronoi basic tutorial.

[SVN r80482]
This commit is contained in:
Andrii Sydorchuk
2012-09-10 20:39:16 +00:00
parent 61734ab2b3
commit bef52a9b3b
7 changed files with 256 additions and 178 deletions

View File

@@ -13,6 +13,10 @@
#include <boost/polygon/voronoi.hpp>
using boost::polygon::voronoi_builder;
using boost::polygon::voronoi_diagram;
using boost::polygon::x;
using boost::polygon::y;
using boost::polygon::low;
using boost::polygon::high;
#include "voronoi_visual_utils.hpp"
@@ -154,5 +158,36 @@ int main() {
printf("\n");
printf("\n");
}
// Linking Voronoi cells with input geometries.
{
unsigned int cell_index = 0;
for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin();
it != vd.cells().end(); ++it) {
if (it->contains_point()) {
std::size_t index = it->source_index();
Point p = points[index];
printf("Cell #%ud contains a point: (%d, %d).\n",
cell_index, x(p), y(p));
} else {
std::size_t index = it->source_index() - points.size();
Point p0 = low(segments[index]);
Point p1 = high(segments[index]);
if (it->source_category() ==
boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) {
printf("Cell #%ud contains segment start point: (%d, %d).\n",
cell_index, x(p0), y(p0));
} else if (it->source_category() ==
boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT) {
printf("Cell #%ud contains segment end point: (%d, %d).\n",
cell_index, x(p0), y(p0));
} else {
printf("Cell #%ud contains a segment: ((%d, %d), (%d, %d)). \n",
cell_index, x(p0), y(p0), x(p1), y(p1));
}
}
++cell_index;
}
}
return 0;
}