27 : bx(bx_), bxy(bxy_), by(by_), bxz(bxz_), byz(byz_), bz(bz_) {
31 const double ucx=max_unit_voro_shells*
bx,ucy=max_unit_voro_shells*
by,ucz=max_unit_voro_shells*
bz;
35 while(l<2*max_unit_voro_shells) {
39 if(unit_voro_intersect(l)) {
43 unit_voro_apply(l,0,0);
45 unit_voro_apply(l,i,0);
46 unit_voro_apply(-l,i,0);
48 for(i=-l;i<=l;i++) unit_voro_apply(i,l,0);
49 for(i=1;i<l;i++)
for(j=-l+1;j<=l;j++) {
50 unit_voro_apply(l,j,i);
51 unit_voro_apply(-j,l,i);
52 unit_voro_apply(-l,-j,i);
53 unit_voro_apply(j,-l,i);
55 for(i=-l;i<=l;i++)
for(j=-l;j<=l;j++) unit_voro_apply(i,j,l);
68 q=*(pp++);y=*(pp++);z=*(pp++);q=sqrt(q*q+y*y+z*z);
89 inline void unitcell::unit_voro_apply(
int i,
int j,
int k) {
102 const double bxinv=1/
bx,byinv=1/
by,bzinv=1/
bz,ivol=bxinv*byinv*bzinv;
106 if(!c.
plane(0,0,bzinv,dz+1))
return false;
107 if(!c.
plane(0,0,-bzinv,-dz+1))
return false;
108 if(!c.
plane(0,byinv,-byz*byinv*bzinv,dy+1))
return false;
109 if(!c.
plane(0,-byinv,byz*byinv*bzinv,-dy+1))
return false;
110 if(!c.
plane(bxinv,-
bxy*bxinv*byinv,(
bxy*byz-
by*bxz)*ivol,dx+1))
return false;
111 if(!c.
plane(-bxinv,
bxy*bxinv*byinv,(-
bxy*byz+
by*bxz)*ivol,-dx+1))
return false;
123 const int ms2=max_unit_voro_shells*2+1,mss=ms2*ms2*ms2;
124 bool *a=
new bool[mss],*ac=a+max_unit_voro_shells*(1+ms2*(1+ms2)),*ap=a;
129 while(ap<ac) *(ap++)=
true;
131 while(ap<a+mss) *(ap++)=
true;
135 q.push(0);q.push(0);q.push(0);
155 ap=ac+i+ms2*(j+ms2*k);
156 if(k>-max_unit_voro_shells&&*(ap-ms2*ms2)) {q.push(i);q.push(j);q.push(k-1);*(ap-ms2*ms2)=
false;}
157 if(j>-max_unit_voro_shells&&*(ap-ms2)) {q.push(i);q.push(j-1);q.push(k);*(ap-ms2)=
false;}
158 if(i>-max_unit_voro_shells&&*(ap-1)) {q.push(i-1);q.push(j);q.push(k);*(ap-1)=
false;}
159 if(i<max_unit_voro_shells&&*(ap+1)) {q.push(i+1);q.push(j);q.push(k);*(ap+1)=
false;}
160 if(j<max_unit_voro_shells&&*(ap+ms2)) {q.push(i);q.push(j+1);q.push(k);*(ap+ms2)=
false;}
161 if(k<max_unit_voro_shells&&*(ap+ms2*ms2)) {q.push(i);q.push(j);q.push(k+1);*(ap+ms2*ms2)=
false;}
173 bool unitcell::unit_voro_intersect(
int l) {
175 if(unit_voro_test(l,0,0))
return true;
177 if(unit_voro_test(l,i,0))
return true;
178 if(unit_voro_test(-l,i,0))
return true;
180 for(i=-l;i<=l;i++)
if(unit_voro_test(i,l,0))
return true;
181 for(i=1;i<l;i++)
for(j=-l+1;j<=l;j++) {
182 if(unit_voro_test(l,j,i))
return true;
183 if(unit_voro_test(-j,l,i))
return true;
184 if(unit_voro_test(-l,-j,i))
return true;
185 if(unit_voro_test(j,-l,i))
return true;
187 for(i=-l;i<=l;i++)
for(j=-l;j<=l;j++)
if(unit_voro_test(i,j,l))
return true;
195 inline bool unitcell::unit_voro_test(
int i,
int j,
int k) {
197 double rsq=x*x+y*y+z*z;
204 fprintf(fp,
"0 0 0\n%g 0 0\n%g %g 0\n%g %g 0\n",
bx,
bx+
bxy,
by,
bxy,
by);
205 fprintf(fp,
"%g %g %g\n%g %g %g\n%g %g %g\n%g %g %g\n",
bxy+bxz,
by+byz,bz,
bx+
bxy+bxz,
by+byz,bz,
bx+bxz,byz,bz,bxz,byz,bz);
206 fprintf(fp,
"0 0 0\n%g %g 0\n\n%g %g %g\n%g %g %g\n\n",
bxy,
by,bxz,byz,bz,
bxy+bxz,
by+byz,bz);
207 fprintf(fp,
"%g 0 0\n%g %g %g\n\n%g %g 0\n%g %g %g\n\n",
bx,
bx+bxz,byz,bz,
bx+
bxy,
by,
bx+
bxy+bxz,
by+byz,bz);
213 fprintf(fp,
"cylinder{0,0,0>,<%g,0,0>,rr}\n"
214 "cylinder{<%g,%g,0>,<%g,%g,0>,rr}\n",
bx,
bxy,
by,
bx+
bxy,
by);
215 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
216 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",bxz,byz,bz,
bx+bxz,byz,bz,
bxy+bxz,
by+byz,bz,
bx+
bxy+bxz,
by+byz,bz);
217 fprintf(fp,
"cylinder{<0,0,0>,<%g,%g,0>,rr}\n"
218 "cylinder{<%g,0,0>,<%g,%g,0>,rr}\n",
bxy,
by,
bx,
bx+
bxy,
by);
219 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
220 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",bxz,byz,bz,
bxy+bxz,
by+byz,bz,
bx+bxz,byz,bz,
bx+
bxy+bxz,
by+byz,bz);
221 fprintf(fp,
"cylinder{<0,0,0>,<%g,%g,%g>,rr}\n"
222 "cylinder{<%g,0,0>,<%g,%g,%g>,rr}\n",bxz,byz,bz,
bx,
bx+bxz,byz,bz);
223 fprintf(fp,
"cylinder{<%g,%g,0>,<%g,%g,%g>,rr}\n"
224 "cylinder{<%g,%g,0>,<%g,%g,%g>,rr}\n",
bxy,
by,
bxy+bxz,
by+byz,bz,
bx+
bxy,
by,
bx+
bxy+bxz,
by+byz,bz);
225 fprintf(fp,
"sphere{<0,0,0>,rr}\nsphere{<%g,0,0>,rr}\n"
226 "sphere{<%g,%g,0>,rr}\nsphere{<%g,%g,0>,rr}\n",
bx,
bxy,
by,
bx+
bxy,
by);
227 fprintf(fp,
"sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n"
228 "sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n",bxz,byz,bz,
bx+bxz,byz,bz,
bxy+bxz,
by+byz,bz,
bx+
bxy+bxz,
by+byz,bz);
bool plane_intersects(double x, double y, double z, double rsq)
#define VOROPP_MEMORY_ERROR
bool plane(double x, double y, double z, double rsq)
Header file for the voronoicell and related classes.
void images(std::vector< int > &vi, std::vector< double > &vd)
unitcell(double bx_, double bxy_, double by_, double bxz_, double byz_, double bz_)
Header file for the unitcell class.
void draw_domain_pov(const char *filename)
bool intersects_image(double dx, double dy, double dz, double &vol)
Extension of the voronoicell_base class to represent a Voronoi cell without neighbor information...
void draw_domain_gnuplot(const char *filename)
void init(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)