From bfddb708b2491c57b0595383c7f5b20abf4fd70f Mon Sep 17 00:00:00 2001 From: toshinagata1964 Date: Sun, 16 Nov 2014 15:47:03 +0000 Subject: [PATCH] Handling of the surface normals was incomplete. Fixed. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@587 a2be9bc6-48de-4e38-9406-05402d4bc13c --- MolLib/Molecule.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MolLib/Molecule.c b/MolLib/Molecule.c index 043b4c1..90b4382 100755 --- a/MolLib/Molecule.c +++ b/MolLib/Molecule.c @@ -1858,6 +1858,7 @@ MoleculeLoadMbsfFile(Molecule *mp, const char *fname, char **errbuf) break; if (mp->mview == NULL) continue; /* Skip */ + redo: if (strcmp(buf, "line\n") == 0) { ibuf[0] = kMainViewGraphicLine; } else if (strcmp(buf, "poly\n") == 0) { @@ -1918,12 +1919,12 @@ MoleculeLoadMbsfFile(Molecule *mp, const char *fname, char **errbuf) } if (j > 0) NewArray(&gp->normals, &gp->nnormals, sizeof(GLfloat) * 3, j); - } else if (i >= gp->npoints + 3 && i < gp->npoints + gp->nnormals + 3) { + } else if (i >= gp->npoints + 4 && i < gp->npoints + gp->nnormals + 4) { if (sscanf(buf, "%lf %lf %lf", &dbuf[0], &dbuf[1], &dbuf[2]) < 3) { s_append_asprintf(errbuf, "line %d: the normal vector cannot be read for graphic object", lineNumber); goto err_exit; } - j = (i - gp->npoints - 3) * 3; + j = (i - gp->npoints - 4) * 3; gp->normals[j++] = dbuf[0]; gp->normals[j++] = dbuf[1]; gp->normals[j] = dbuf[2]; @@ -1932,8 +1933,9 @@ MoleculeLoadMbsfFile(Molecule *mp, const char *fname, char **errbuf) } MainView_insertGraphic(mp->mview, -1, gp); free(gp); - if (buf[0] == '\n') + if (buf[0] == '\n' || buf[0] == 0) break; + goto redo; } continue; } else if (strncmp(buf, "!:@", 3) == 0) { -- 2.11.0