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

Comparing ray/src/cv/arch2rad.c (file contents):
Revision 1.1 by greg, Tue Dec 11 08:45:46 1990 UTC vs.
Revision 2.2 by greg, Sat Feb 22 02:07:23 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1990 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Convert Architrion file to Radiance
6   *
# Line 12 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9  
10   #include <stdio.h>
11  
12 + #include <stdlib.h>
13 +
14   #include "trans.h"
15  
16   #define DEFMAPFILE      "/usr/local/lib/ray/lib/arch.map"
# Line 194 | Line 193 | FILE   *fp;
193   {
194          char    buf[MAXSTR];
195          int     i, n;
196 +        register int    c;
197                                          /* get file name */
198          if (fgets(buf, MAXSTR, fp) == NULL)
199                  goto readerr;
200 <        if ((n = strlen(buf)) < 1)
201 <                goto readerr;
202 <        buf[n-1] = '\0';
200 >        buf[strlen(buf)-1] = '\0';
201          fhead.filename = savestr(buf);
202                                          /* get layers */
203          fhead.layer[0] = "Worksheet";
204          for (i = 1; i <= 8; i++) {
205 <                if (fscanf(fp, "Layer No.%d", &n) != 1 || n != i)
205 >                if (fscanf(fp, "L%*[^0-8]%d", &n) != 1 || n != i)
206                          goto readerr;
207 <                while ((n = getc(fp)) != EOF && (n == ' ' || n == '\t'))
207 >                while ((c = getc(fp)) != EOF && (c == ' ' || c == '\t'))
208                          ;
209 <                if (n == EOF)
209 >                if (c == EOF)
210                          goto readerr;
211 <                ungetc(n, fp);
211 >                ungetc(c, fp);
212                  if (fgets(buf, MAXSTR, fp) == NULL)
213                          goto readerr;
214                  buf[strlen(buf)-1] = '\0';
# Line 349 | Line 347 | register BLOCK *bp;
347          if (bp->nopenings > 0) {
348                  for (i = 0; i < bp->nopenings; i++)
349                          doneid(&bp->opening[i].frame);
350 <                free((char *)bp->opening);
350 >                free((void *)bp->opening);
351          }
352          doneid(&bp->refid);
353   }
# Line 427 | Line 425 | FILE   *fp;
425                                          /* check for repeats */
426          rept = 0; nrepts = 0;
427          for (i = 0; i < nm; i++) {
428 <                if (ml[i] == sm) {
428 >                if (ml[i] == sm || !strcmp(ml[i], VOIDID)) {
429                          rept |= 1<<i;
430                          nrepts++;
431 +                        continue;
432                  }
433                  for (j = 0; j < i; j++)
434 <                        if (ml[j] == ml[i]) {
434 >                        if (!(rept & 1<<j) && ml[j] == ml[i]) {
435                                  rept |= 1<<j;
436                                  nrepts++;
437                          }
438          }
439                                          /* print antimatter and modlist */
440 <        fprintf(fp, "\nvoid antimatter %s\n", openmod);
440 >        fprintf(fp, "\n%s antimatter %s\n", VOIDID, openmod);
441          fprintf(fp, "%d %s", 1+nm-nrepts, sm);
442          for (i = 0; i < nm; i++)
443                  if (!(rept & 1<<i))
# Line 464 | Line 463 | FILE   *fp;
463                  newp.h[i] = p->h[i];
464          }
465                                          /* spread reference and opposite */
466 <        if (p->x[1] > p->x[0]) {
466 >        if (p->x[2] > p->x[0]) {
467                  newp.x[0] -= 2;
468 <                newp.x[1] += 2;
468 >                newp.x[1] -= 2;
469                  newp.x[2] += 2;
470 <                newp.x[3] -= 2;
471 <        } else if (p->x[0] > p->x[1]) {
470 >                newp.x[3] += 2;
471 >        } else if (p->x[0] > p->x[2]) {
472                  newp.x[0] += 2;
473 <                newp.x[1] -= 2;
473 >                newp.x[1] += 2;
474                  newp.x[2] -= 2;
475 <                newp.x[3] += 2;
475 >                newp.x[3] -= 2;
476          }
477 <        if (p->y[1] > p->y[0]) {
477 >        if (p->y[2] > p->y[0]) {
478                  newp.y[0] -= 2;
479 <                newp.y[1] += 2;
479 >                newp.y[1] -= 2;
480                  newp.y[2] += 2;
481 <                newp.y[3] -= 2;
482 <        } else if (p->y[0] > p->y[1]) {
481 >                newp.y[3] += 2;
482 >        } else if (p->y[0] > p->y[2]) {
483                  newp.y[0] += 2;
484 <                newp.y[1] -= 2;
484 >                newp.y[1] += 2;
485                  newp.y[2] -= 2;
486 <                newp.y[3] += 2;
486 >                newp.y[3] -= 2;
487          }
488                                                  /* put out faces */
489          sprintf(buf, "op%d", ++nopens);
490 <        putface(openmod, buf, "ref", &newp, 0, 4, 7, 3, fp);
491 <        putface(openmod, buf, "opp", &newp, 1, 2, 6, 5, fp);
492 <        putface(openmod, buf, "end1", &newp, 3, 7, 6, 2, fp);
493 <        putface(openmod, buf, "end2", &newp, 0, 1, 5, 4, fp);
494 <        putface(openmod, buf, "bot", &newp, 0, 3, 2, 1, fp);
495 <        putface(openmod, buf, "top", &newp, 4, 5, 6, 7, fp);
490 >        putface(openmod, buf, "ref", &newp, 4, 5, 1, 0, fp);
491 >        putface(openmod, buf, "opp", &newp, 2, 6, 7, 3, fp);
492 >        putface(openmod, buf, "end1", &newp, 5, 6, 2, 1, fp);
493 >        putface(openmod, buf, "end2", &newp, 3, 7, 4, 0, fp);
494 >        putface(openmod, buf, "bot", &newp, 1, 2, 3, 0, fp);
495 >        putface(openmod, buf, "top", &newp, 7, 6, 5, 4, fp);
496   }
497  
498  
# Line 506 | Line 505 | register RULEHD        *rp;
505          ID      tmpid;
506          
507          if (rp->qflg & FL(Q_LAY)) {             /* check layer */
508 <                tmpid.name = NULL;
508 >                tmpid.name = fhead.layer[bp->layer];
509                  tmpid.number = bp->layer;
510                  if (!matchid(&tmpid, &idm(rp)[Q_LAY]))
511                          return(0);
# Line 543 | Line 542 | FILE   *fp;
542                  return;
543          bn = blkname(bp);
544          if (ff & 1<<F_REF)
545 <                putface(m, bn, "ref", &bp->p, 3, 7, 4, 0, fp);
545 >                putface(m, bn, "ref", &bp->p, 4, 5, 1, 0, fp);
546          if (ff & 1<<F_OPP)
547 <                putface(m, bn, "opp", &bp->p, 5, 6, 2, 1, fp);
547 >                putface(m, bn, "opp", &bp->p, 2, 6, 7, 3, fp);
548          if (ff & 1<<F_END) {
549 <                putface(m, bn, "end1", &bp->p, 2, 6, 7, 3, fp);
550 <                putface(m, bn, "end2", &bp->p, 4, 5, 1, 0, fp);
549 >                putface(m, bn, "end1", &bp->p, 5, 6, 2, 1, fp);
550 >                putface(m, bn, "end2", &bp->p, 3, 7, 4, 0, fp);
551          }
552          if (ff & 1<<F_BOT)
553                  putface(m, bn, "bot", &bp->p, 1, 2, 3, 0, fp);
# Line 564 | Line 563 | register BLOCK *bp;
563          static char     nambuf[32];
564          static int      blkcnt = 0;
565          register char   *nam;
566 <        register int    i;
566 >        register int    i, j;
567  
568 +        sprintf(nambuf, "l%d.", bp->layer);
569 +        i = strlen(nambuf);
570          nam = bp->refid.name;
570        if (nam == NULL)
571                nam = fhead.layer[bp->layer];
571          if (nam == NULL) {
572 <                sprintf(nambuf, "l%d.", bp->layer);
573 <                i = strlen(nambuf);
574 <        } else {
575 <                for (i = 0; i < 12 && nam[i]; i++) {
576 <                        if (nam[i] == ' ' || nam[i] == '\t')
577 <                                nambuf[i] = '_';
572 >                nam = fhead.layer[bp->layer];
573 >                if (nam != NULL)
574 >                        i = 0;
575 >        }
576 >        if (nam != NULL) {
577 >                for (j = 0; j < 12 && nam[j]; j++) {
578 >                        if (nam[j] == ' ' || nam[j] == '\t')
579 >                                nambuf[i++] = '_';
580                          else
581 <                                nambuf[i] = nam[i];
581 >                                nambuf[i++] = nam[j];
582                  }
583                  nambuf[i++] = '.';
584          }
# Line 704 | Line 705 | FILE   *fp;
705   }
706  
707  
708 + void
709   eputs(s)
710   char    *s;
711   {
# Line 711 | Line 713 | char   *s;
713   }
714  
715  
716 + void
717   quit(code)
718   int     code;
719   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines