OSDN Git Service

Handling of the surface normals was incomplete. Fixed.
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sun, 16 Nov 2014 15:47:03 +0000 (15:47 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sun, 16 Nov 2014 15:47:03 +0000 (15:47 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@587 a2be9bc6-48de-4e38-9406-05402d4bc13c

MolLib/Molecule.c

index 043b4c1..90b4382 100755 (executable)
@@ -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) {