X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=blobdiff_plain;f=src%2Fgromacs%2Fgmxana%2Fgmx_density.cpp;fp=src%2Fgromacs%2Fgmxana%2Fgmx_density.c;h=f63db4e7f836c5f58fdfea6c380c8477c0137331;hb=c3f2d46e4047f0c465f7234b3784a2fa6f02a065;hp=29bd719c4380249654e5134386405de7e8543bce;hpb=0595b4a4c763a0bc574658992081abf8b0abc3fe;p=alexxy%2Fgromacs.git diff --git a/src/gromacs/gmxana/gmx_density.c b/src/gromacs/gmxana/gmx_density.cpp similarity index 96% rename from src/gromacs/gmxana/gmx_density.c rename to src/gromacs/gmxana/gmx_density.cpp index 29bd719c43..f63db4e7f8 100644 --- a/src/gromacs/gmxana/gmx_density.c +++ b/src/gromacs/gmxana/gmx_density.cpp @@ -36,10 +36,10 @@ */ #include "gmxpre.h" -#include -#include -#include -#include +#include +#include +#include +#include #include "gromacs/commandline/pargs.h" #include "gromacs/fileio/trxio.h" @@ -57,6 +57,7 @@ #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" +#include "gromacs/utility/gmxassert.h" #include "gromacs/utility/smalloc.h" typedef struct { @@ -75,7 +76,7 @@ int compare(void *a, void *b) t_electron *tmp1, *tmp2; tmp1 = (t_electron *)a; tmp2 = (t_electron *)b; - return strcmp(tmp1->atomname, tmp2->atomname); + return std::strcmp(tmp1->atomname, tmp2->atomname); } int get_electrons(t_electron **eltab, const char *fn) @@ -204,7 +205,7 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[], if (!*nslices) { - *nslices = (int)(box[axis][axis] * 10); /* default value */ + *nslices = static_cast(box[axis][axis] * 10); /* default value */ fprintf(stderr, "\nDividing the box in %d slices\n", *nslices); } @@ -265,11 +266,11 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[], /* determine which slice atom is in */ if (bCenter) { - slice = floor( (z-(boxSz/2.0)) / (*slWidth) ) + *nslices/2; + slice = static_cast(std::floor( (z-(boxSz/2.0)) / (*slWidth) ) + *nslices/2); } else { - slice = (z / (*slWidth)); + slice = static_cast(z / (*slWidth)); } sought.nr_el = 0; sought.atomname = gmx_strdup(*(top->atoms.atomname[index[n][i]])); @@ -336,15 +337,12 @@ void calc_density(const char *fn, atom_id **index, int gnx[], double invvol; int natoms; /* nr. atoms in trj */ t_trxstatus *status; - int **slCount, /* nr. of atoms in one slice for a group */ - i, j, n, /* loop indices */ - ax1 = 0, ax2 = 0, + int i, n, /* loop indices */ nr_frames = 0, /* number of frames */ slice; /* current slice */ real t, z; real boxSz, aveBox; - char *buf; /* for tmp. keeping atomname */ gmx_rmpbc_t gpbc = NULL; if (axis < 0 || axis >= DIM) @@ -361,7 +359,7 @@ void calc_density(const char *fn, atom_id **index, int gnx[], if (!*nslices) { - *nslices = (int)(box[axis][axis] * 10); /* default value */ + *nslices = static_cast(box[axis][axis] * 10); /* default value */ fprintf(stderr, "\nDividing the box in %d slices\n", *nslices); } @@ -422,11 +420,11 @@ void calc_density(const char *fn, atom_id **index, int gnx[], /* determine which slice atom is in */ if (bCenter) { - slice = floor( (z-(boxSz/2.0)) / (*slWidth) ) + *nslices/2; + slice = static_cast(std::floor( (z-(boxSz/2.0)) / (*slWidth) ) + *nslices/2); } else { - slice = floor(z / (*slWidth)); + slice = static_cast(std::floor(z / (*slWidth))); } /* Slice should already be 0<=slice 1) ? "s" : "");