1 // Voro++, a cell-based Voronoi library
3 // Authors : Chris H. Rycroft (LBL / UC Berkeley)
4 // Cody Robert Dance (UC Berkeley)
5 // Email : chr@alum.mit.edu
6 // Date : August 30th 2011
8 /** \file ctr_boundary_2d.cc
9 * \brief Function implementations for the ctr_boundary_2d and related classes. */
11 #include "ctr_boundary_2d.hh"
15 /** The class constructor sets up the geometry of container, initializing the
16 * minimum and maximum coordinates in each direction, and setting whether each
17 * direction is periodic or not. It divides the container into a rectangular
18 * grid of blocks, and allocates memory for each of these for storing particle
20 * \param[in] (ax_,bx_) the minimum and maximum x coordinates.
21 * \param[in] (ay_,by_) the minimum and maximum y coordinates.
22 * \param[in] (nx_,ny_) the number of grid blocks in each of the three
23 * coordinate directions.
24 * \param[in] (xperiodic_,yperiodic_) flags setting whether the container is
25 * periodic in each coordinate direction.
26 * \param[in] init_mem the initial memory allocation for each block.
27 * \param[in] ps_ the number of floating point entries to store for each
29 container_boundary_2d::container_boundary_2d(double ax_
,double bx_
,double ay_
,double by_
,
30 int nx_
,int ny_
,bool xperiodic_
,bool yperiodic_
,int init_mem
)
31 : voro_base_2d(nx_
,ny_
,(bx_
-ax_
)/nx_
,(by_
-ay_
)/ny_
),
32 ax(ax_
), bx(bx_
), ay(ay_
), by(by_
), xperiodic(xperiodic_
), yperiodic(yperiodic_
),
33 id(new int*[nxy
]), p(new double*[nxy
]), co(new int[nxy
]), mem(new int[nxy
]),
34 wid(new int*[nxy
]), nlab(new int*[nxy
]), plab(new int**[nxy
]), bndpts(new int*[nxy
]),
35 boundary_track(-1), edbc(0), edbm(init_boundary_size
),
36 edb(new int[2*edbm
]), bnds(new double[2*edbm
]), ps(2), soi(NULL
),
37 vc(*this,xperiodic_
?2*nx_
+1:nx_
,yperiodic_
?2*ny_
+1:ny_
) {
41 for(l
=0;l
<nxy
;l
++) co
[l
]=0;
42 for(l
=0;l
<nxy
;l
++) mem
[l
]=init_mem
;
43 for(l
=0;l
<nxy
;l
++) id
[l
]=new int[init_mem
];
44 for(l
=0;l
<nxy
;l
++) p
[l
]=new double[ps
*init_mem
];
45 for(l
=0;l
<nxy
;l
++) nlab
[l
]=new int[init_mem
];
46 for(l
=0;l
<nxy
;l
++) plab
[l
]=new int*[init_mem
];
47 for(l
=0;l
<nxy
;l
++) bndpts
[l
]=new int[init_mem
];
49 for(l
=0;l
<nxy
;l
++) {wid
[l
]=new int[init_wall_tag_size
+2];*(wid
[l
])=0;wid
[l
][1]=init_wall_tag_size
;}
52 /** The container destructor frees the dynamically allocated memory. */
53 container_boundary_2d::~container_boundary_2d() {
56 // Clear "sphere of influence" array if it has been allocated
57 if(soi
!=NULL
) delete [] soi
;
59 // Deallocate the block-level arrays
60 for(l
=nxy
-1;l
>=0;l
--) delete [] wid
[l
];
61 for(l
=nxy
-1;l
>=0;l
--) delete [] bndpts
[l
];
62 for(l
=nxy
-1;l
>=0;l
--) delete [] plab
[l
];
63 for(l
=nxy
-1;l
>=0;l
--) delete [] nlab
[l
];
64 for(l
=nxy
-1;l
>=0;l
--) delete [] p
[l
];
65 for(l
=nxy
-1;l
>=0;l
--) delete [] id
[l
];
67 // Delete the two-dimensional arrays
75 /** Put a particle into the correct region of the container.
76 * \param[in] n the numerical ID of the inserted particle.
77 * \param[in] (x,y) the position vector of the inserted particle. */
78 void container_boundary_2d::put(int n
,double x
,double y
) {
80 if(put_locate_block(ij
,x
,y
)) {
83 if(boundary_track
!=-1) {
84 bndpts
[ij
][co
[ij
]]=edbc
;
85 register_boundary(x
,y
);
86 } else bndpts
[ij
][co
[ij
]]=-1;
87 double *pp
=p
[ij
]+2*co
[ij
]++;
92 /** Put a particle into the correct region of the container, also recording
93 * into which region it was stored.
94 * \param[in] vo the ordering class in which to record the region.
95 * \param[in] n the numerical ID of the inserted particle.
96 * \param[in] (x,y) the position vector of the inserted particle. */
97 void container_boundary_2d::put(particle_order
&vo
,int n
,double x
,double y
) {
99 if(put_locate_block(ij
,x
,y
)) {
102 if(boundary_track
!=-1) {
103 bndpts
[ij
][co
[ij
]]=edbc
;
104 register_boundary(x
,y
);
105 } else bndpts
[ij
][co
[ij
]]=-1;
107 double *pp
=p
[ij
]+2*co
[ij
]++;
112 /** This routine takes a particle position vector, tries to remap it into the
113 * primary domain. If successful, it computes the region into which it can be
114 * stored and checks that there is enough memory within this region to store
116 * \param[out] ij the region index.
117 * \param[in,out] (x,y) the particle position, remapped into the primary
118 * domain if necessary.
119 * \return True if the particle can be successfully placed into the container,
120 * false otherwise. */
121 inline bool container_boundary_2d::put_locate_block(int &ij
,double &x
,double &y
) {
122 if(put_remap(ij
,x
,y
)) {
123 if(co
[ij
]==mem
[ij
]) add_particle_memory(ij
);
126 #if VOROPP_REPORT_OUT_OF_BOUNDS ==1
127 fprintf(stderr
,"Out of bounds: (x,y)=(%g,%g)\n",x
,y
);
132 /** Takes a particle position vector and computes the region index into which
133 * it should be stored. If the container is periodic, then the routine also
134 * maps the particle position to ensure it is in the primary domain. If the
135 * container is not periodic, the routine bails out.
136 * \param[out] ij the region index.
137 * \param[in,out] (x,y) the particle position, remapped into the primary domain
139 * \return True if the particle can be successfully placed into the container,
140 * false otherwise. */
141 inline bool container_boundary_2d::put_remap(int &ij
,double &x
,double &y
) {
144 ij
=step_int((x
-ax
)*xsp
);
145 if(xperiodic
) {l
=step_mod(ij
,nx
);x
+=boxx
*(l
-ij
);ij
=l
;}
146 else if(ij
<0||ij
>=nx
) return false;
148 int j
=step_int((y
-ay
)*ysp
);
149 if(yperiodic
) {l
=step_mod(j
,ny
);y
+=boxy
*(l
-j
);j
=l
;}
150 else if(j
<0||j
>=ny
) return false;
156 /** Increase memory for a particular region.
157 * \param[in] i the index of the region to reallocate. */
158 void container_boundary_2d::add_particle_memory(int i
) {
159 int l
,nmem
=mem
[i
]<<1;
161 // Carry out a check on the memory allocation size, and
162 // print a status message if requested
163 if(nmem
>max_particle_memory_2d
)
164 voro_fatal_error("Absolute maximum memory allocation exceeded",VOROPP_MEMORY_ERROR
);
165 #if VOROPP_VERBOSE >=3
166 fprintf(stderr
,"Particle memory in region %d scaled up to %d\n",i
,nmem
);
169 // Allocate new memory and copy in the contents of the old arrays
170 int *idp
=new int[nmem
];
171 for(l
=0;l
<co
[i
];l
++) idp
[l
]=id
[i
][l
];
172 double *pp
=new double[ps
*nmem
];
173 for(l
=0;l
<ps
*co
[i
];l
++) pp
[l
]=p
[i
][l
];
174 int *nlabp
=new int[nmem
];
175 for(l
=0;l
<co
[i
];l
++) nlabp
[l
]=nlab
[i
][l
];
176 int **plabp
=new int*[nmem
];
177 for(l
=0;l
<co
[i
];l
++) plabp
[l
]=plab
[i
][l
];
178 int *bndptsp
=new int[nmem
];
179 for(l
=0;l
<co
[i
];l
++) bndptsp
[l
]=bndpts
[i
][l
];
181 // Update pointers and delete old arrays
183 delete [] id
[i
];id
[i
]=idp
;
184 delete [] p
[i
];p
[i
]=pp
;
185 delete [] nlab
[i
];nlab
[i
]=nlabp
;
186 delete [] plab
[i
];plab
[i
]=plabp
;
187 delete [] bndpts
[i
];bndpts
[i
]=bndptsp
;
190 /** Outputs the a list of all the container regions along with the number of
191 * particles stored within each. */
192 void container_boundary_2d::region_count() {
194 for(j
=0;j
<ny
;j
++) for(i
=0;i
<nx
;i
++)
195 printf("Region (%d,%d): %d particles\n",i
,j
,*(cop
++));
198 /** Clears a container of particles. */
199 void container_boundary_2d::clear() {
200 for(int *cop
=co
;cop
<co
+nxy
;cop
++) *cop
=0;
203 /** Computes all the Voronoi cells and saves customized information about them.
204 * \param[in] format the custom output string to use.
205 * \param[in] fp a file handle to write to. */
206 void container_boundary_2d::print_custom(const char *format
,FILE *fp
) {
207 c_loop_all_2d
vl(*this);
208 print_custom(vl
,format
,fp
);
211 /** Computes all the Voronoi cells and saves customized information about them.
212 * \param[in] format the custom output string to use.
213 * \param[in] filename the name of the file to write to. */
214 void container_boundary_2d::print_custom(const char *format
,const char *filename
) {
215 FILE *fp
=safe_fopen(filename
,"w");
216 print_custom(format
,fp
);
220 /** Computes all of the Voronoi cells in the container, but does nothing
221 * with the output. It is useful for measuring the pure computation time
222 * of the Voronoi algorithm, without any additional calculations such as
223 * volume evaluation or cell output. */
224 void container_boundary_2d::compute_all_cells() {
225 voronoicell_nonconvex_2d c
;
226 c_loop_all_2d
vl(*this);
227 if(vl
.start()) do compute_cell(c
,vl
);
231 /** Calculates all of the Voronoi cells and sums their volumes. In most cases
232 * without walls, the sum of the Voronoi cell volumes should equal the volume
233 * of the container to numerical precision.
234 * \return The sum of all of the computed Voronoi volumes. */
235 double container_boundary_2d::sum_cell_areas() {
236 voronoicell_nonconvex_2d c
;
238 c_loop_all_2d
vl(*this);
239 if(vl
.start()) do if(compute_cell(c
,vl
)) area
+=c
.area();while(vl
.inc());
243 /** Draws an outline of the domain in gnuplot format.
244 * \param[in] fp the file handle to write to. */
245 void container_boundary_2d::draw_domain_gnuplot(FILE *fp
) {
246 fprintf(fp
,"%g %g\n%g %g\n%g %g\n%g %g\n%g %g\n",ax
,ay
,bx
,ay
,bx
,by
,ax
,by
,ax
,ay
);
249 /** Draws an outline of the domain in POV-Ray format.
250 * \param[in] fp the file handle to write to. */
251 void container_boundary_2d::draw_domain_pov(FILE *fp
) {
252 fprintf(fp
,"cylinder{<%g,%g,0>,<%g,%g,0>,rr}\n"
253 "cylinder{<%g,%g,0>,<%g,%g,0>,rr}\n",ax
,ay
,bx
,ay
,ax
,by
,bx
,by
);
254 fprintf(fp
,"cylinder{<%g,%g,0>,<%g,%g,0>,rr}\n"
255 "cylinder{<%g,%g,0>,<%g,%g,0>,rr}\n",ax
,ay
,ax
,by
,bx
,ay
,bx
,by
);
256 fprintf(fp
,"sphere{<%g,%g,0>,rr}\nsphere{<%g,%g,0>,rr}\n"
257 "sphere{<%g,%g,0>,rr}\nsphere{<%g,%g,0>,rr}\n",ax
,ay
,bx
,ay
,ax
,by
,bx
,by
);
260 /** This does the additional set-up for non-convex containers. We assume that
261 * **p, **id, *co, *mem, *bnds, and edbc have already been setup. We then
262 * proceed to setup **wid, *soi, and THE PROBLEM POINTS BOOLEAN ARRAY.
263 * This algorithm keeps the importing seperate from the set-up */
264 void container_boundary_2d::setup(){
265 double lx
,ly
,cx
,cy
,nx
,ny
;//last (x,y),current (x,y),next (x,y)
266 int widl
=1,maxwid
=1,fwid
=1,nwid
,lwid
;
269 tmp
=tmpp
=new int[3*init_temp_label_size
];
270 tmpe
=tmp
+3*init_temp_label_size
;
273 cx
=bnds
[2*widl
];cy
=bnds
[2*widl
+1];
274 nwid
=edb
[2*widl
];lwid
=edb
[2*widl
+1];
275 lx
=bnds
[lwid
*2];ly
=bnds
[lwid
*2+1];
276 nx
=bnds
[2*nwid
];ny
=bnds
[2*nwid
+1];
278 tag_walls(cx
,cy
,nx
,ny
,widl
);
279 semi_circle_labeling(cx
,cy
,nx
,ny
,widl
);
281 //make sure that the cos(angle)>1 and the angle points inward
282 //probpts=(lx-cx)*(nx-cx)+(ly-cy)*(ny-cy)>tolerance &&
283 // cross_product(lx-cx,ly-cy,nx-cx,ny-cy);
286 if(widl
>maxwid
) maxwid
=widl
;
295 // The temporary array can now be used to set up the label table
296 create_label_table();
298 // Remove temporary array
302 /** Given two points, tags all the computational boxes that the line segment
303 * specified by the two points
304 * goes through. param[in] (x1,y1) this is one point
305 * \param[in] (x2,y2) this is the other point.
306 * \param[in] wid this is the wall id bnds[2*wid] is the x index of the first
307 * vertex in the c-c direction. */
308 void container_boundary_2d::tag_walls(double x1
,double y1
,double x2
,double y2
,int wid_
) {
310 // Find which boxes these points are within
311 int i1
=int((x1
-ax
)*xsp
),j1
=int((y1
-ay
)*ysp
);
312 int i2
=int((x2
-ax
)*xsp
),j2
=int((y2
-ay
)*ysp
),k
,ij
;
314 // Swap to ensure that i1 is smaller than i2
317 q
=x1
;x1
=x2
;x2
=q
;q
=y1
;y1
=y2
;y2
=q
;
318 k
=i1
;i1
=i2
;i2
=k
;k
=j1
;j1
=j2
;j2
=k
;
327 k
=int((((q
-y1
)*x2
+x1
*(y2
-q
))*yfac
-ax
)*xsp
);
329 tag_line(ij
,(j1
-1)*nx
+k
,wid_
);
336 k
=int((((q
-y1
)*x2
+x1
*(y2
-q
))*yfac
-ax
)*xsp
);
338 tag_line(ij
,j1
*nx
+k
,wid_
);
343 tag_line(ij
,i2
+j2
*nx
,wid_
);
346 void container_boundary_2d::tag_line(int &ij
,int ije
,int wid_
) {
354 inline void container_boundary_2d::tag(int ij
,int wid_
) {
358 if(nws
>max_wall_tag_size
) voro_fatal_error("Maximum wall tag memory exceeded",VOROPP_MEMORY_ERROR
);
359 int *np
=new int[nws
+2];
361 for(int i
=2;i
<*wp
+2;i
++) np
[i
]=wp
[i
];
368 /* Tags particles that are within a semicircle (on the appropriate side) of a
370 * \param[in] (x1,y1) the start point of the wall segment, arranged so that it
371 * is the first point reached in the counter-clockwise
373 * \param[in] (x2,y2) the end points of the wall segment. */
374 void container_boundary_2d::semi_circle_labeling(double x1
,double y1
,double x2
,double y2
,int bid
) {
376 double radius
=sqrt((x1
-x2
)*(x1
-x2
)+(y1
-y2
)*(y1
-y2
))*0.5,
377 midx
=(x1
+x2
)*0.5,midy
=(y1
+y2
)*0.5,cpx
,cpy
;
378 int ai
=int((midx
-radius
-ax
)*xsp
),
379 bi
=int((midx
+radius
-ax
)*xsp
),
380 aj
=int((midy
-radius
-ay
)*ysp
),
381 bj
=int((midy
+radius
-ay
)*ysp
),i
,j
,ij
,k
;
382 if(ai
<0) ai
=0;if(ai
>=nx
) ai
=nx
-1;
383 if(bi
<0) bi
=0;if(bi
>=nx
) bi
=nx
-1;
384 if(aj
<0) aj
=0;if(aj
>=ny
) aj
=ny
-1;
385 if(bj
<0) bj
=0;if(bj
>=ny
) bj
=ny
-1;
387 // Now loop through all the particles in the boxes we found, tagging
388 // the ones that are within radius of (midx,midy) and are on the
389 // appropriate side of the wall
390 for(j
=aj
;j
<=bj
;j
++) for(i
=ai
;i
<=bi
;i
++) {
392 for(k
=0;k
<co
[ij
];k
++) {
395 if((midx
-cpx
)*(midx
-cpx
)+(midy
-cpy
)*(midy
-cpy
)<=radius
*radius
&&
396 cross_product((x1
-x2
),(y1
-y2
),(cpx
-x2
),(cpy
-y2
))&&
397 (cpx
!=x1
||cpy
==y1
)&&(cpx
!=x2
||cpy
!=y2
)) {
399 if(tmpp
==tmpe
) add_temporary_label_memory();
408 void container_boundary_2d::create_label_table() {
411 // Clear label counters
412 for(ij
=0;ij
<nxy
;ij
++) for(q
=0;q
<co
[ij
];q
++) nlab
[ij
][q
]=0;
414 // Increment label counters
415 for(pp
=tmp
;pp
<tmpp
;pp
+=3) {nlab
[*pp
][pp
[1]]++;tlab
++;}
417 // Check for case of no labels at all (which may be common)
419 #if VOROPP_VERBOSE >=2
425 // If there was already a table from a previous call, remove it
426 if(soi
!=NULL
) delete [] soi
;
428 // Allocate the label array, and set up pointers from each particle
429 // to the corresponding location
430 pp
=soi
=new int[tlab
];
431 for(ij
=0;ij
<nxy
;ij
++) for(q
=0;q
<co
[ij
];pp
+=nlab
[ij
][q
++]) plab
[ij
][q
]=pp
;
433 // Fill in the label entries
434 for(pp
=tmp
;pp
<tmpp
;pp
+=3) *(plab
[*pp
][pp
[1]]++)=pp
[2];
436 // Reset the label pointers
438 for(ij
=0;ij
<nxy
;ij
++) for(q
=0;q
<co
[ij
];pp
+=nlab
[ij
][q
++]) plab
[ij
][q
]=pp
;
441 /** Draws the boundaries. (Note: this currently assumes that each boundary loop
442 * is a continuous block in the bnds array, which will be true for the import
443 * function. However, it may not be true in other cases, in which case this
444 * routine would have to be extended.) */
445 void container_boundary_2d::draw_boundary_gnuplot(FILE *fp
) {
448 for(i
=0;i
<edbc
;i
++) {
449 fprintf(fp
,"%g %g\n",bnds
[2*i
],bnds
[2*i
+1]);
451 // If a loop is detected, than complete the loop in the output file
452 // and insert a newline
453 if(edb
[2*i
]<i
) fprintf(fp
,"%g %g\n\n",bnds
[2*edb
[2*i
]],bnds
[2*edb
[2*i
]+1]);
457 bool container_boundary_2d::point_inside(double x
,double y
) {
459 bool sleft
,left
,nleft
;
462 sleft
=left
=bnds
[2*i
]<x
;
465 nleft
=j
<i
?sleft
:bnds
[2*j
]<x
;
468 if(bnds
[2*j
+1]*(x
-bnds
[2*i
])+bnds
[2*i
+1]*(bnds
[2*j
]-x
)<y
*(bnds
[2*j
]-bnds
[2*i
])) k
++;
470 if(bnds
[2*j
+1]*(x
-bnds
[2*i
])+bnds
[2*i
+1]*(bnds
[2*j
]-x
)>y
*(bnds
[2*j
]-bnds
[2*i
])) k
--;
478 #if VOROPP_VERBOSE >=2
479 if(k
<0) fprintf(stderr
,"Negative winding number of %d for (%g,%g)\n",j
,x
,y
);
480 else if(k
>1) fprintf(stderr
,"Winding number of %d for (%g,%g)\n",j
,x
,y
);
485 template<class v_cell_2d
>
486 bool container_boundary_2d::boundary_cuts(v_cell_2d
&c
,int ij
,double x
,double y
) {
488 double lx
,ly
,dx
,dy
,dr
;
489 for(i
=2;i
<*(wid
[ij
])+2;i
++) {
490 j
=2*wid
[ij
][i
];k
=2*edb
[j
];
491 dx
=bnds
[k
]-bnds
[j
];dy
=bnds
[k
+1]-bnds
[j
+1];
492 dr
=dy
*(bnds
[j
]-x
)-dx
*(bnds
[j
+1]-y
);
493 if(dr
<tolerance
) continue;
494 lx
=bnds
[j
]+bnds
[k
]-2*x
;
495 ly
=bnds
[j
+1]+bnds
[k
+1]-2*y
;
496 if(lx
*lx
+ly
*ly
>dx
*dx
+dy
*dy
) continue;
497 if(!c
.plane(dy
,-dx
,2*dr
)) return false;
502 bool container_boundary_2d::skip(int ij
,int q
,double x
,double y
) {
504 double wx1
,wy1
,wx2
,wy2
,dx
,dy
,lx
,ly
;
505 double cx
=p
[ij
][ps
*q
],cy
=p
[ij
][ps
*q
+1];
507 for(int i
=0;i
<nlab
[ij
][q
];i
++) {
517 if(dx
*wy1
-dy
*wx1
>tolerance
) {
519 if(wx1
*ly
-wy1
*lx
>tolerance
&&lx
*(wy2
-y
)-ly
*(wx2
-x
)>tolerance
) return true;
526 /** Imports a list of particles from an input stream.
527 * \param[in] fp a file handle to read from. */
528 void container_boundary_2d::import(FILE *fp
) {
531 char *buf(new char[512]);
533 while(fgets(buf
,512,fp
)!=NULL
) {
534 if(strcmp(buf
,"#Start\n")==0||strcmp(buf
,"# Start\n")==0) {
536 // Check that two consecutive start tokens haven't been
538 if(boundary_track
!=-1) voro_fatal_error("File import error - two consecutive start tokens found",VOROPP_FILE_ERROR
);
541 } else if(strcmp(buf
,"#End\n")==0||strcmp(buf
,"# End\n")==0||
542 strcmp(buf
,"#End")==0||strcmp(buf
,"# End")==0) {
544 // Check that two consecutive end tokens haven't been
546 if(boundary_track
==-1) voro_fatal_error("File import error - found end token without start token",VOROPP_FILE_ERROR
);
550 // Try and read three entries from the line
551 if(sscanf(buf
,"%d %lg %lg",&i
,&x
,&y
)!=3) voro_fatal_error("File import error - can't parse particle information",VOROPP_FILE_ERROR
);
555 if(boundary_track
!=-1) voro_fatal_error("File import error - end of file reached without finding end token",VOROPP_FILE_ERROR
);
557 if(!feof(fp
)) voro_fatal_error("File import error - error reading string from file",VOROPP_FILE_ERROR
);
561 void container_boundary_2d::end_boundary() {
562 if(boundary_track
!=edbc
) {
563 edb
[2*boundary_track
+1]=edbc
-1;
564 edb
[2*(edbc
-1)]=boundary_track
;
569 void container_boundary_2d::register_boundary(double x
,double y
) {
570 if(edbc
==edbm
) add_boundary_memory();
571 if(edbc
!=boundary_track
) {
573 edb
[2*edbc
+1]=edbc
-1;
576 bnds
[2*(edbc
++)+1]=y
;
579 /** Increases the size of the temporary label memory. */
580 void container_boundary_2d::add_temporary_label_memory() {
583 if(size
>3*max_temp_label_size
)
584 voro_fatal_error("Absolute temporary label memory allocation exceeded",VOROPP_MEMORY_ERROR
);
585 #if VOROPP_VERBOSE >=3
586 fprintf(stderr
,"Temporary label memory in region scaled up to %d\n",size
);
588 int *ntmp(new int[size
]),*tp(tmp
);tmpp
=ntmp
;
589 while(tp
<tmpe
) *(tmpp
++)=*(tp
++);
591 tmp
=ntmp
;tmpe
=tmp
+size
;
594 /** Increases the memory allocation for the boundary points. */
595 void container_boundary_2d::add_boundary_memory() {
598 if(edbm
>max_boundary_size
)
599 voro_fatal_error("Absolute boundary memory allocation exceeded",VOROPP_MEMORY_ERROR
);
600 #if VOROPP_VERBOSE >=3
601 fprintf(stderr
,"Boundary memory scaled up to %d\n",size
);
604 // Reallocate the boundary vertex information
605 double *nbnds(new double[2*edbm
]);
606 for(i
=0;i
<2*edbc
;i
++) nbnds
[i
]=bnds
[i
];
607 delete [] nbnds
;bnds
=nbnds
;
609 // Reallocate the edge information
610 int *nedb(new int[2*edbm
]);
611 for(i
=0;i
<2*edbc
;i
++) nedb
[i
]=edb
[i
];
612 delete [] edb
;edb
=nedb
;
619 // Explicit instantiation
620 template bool container_boundary_2d::boundary_cuts(voronoicell_nonconvex_2d
&,int,double,double);
621 template bool container_boundary_2d::boundary_cuts(voronoicell_nonconvex_neighbor_2d
&,int,double,double);