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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user