1 // Irregular packing example code
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
10 // Set the number of particles that are going to be randomly introduced
11 const int particles
=30;
13 // This function returns a random double between 0 and 1
14 double rnd() {return double(rand())/RAND_MAX
;}
16 // Create a wall class that, whenever called, will replace the Voronoi cell
17 // with a prescribed shape, in this case a dodecahedron
18 class wall_l_shape
: public wall
{
23 bool point_inside(double x
,double y
,double z
) {return true;}
24 bool cut_cell(voronoicell
&c
,double x
,double y
,double z
) {
26 // Set the cell to be equal to the dodecahedron
28 c
.translate(-x
,-y
,-z
);
32 bool cut_cell(voronoicell_neighbor
&c
,double x
,double y
,double z
) {
34 // Set the cell to be equal to the dodecahedron
36 c
.translate(-x
,-y
,-z
);
48 // Create a container with the geometry given above. This is bigger
49 // than the particle packing itself.
50 container
con(-1,1,-1,1,-1,1,5,5,5,false,false,false,8);
52 // Create the L-shape wall class and add it to the container
56 // Import the irregular particle packing
60 if(x
<0&&y
>0) continue;
66 // Save the particles and Voronoi cells in POV-Ray format
67 con
.draw_particles("l_shape_p.gnu");
68 con
.draw_cells_gnuplot("l_shape_v.gnu");