ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/parser.c
(Generate patch)

Comparing ray/src/cv/mgflib/parser.c (file contents):
Revision 1.9 by greg, Sat Jun 25 16:33:09 1994 UTC vs.
Revision 1.10 by greg, Wed Jun 29 16:15:20 1994 UTC

# Line 187 | Line 187 | char   *name;
187   }
188  
189  
190 < static int
191 < handle_it(en, ac, av)           /* pass entity to appropriate handler */
190 > int
191 > mg_handle(en, ac, av)           /* pass entity to appropriate handler */
192   register int    en;
193   int     ac;
194   char    **av;
# Line 210 | Line 210 | mg_open(ctx, fn)                       /* open new input file */
210   register MG_FCTXT       *ctx;
211   char    *fn;
212   {
213 +        static int      nfids;
214          int     olen;
215          register char   *cp;
216  
217 +        ctx->fid = ++nfids;
218          ctx->lineno = 0;
219          if (fn == NULL) {
220                  strcpy(ctx->fname, "<stdin>");
# Line 251 | Line 253 | mg_close()                     /* close input file */
253   }
254  
255  
256 + void
257 + mg_fgetpos(pos)                 /* get current position in input file */
258 + register MG_FPOS        *pos;
259 + {
260 +        extern long     ftell();
261 +
262 +        pos->fid = mg_file->fid;
263 +        pos->lineno = mg_file->lineno;
264 +        pos->offset = ftell(mg_file->fp);
265 + }
266 +
267 +
268   int
269 < mg_rewind()                     /* rewind input file */
269 > mg_fgoto(pos)                   /* reposition input file pointer */
270 > register MG_FPOS        *pos;
271   {
272 <        if (mg_file->lineno == 0)
272 >        if (pos->fid != mg_file->fid)
273 >                return(MG_ESEEK);
274 >        if (pos->lineno == mg_file->lineno)
275                  return(MG_OK);
276          if (mg_file->fp == stdin)
277                  return(MG_ESEEK);       /* cannot seek on standard input */
278 <        if (fseek(mg_file->fp, 0L, 0) == EOF)
278 >        if (fseek(mg_file->fp, pos->offset, 0) == EOF)
279                  return(MG_ESEEK);
280 <        mg_file->lineno = 0;
280 >        mg_file->lineno = pos->lineno;
281          return(MG_OK);
282   }
283  
# Line 309 | Line 326 | mg_parse()                     /* parse current input line */
326                  return(MG_OK);          /* no words in line */
327          *ap = NULL;
328                                          /* else handle it */
329 <        return(handle_it(-1, ap-argv, argv));
329 >        return(mg_handle(-1, ap-argv, argv));
330   }
331  
332  
# Line 344 | Line 361 | mg_clear()                     /* clear parser history */
361   }
362  
363  
347 int
348 mg_iterate(ac, av, f)           /* iterate on statement */
349 int     ac;
350 register char   **av;
351 int     (*f)();
352 {
353        int     niter, rval;
354        register int    i, j;
355        char    *argv[MG_MAXARGC];
356        char    cntbuf[10];
357                                        /* build partial transformation */
358        for (i = 0; i < ac; i++) {
359                if (av[i][0] == '-' && av[i][1] == 'a' && av[i][2] == '\0')
360                        break;
361                argv[i+1] = av[i];
362        }
363        argv[i+1] = NULL;
364        if (i) {                        /* handle transformation */
365                argv[0] = mg_ename[MG_E_XF];
366                if ((rval = handle_it(MG_E_XF, i+1, argv)) != MG_OK)
367                        return(rval);
368        }
369        if (i < ac) {                   /* run array */
370                if (i+1 >= ac || !isint(av[i+1]))
371                        return(MG_ETYPE);
372                niter = atoi(av[i+1]);
373                argv[0] = mg_ename[MG_E_OBJECT];
374                argv[1] = cntbuf;
375                for (j = 2; j+i < ac; j++)
376                        argv[j] = av[j+i];
377                argv[j] = NULL;
378                for (j = 0; j < niter; j++) {
379                        sprintf(cntbuf, "%d", j);
380                        if ((rval = handle_it(MG_E_OBJECT, 2, argv)) != MG_OK)
381                                return(rval);
382                        argv[0] = "-i";
383                        if ((rval = mg_iterate(ac-i, argv, f)) != MG_OK)
384                                return(rval);
385                        argv[0] = mg_ename[MG_E_OBJECT];
386                        if ((rval = handle_it(MG_E_OBJECT, 1, argv)) != MG_OK)
387                                return(rval);
388                }
389        } else if ((rval = (*f)()) != MG_OK)    /* else do this instance */
390                        return(rval);
391        if (i) {                        /* reset the transform */
392                argv[0] = mg_ename[MG_E_XF];
393                argv[1] = NULL;
394                (void)handle_it(MG_E_XF, 1, argv);
395        }
396        return(MG_OK);
397 }
398
399
364   /****************************************************************************
365   *      The following routines handle unsupported entities
366   */
# Line 412 | Line 376 | char   **av;
376  
377  
378   static int
415 reload_file()                   /* reload current MGF file */
416 {
417        register int    rval;
418
419        if ((rval = mg_rewind()) != MG_OK)
420                return(rval);
421        while (mg_read())
422                if ((rval = mg_parse()) != MG_OK)
423                        return(rval);
424        return(MG_OK);
425 }
426
427
428 static int
379   e_include(ac, av)               /* include file */
380   int     ac;
381   char    **av;
382   {
383 +        char    *xfarg[MG_MAXARGC];
384          MG_FCTXT        ictx;
385          int     rv;
386  
# Line 437 | Line 388 | char   **av;
388                  return(MG_EARGC);
389          if ((rv = mg_open(&ictx, av[1])) != MG_OK)
390                  return(rv);
391 <        if ((rv = mg_iterate(ac-2, av+2, reload_file)) != MG_OK) {
392 <                fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname,
393 <                                ictx.lineno, mg_err[rv], ictx.inpline);
394 <                mg_close();
395 <                return(MG_EINCL);
391 >        if (ac > 2) {
392 >                register int    i;
393 >
394 >                xfarg[0] = mg_ename[MG_E_XF];
395 >                for (i = 1; i < ac-1; i++)
396 >                        xfarg[i] = av[i+1];
397 >                xfarg[ac-1] = NULL;
398 >                if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK)
399 >                        return(rv);
400          }
401 +        while (!feof(mg_file->fp)) {
402 +                while (mg_read())
403 +                        if ((rv = mg_parse()) != MG_OK) {
404 +                                fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname,
405 +                                                ictx.lineno, mg_err[rv],
406 +                                                ictx.inpline);
407 +                                mg_close();
408 +                                return(MG_EINCL);
409 +                        }
410 +                if (ac > 2)
411 +                        if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK)
412 +                                return(rv);
413 +        }
414          mg_close();
415          return(MG_OK);
416   }
# Line 490 | Line 458 | char   **av;
458          rad = atof(av[2]);
459                                          /* initialize */
460          warpconends = 1;
461 <        if ((rval = handle_it(MG_E_VERTEX, 3, v2ent)) != MG_OK)
461 >        if ((rval = mg_handle(MG_E_VERTEX, 3, v2ent)) != MG_OK)
462                  return(rval);
463          sprintf(p2x, FLTFMT, cv->p[0]);
464          sprintf(p2y, FLTFMT, cv->p[1]);
465          sprintf(p2z, FLTFMT, cv->p[2]+rad);
466 <        if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
466 >        if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
467                  return(rval);
468          r2[0] = '0'; r2[1] = '\0';
469          for (i = 1; i <= 2*mg_nqcdivs; i++) {
470                  theta = i*(PI/2)/mg_nqcdivs;
471 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
471 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
472                          return(rval);
473                  sprintf(p2z, FLTFMT, cv->p[2]+rad*cos(theta));
474 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
474 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
475                          return(rval);
476 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
476 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
477                          return(rval);
478                  strcpy(r1, r2);
479                  sprintf(r2, FLTFMT, rad*sin(theta));
480 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
480 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
481                          return(rval);
482          }
483          warpconends = 0;
# Line 564 | Line 532 | char   **av;
532          for (j = 0; j < 3; j++)
533                  sprintf(p2[j], FLTFMT, cv->p[j] +
534                                  .5*sgn*(maxrad-minrad)*cv->n[j]);
535 <        if ((rval = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
535 >        if ((rval = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
536                  return(rval);
537 <        if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
537 >        if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
538                  return(rval);
539          sprintf(r2, FLTFMT, avgrad=.5*(minrad+maxrad));
540                                          /* run outer section */
541          for (i = 1; i <= 2*mg_nqcdivs; i++) {
542                  theta = i*(PI/2)/mg_nqcdivs;
543 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
543 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
544                          return(rval);
545                  for (j = 0; j < 3; j++)
546                          sprintf(p2[j], FLTFMT, cv->p[j] +
547                                  .5*sgn*(maxrad-minrad)*cos(theta)*cv->n[j]);
548 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
548 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
549                          return(rval);
550 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
550 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
551                          return(rval);
552                  strcpy(r1, r2);
553                  sprintf(r2, FLTFMT, avgrad + .5*(maxrad-minrad)*sin(theta));
554 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
554 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
555                          return(rval);
556          }
557                                          /* run inner section */
# Line 593 | Line 561 | char   **av;
561                  for (j = 0; j < 3; j++)
562                          sprintf(p2[j], FLTFMT, cv->p[j] +
563                                  .5*sgn*(maxrad-minrad)*cos(theta)*cv->n[j]);
564 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
564 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
565                          return(rval);
566 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
566 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
567                          return(rval);
568 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
568 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
569                          return(rval);
570                  strcpy(r1, r2);
571                  sprintf(r2, FLTFMT, -avgrad - .5*(maxrad-minrad)*sin(theta));
572 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
572 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
573                          return(rval);
574          }
575          warpconends = 0;
# Line 622 | Line 590 | char   **av;
590          avnew[2] = av[2];
591          avnew[3] = av[3];
592          avnew[4] = av[2];
593 <        return(handle_it(MG_E_CONE, 5, avnew));
593 >        return(mg_handle(MG_E_CONE, 5, avnew));
594   }
595  
596  
# Line 664 | Line 632 | char   **av;
632          make_axes(u, v, cv->n);
633          for (j = 0; j < 3; j++)
634                  sprintf(p3[j], FLTFMT, cv->p[j] + maxrad*u[j]);
635 <        if ((rv = handle_it(MG_E_VERTEX, 3, v3ent)) != MG_OK)
635 >        if ((rv = mg_handle(MG_E_VERTEX, 3, v3ent)) != MG_OK)
636                  return(rv);
637 <        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
637 >        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
638                  return(rv);
639          if (minrad == 0.) {             /* closed */
640                  v1ent[3] = av[1];
641 <                if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
641 >                if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
642                          return(rv);
643 <                if ((rv = handle_it(MG_E_NORMAL, 4, nzent)) != MG_OK)
643 >                if ((rv = mg_handle(MG_E_NORMAL, 4, nzent)) != MG_OK)
644                          return(rv);
645                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
646                          theta = i*(PI/2)/mg_nqcdivs;
647 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
647 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
648                                  return(rv);
649                          for (j = 0; j < 3; j++)
650                                  sprintf(p3[j], FLTFMT, cv->p[j] +
651                                                  maxrad*u[j]*cos(theta) +
652                                                  maxrad*v[j]*sin(theta));
653 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
653 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
654                                  return(rv);
655 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
655 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
656                                  return(rv);
657 <                        if ((rv = handle_it(MG_E_FACE, 4, fent)) != MG_OK)
657 >                        if ((rv = mg_handle(MG_E_FACE, 4, fent)) != MG_OK)
658                                  return(rv);
659                  }
660          } else {                        /* open */
661 <                if ((rv = handle_it(MG_E_VERTEX, 3, v4ent)) != MG_OK)
661 >                if ((rv = mg_handle(MG_E_VERTEX, 3, v4ent)) != MG_OK)
662                          return(rv);
663                  for (j = 0; j < 3; j++)
664                          sprintf(p4[j], FLTFMT, cv->p[j] + minrad*u[j]);
665 <                if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
665 >                if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
666                          return(rv);
667                  v1ent[3] = "_rv4";
668                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
669                          theta = i*(PI/2)/mg_nqcdivs;
670 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
670 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
671                                  return(rv);
672 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
672 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
673                                  return(rv);
674                          for (j = 0; j < 3; j++) {
675                                  d = u[j]*cos(theta) + v[j]*sin(theta);
676                                  sprintf(p3[j], FLTFMT, cv->p[j] + maxrad*d);
677                                  sprintf(p4[j], FLTFMT, cv->p[j] + minrad*d);
678                          }
679 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
679 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
680                                  return(rv);
681 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
681 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
682                                  return(rv);
683 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v4ent)) != MG_OK)
683 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v4ent)) != MG_OK)
684                                  return(rv);
685 <                        if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
685 >                        if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
686                                  return(rv);
687 <                        if ((rv = handle_it(MG_E_FACE, 5, fent)) != MG_OK)
687 >                        if ((rv = mg_handle(MG_E_FACE, 5, fent)) != MG_OK)
688                                  return(rv);
689                  }
690          }
# Line 798 | Line 766 | char   **av;
766                  else
767                          sprintf(n3[j], FLTFMT, u[j] + w[j]*n2off);
768          }
769 <        if ((rv = handle_it(MG_E_VERTEX, 3, v3ent)) != MG_OK)
769 >        if ((rv = mg_handle(MG_E_VERTEX, 3, v3ent)) != MG_OK)
770                  return(rv);
771 <        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
771 >        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
772                  return(rv);
773 <        if ((rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
773 >        if ((rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
774                  return(rv);
775          if (rad1 == 0.) {               /* triangles */
776                  v1ent[3] = av[1];
777 <                if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
777 >                if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
778                          return(rv);
779                  for (j = 0; j < 3; j++)
780                          sprintf(n4[j], FLTFMT, w[j]);
781 <                if ((rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
781 >                if ((rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
782                          return(rv);
783                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
784                          theta = sgn*i*(PI/2)/mg_nqcdivs;
785 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
785 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
786                                  return(rv);
787                          for (j = 0; j < 3; j++) {
788                                  d = u[j]*cos(theta) + v[j]*sin(theta);
# Line 822 | Line 790 | char   **av;
790                                  if (n2off > -FHUGE)
791                                          sprintf(n3[j], FLTFMT, d + w[j]*n2off);
792                          }
793 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
793 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
794                                  return(rv);
795 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
795 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
796                                  return(rv);
797                          if (n2off > -FHUGE &&
798 <                        (rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
798 >                        (rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
799                                  return(rv);
800 <                        if ((rv = handle_it(MG_E_FACE, 4, fent)) != MG_OK)
800 >                        if ((rv = mg_handle(MG_E_FACE, 4, fent)) != MG_OK)
801                                  return(rv);
802                  }
803          } else {                        /* quads */
# Line 848 | Line 816 | char   **av;
816                          else
817                                  sprintf(n4[j], FLTFMT, u[j] + w[j]*n1off);
818                  }
819 <                if ((rv = handle_it(MG_E_VERTEX, 3, v4ent)) != MG_OK)
819 >                if ((rv = mg_handle(MG_E_VERTEX, 3, v4ent)) != MG_OK)
820                          return(rv);
821 <                if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
821 >                if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
822                          return(rv);
823 <                if ((rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
823 >                if ((rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
824                          return(rv);
825                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
826                          theta = sgn*i*(PI/2)/mg_nqcdivs;
827 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
827 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
828                                  return(rv);
829 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
829 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
830                                  return(rv);
831                          for (j = 0; j < 3; j++) {
832                                  d = u[j]*cos(theta) + v[j]*sin(theta);
# Line 869 | Line 837 | char   **av;
837                                  if (n1off < FHUGE)
838                                          sprintf(n4[j], FLTFMT, d + w[j]*n1off);
839                          }
840 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
840 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
841                                  return(rv);
842 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
842 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
843                                  return(rv);
844                          if (n2off > -FHUGE &&
845 <                        (rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
845 >                        (rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
846                                  return(rv);
847 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v4ent)) != MG_OK)
847 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v4ent)) != MG_OK)
848                                  return(rv);
849 <                        if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
849 >                        if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
850                                  return(rv);
851                          if (n1off < FHUGE &&
852 <                        (rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
852 >                        (rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
853                                  return(rv);
854 <                        if ((rv = handle_it(MG_E_FACE, 5, fent)) != MG_OK)
854 >                        if ((rv = mg_handle(MG_E_FACE, 5, fent)) != MG_OK)
855                                  return(rv);
856                  }
857          }
# Line 919 | Line 887 | char   **av;
887          for (i = 1; i < ac-1; i++)
888                  newav[i] = av[i];
889          newav[i] = NULL;
890 <        if ((rv = handle_it(MG_E_FACE, i, newav)) != MG_OK)
890 >        if ((rv = mg_handle(MG_E_FACE, i, newav)) != MG_OK)
891                  return(rv);
892                                          /* compute face normal */
893          if ((cv0 = c_getvert(av[1])) == NULL)
# Line 944 | Line 912 | char   **av;
912          for (i = 1; i < ac-1; i++) {
913                  sprintf(nvn[i-1], "_pv%d", i);
914                  vent[1] = nvn[i-1];
915 <                if ((rv = handle_it(MG_E_VERTEX, 3, vent)) != MG_OK)
915 >                if ((rv = mg_handle(MG_E_VERTEX, 3, vent)) != MG_OK)
916                          return(rv);
917                  cv = c_getvert(av[i]);          /* checked above */
918                  for (j = 0; j < 3; j++)
919                          sprintf(p[j], FLTFMT, cv->p[j] - length*norm[j]);
920 <                if ((rv = handle_it(MG_E_POINT, 4, pent)) != MG_OK)
920 >                if ((rv = mg_handle(MG_E_POINT, 4, pent)) != MG_OK)
921                          return(rv);
922                  newav[ac-1-i] = nvn[i-1];       /* reverse */
923          }
924                                                  /* do top face */
925 <        if ((rv = handle_it(MG_E_FACE, ac-1, newav)) != MG_OK)
925 >        if ((rv = mg_handle(MG_E_FACE, ac-1, newav)) != MG_OK)
926                  return(rv);
927                                                  /* do the side faces */
928          newav[5] = NULL;
# Line 963 | Line 931 | char   **av;
931          for (i = 1; i < ac-1; i++) {
932                  newav[1] = nvn[i-1];
933                  newav[2] = av[i];
934 <                if ((rv = handle_it(MG_E_FACE, 5, newav)) != MG_OK)
934 >                if ((rv = mg_handle(MG_E_FACE, 5, newav)) != MG_OK)
935                          return(rv);
936                  newav[3] = newav[2];
937                  newav[4] = newav[1];
# Line 986 | Line 954 | char   **av;
954          if (mg_ehand[MG_E_CXY] != c_hcolor) {
955                  sprintf(xbuf, "%.4f", c_ccolor->cx);
956                  sprintf(ybuf, "%.4f", c_ccolor->cy);
957 <                if ((rv = handle_it(MG_E_CXY, 3, ccom)) != MG_OK)
957 >                if ((rv = mg_handle(MG_E_CXY, 3, ccom)) != MG_OK)
958                          return(rv);
959          }
960          return(MG_OK);
# Line 1026 | Line 994 | char   **av;
994                                  newav[i+3] = vbuf[i];
995                          }
996                          newav[C_CNSS+3] = NULL;
997 <                        if ((rv = handle_it(MG_E_CSPEC, C_CNSS+3, newav)) != MG_OK)
997 >                        if ((rv = mg_handle(MG_E_CSPEC, C_CNSS+3, newav)) != MG_OK)
998                                  return(rv);
999                  }
1000                  return(MG_OK);
# Line 1038 | Line 1006 | char   **av;
1006                  newav[1] = vbuf[0];
1007                  newav[2] = vbuf[1];
1008                  newav[3] = NULL;
1009 <                if ((rv = handle_it(MG_E_CXY, 3, newav)) != MG_OK)
1009 >                if ((rv = mg_handle(MG_E_CXY, 3, newav)) != MG_OK)
1010                          return(rv);
1011          }
1012          return(MG_OK);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines