Bugfix in search_for_outside_edge routine.
[voro++.git] / branches / 2d / examples / extra / lloyd.cc
blob05a708d25e627307fb57c61dd2635f752d0f0c8f
1 #include "voro++_2d.hh"
2 using namespace voro;
4 int main() {
5 int i;
6 char buffer[64];
8 // Initialize the container class to be the unit square, with
9 // non-periodic boundary conditions. Divide it into a 6 by 6 grid, with
10 // an initial memory allocation of 16 particles per grid square.
11 container_2d con(0,1,0,1,6,6,false,false,16);
13 // Import the spiral data set, and only save those particles that are
14 // within the container bounds
15 con.import("particles_spiral");
16 sprintf(buffer,"lloyd_output/lloyd_p.%d",0);
17 con.draw_particles(buffer);
19 // Carry out sixty four iterations of Lloyd's algorithm
20 for(i=0;i<256;i++) {
21 con.clear();
22 con.import(buffer);
23 sprintf(buffer,"lloyd_output/lloyd_v.%d",i);
24 con.draw_cells_gnuplot(buffer);
25 sprintf(buffer,"lloyd_output/lloyd_p.%d",i+1);
26 con.print_custom("%i %C",buffer);
29 // Draw the final Voronoi cells
30 con.draw_cells_gnuplot("lloyd_output/lloyd_v.256");