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