374 |
|
fp = stdin; |
375 |
|
else if (inspec[0] == '!') |
376 |
|
fp = popen(inspec+1, "r"); |
377 |
< |
else if (rmp != RMPnone) { |
377 |
> |
else { |
378 |
|
const char *sp = inspec; /* check suffix */ |
379 |
|
while (*sp) |
380 |
|
++sp; |
381 |
|
while (sp > inspec && sp[-1] != '.') |
382 |
|
--sp; |
383 |
|
if (!strcasecmp(sp, "XML")) { /* assume it's a BSDF */ |
384 |
< |
CMATRIX *cm = rmp==RMPtrans ? cm_loadBTDF(inspec) : |
384 |
> |
CMATRIX *cm = rmp==RMPnone ? (CMATRIX *)NULL : |
385 |
> |
rmp==RMPtrans ? cm_loadBTDF(inspec) : |
386 |
|
cm_loadBRDF(inspec, rmp==RMPreflB) ; |
387 |
|
if (!cm) |
388 |
|
return(NULL); |
450 |
|
{ |
451 |
|
while (len-- > 0) { |
452 |
|
int k = nc; |
453 |
< |
while (nc-- > 0) |
453 |
> |
while (k-- > 0) |
454 |
|
fprintf(fp, " %.7e", *dp++); |
455 |
|
fputc('\t', fp); |
456 |
|
} |
528 |
|
int |
529 |
|
rmx_write_header(const RMATRIX *rm, int dtype, FILE *fp) |
530 |
|
{ |
531 |
< |
if (!rm | !fp || !rm->mtx | (rm->ncols <= 0)) |
531 |
> |
if (!rm | !fp || rm->ncols <= 0) |
532 |
|
return(0); |
533 |
|
if (rm->info) |
534 |
|
fputs(rm->info, fp); |
539 |
|
dtype = DTxyze; |
540 |
|
else if ((dtype == DTxyze) & (rm->dtype == DTrgbe)) |
541 |
|
dtype = DTrgbe; |
542 |
< |
if ((dtype == DTspec) & (rm->ncomp < 3)) |
542 |
> |
if ((dtype == DTspec) & (rm->ncomp <= 3)) |
543 |
|
return(0); |
544 |
|
|
545 |
|
if (dtype == DTascii) /* set file type (WINDOWS) */ |
560 |
|
} |
561 |
|
if (dtype >= DTspec) { /* # components & split? */ |
562 |
|
fputncomp(rm->ncomp, fp); |
563 |
< |
if (dtype == DTspec || (rm->ncomp > 3 && |
564 |
< |
memcmp(rm->wlpart, WLPART, sizeof(WLPART)))) |
563 |
> |
if (rm->ncomp > 3 && |
564 |
> |
memcmp(rm->wlpart, WLPART, sizeof(WLPART))) |
565 |
|
fputwlsplit(rm->wlpart, fp); |
566 |
|
} else if ((rm->ncomp != 3) & (rm->ncomp != 1)) |
567 |
|
return(0); /* wrong # components */ |
666 |
|
copycolor(dnew->cexp, rm->cexp); |
667 |
|
memcpy(dnew->wlpart, rm->wlpart, sizeof(dnew->wlpart)); |
668 |
|
return(dnew); |
669 |
+ |
} |
670 |
+ |
|
671 |
+ |
/* Replace data in first matrix with data from second */ |
672 |
+ |
int |
673 |
+ |
rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa) |
674 |
+ |
{ |
675 |
+ |
if (!rdst | !rsrc || (rdst->nrows != rsrc->nrows) | |
676 |
+ |
(rdst->ncols != rsrc->ncols) | |
677 |
+ |
(rdst->ncomp != rsrc->ncomp)) |
678 |
+ |
return(0); |
679 |
+ |
|
680 |
+ |
if (dometa) { /* transfer everything? */ |
681 |
+ |
rmx_reset(rdst); |
682 |
+ |
*rdst = *rsrc; |
683 |
+ |
rsrc->info = NULL; rsrc->mapped = NULL; rsrc->mtx = NULL; |
684 |
+ |
return(1); |
685 |
+ |
} |
686 |
+ |
if (rdst->mapped) |
687 |
+ |
return(0); /* XXX can't handle this case */ |
688 |
+ |
/* just matrix data -- leave metadata */ |
689 |
+ |
if (rdst->mtx) free(rdst->mtx); |
690 |
+ |
rdst->mtx = rsrc->mtx; |
691 |
+ |
rsrc->mtx = NULL; |
692 |
+ |
return(1); |
693 |
|
} |
694 |
|
|
695 |
|
/* Allocate and assign transposed matrix */ |