Bugfix in search_for_outside_edge routine.
[voro++.git] / branches / 2d_boundary / src / common.cc
blobf4285d7b8ee61ca1699845275935ada9e9da9b1b
1 // Voro++, a 3D cell-based Voronoi library
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : May 18th 2011
7 /** \file common.cc
8 * \brief Implementations of the small helper functions. */
10 #include "common.hh"
12 /** \brief Prints a vector of integers.
14 * Prints a vector of integers.
15 * \param[in] v the vector to print.
16 * \param[in] fp the file stream to print to. */
17 void voropp_print_vector(vector<int> &v,FILE *fp) {
18 int k(0),s(v.size());
19 while(k+4<s) {
20 fprintf(fp,"%d %d %d %d ",v[k],v[k+1],v[k+2],v[k+3]);
21 k+=4;
23 if(k+3<=s) {
24 if(k+4==s) fprintf(fp,"%d %d %d %d",v[k],v[k+1],v[k+2],v[k+3]);
25 else fprintf(fp,"%d %d %d",v[k],v[k+1],v[k+2]);
26 } else {
27 if(k+2==s) fprintf(fp,"%d %d",v[k],v[k+1]);
28 else fprintf(fp,"%d",v[k]);
32 /** \brief Prints a vector of doubles.
34 * Prints a vector of doubles.
35 * \param[in] v the vector to print.
36 * \param[in] fp the file stream to print to. */
37 void voropp_print_vector(vector<double> &v,FILE *fp) {
38 int k(0),s(v.size());
39 while(k+4<s) {
40 fprintf(fp,"%g %g %g %g ",v[k],v[k+1],v[k+2],v[k+3]);
41 k+=4;
43 if(k+3<=s) {
44 if(k+4==s) fprintf(fp,"%g %g %g %g",v[k],v[k+1],v[k+2],v[k+3]);
45 else fprintf(fp,"%g %g %g",v[k],v[k+1],v[k+2]);
46 } else {
47 if(k+2==s) fprintf(fp,"%g %g",v[k],v[k+1]);
48 else fprintf(fp,"%g",v[k]);