~ubuntu-branches/ubuntu/vivid/travis/vivid-proposed

« back to all changes in this revision

Viewing changes to src/v_common.cpp

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert, Daniel Leidert, Michael Banck
  • Date: 2014-09-22 10:00:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20140922100017-voentkpft033vxa6
Tags: 140902-1
* New upstream release.

[ Daniel Leidert ]
* debian/copyright: Updated.
* debian/upstream: Renamed to debian/upstream/metadata.

[ Michael Banck ]
* debian/travis.1: Add LAMMPS and DLPOLY to trajectory filetypes and
  document -stream option.
* debian/control (Description): List supported fileteypes and
  available analysis features.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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     : August 30th 2011
6
 
 
7
 
/** \file common.cc
8
 
 * \brief Implementations of the small helper functions. */
9
 
 
10
 
#include "v_common.h"
11
 
 
12
 
 
13
 
/** \brief Prints a vector of integers.
14
 
 *
15
 
 * Prints a vector of integers.
16
 
 * \param[in] v the vector to print.
17
 
 * \param[in] fp the file stream to print to. */
18
 
void voro_print_vector(vector<int> &v,FILE *fp) {
19
 
        int k=0,s=v.size();
20
 
        while(k+4<s) {
21
 
                fprintf(fp,"%d %d %d %d ",v[k],v[k+1],v[k+2],v[k+3]);
22
 
                k+=4;
23
 
        }
24
 
        if(k+3<=s) {
25
 
                if(k+4==s) fprintf(fp,"%d %d %d %d",v[k],v[k+1],v[k+2],v[k+3]);
26
 
                else fprintf(fp,"%d %d %d",v[k],v[k+1],v[k+2]);
27
 
        } else {
28
 
                if(k+2==s) fprintf(fp,"%d %d",v[k],v[k+1]);
29
 
                else fprintf(fp,"%d",v[k]);
30
 
        }
31
 
}
32
 
 
33
 
/** \brief Prints a vector of doubles.
34
 
 *
35
 
 * Prints a vector of doubles.
36
 
 * \param[in] v the vector to print.
37
 
 * \param[in] fp the file stream to print to. */
38
 
void voro_print_vector(vector<double> &v,FILE *fp) {
39
 
        int k=0,s=v.size();
40
 
        while(k+4<s) {
41
 
                fprintf(fp,"%g %g %g %g ",v[k],v[k+1],v[k+2],v[k+3]);
42
 
                k+=4;
43
 
        }
44
 
        if(k+3<=s) {
45
 
                if(k+4==s) fprintf(fp,"%g %g %g %g",v[k],v[k+1],v[k+2],v[k+3]);
46
 
                else fprintf(fp,"%g %g %g",v[k],v[k+1],v[k+2]);
47
 
        } else {
48
 
                if(k+2==s) fprintf(fp,"%g %g",v[k],v[k+1]);
49
 
                else fprintf(fp,"%g",v[k]);
50
 
        }
51
 
}
52
 
 
53
 
/** \brief Prints a vector a face vertex information.
54
 
 *
55
 
 * Prints a vector of face vertex information. A value is read, which
56
 
 * corresponds to the number of vertices in the next face. The routine reads
57
 
 * this number of values and prints them as a bracked list. This is repeated
58
 
 * until the end of the vector is reached.
59
 
 * \param[in] v the vector to interpret and print.
60
 
 * \param[in] fp the file stream to print to. */
61
 
void voro_print_face_vertices(vector<int> &v,FILE *fp) {
62
 
        int j,k=0,l;
63
 
        if(v.size()>0) {
64
 
                l=v[k++];
65
 
                if(l<=1) {
66
 
                        if(l==1) fprintf(fp,"(%d)",v[k++]);
67
 
                        else fputs("()",fp);
68
 
                } else {
69
 
                        j=k+l;
70
 
                        fprintf(fp,"(%d",v[k++]);
71
 
                        while(k<j) fprintf(fp,",%d",v[k++]);
72
 
                        fputs(")",fp);
73
 
                }
74
 
                while((unsigned int) k<v.size()) {
75
 
                        l=v[k++];
76
 
                        if(l<=1) {
77
 
                                if(l==1) fprintf(fp," (%d)",v[k++]);
78
 
                                else fputs(" ()",fp);
79
 
                        } else {
80
 
                                j=k+l;
81
 
                                fprintf(fp," (%d",v[k++]);
82
 
                                while(k<j) fprintf(fp,",%d",v[k++]);
83
 
                                fputs(")",fp);
84
 
                        }
85
 
                }
86
 
        }
87
 
}
88