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 up constants for the container geometry
11 const double x_min
=-6,x_max
=6;
12 const double y_min
=-6,y_max
=6;
13 const double z_min
=-3,z_max
=9;
15 // Golden ratio constants
16 const double Phi
=0.5*(1+sqrt(5.0));
17 const double phi
=0.5*(1-sqrt(5.0));
19 // Set up the number of blocks that the container is divided
21 const int n_x
=5,n_y
=5,n_z
=5;
23 // Create a wall class that, whenever called, will replace the Voronoi cell
24 // with a prescribed shape, in this case a dodecahedron
25 class wall_initial_shape
: public wall
{
27 wall_initial_shape() {
29 // Create a dodecahedron
30 v
.init(-2,2,-2,2,-2,2);
31 v
.plane(0,Phi
,1);v
.plane(0,-Phi
,1);v
.plane(0,Phi
,-1);
32 v
.plane(0,-Phi
,-1);v
.plane(1,0,Phi
);v
.plane(-1,0,Phi
);
33 v
.plane(1,0,-Phi
);v
.plane(-1,0,-Phi
);v
.plane(Phi
,1,0);
34 v
.plane(-Phi
,1,0);v
.plane(Phi
,-1,0);v
.plane(-Phi
,-1,0);
36 bool point_inside(double x
,double y
,double z
) {return true;}
37 bool cut_cell(voronoicell
&c
,double x
,double y
,double z
) {
39 // Set the cell to be equal to the dodecahedron
43 bool cut_cell(voronoicell_neighbor
&c
,double x
,double y
,double z
) {
45 // Set the cell to be equal to the dodecahedron
55 // Create a container with the geometry given above. This is bigger
56 // than the particle packing itself.
57 container
con(x_min
,x_max
,y_min
,y_max
,z_min
,z_max
,n_x
,n_y
,n_z
,
60 // Create the "initial shape" wall class and add it to the container
61 wall_initial_shape(wis
);
64 // Import the irregular particle packing
65 con
.import("pack_irregular");
67 // Save the particles and Voronoi cells in POV-Ray format
68 con
.draw_particles_pov("irregular_p.pov");
69 con
.draw_cells_pov("irregular_v.pov");