744 |
|
iesversion(char *buf) { |
745 |
|
IESversions *v; |
746 |
|
|
747 |
< |
for(v = IESFILEVERSIONS; v != NULL; v++) |
747 |
> |
for(v = IESFILEVERSIONS; v->tag != NULL; v++) |
748 |
|
if (streq(v->tag,buf)) |
749 |
|
return v->yr; |
750 |
|
return v->yr; |
1519 |
|
*/ |
1520 |
|
#define CONVSGN(d) ((d) < 0 ? 1 : ((d) == 0 ? 2 : 3)) |
1521 |
|
|
1522 |
+ |
/* |
1523 |
+ |
* Generate the numeric key, the "thumbprint" for the various |
1524 |
+ |
* combinations of IES LM-63 version year, length, width, and height. |
1525 |
+ |
* This must be an integer constant expression so that it can be used |
1526 |
+ |
* in a case label. See the header comments of makeiesshape() for |
1527 |
+ |
* additional information. |
1528 |
+ |
*/ |
1529 |
+ |
#define TBPR(ver,l,w,h) ((ver) * 1000 + CONVSGN(l) * 100 + CONVSGN(w) * 10 + CONVSGN(h)) |
1530 |
+ |
|
1531 |
|
/* makeiesshape - convert IES shape to Radiance shape |
1532 |
|
* |
1533 |
|
* Some 34 cases in the various versions of the IES LM-63 standard are |
1543 |
|
* positive. These are then combined into a numeric key by the |
1544 |
|
* following formula: |
1545 |
|
* |
1546 |
< |
* version * 1000 + sgn(length) * 100 + sgn(width) * 10 + sgn(height). |
1546 |
> |
* version * 1000 + sgn(length) * 100 + sgn(width) * 10 + sgn(height) |
1547 |
|
* |
1548 |
+ |
* The macro TBPR implements this formula. |
1549 |
+ |
* |
1550 |
|
* Since the 1991 version uses the same encoding as the 1986 version, |
1551 |
|
* and the 2019 version uses the same encoding as the 2002 version, |
1552 |
|
* these are collapsed into the earlier years. |
1566 |
|
* used throughout the function, this has a low cost and eliminates |
1567 |
|
* the chance of sign errors. |
1568 |
|
* |
1569 |
< |
* There is one extension to the ies standard here, devised to |
1559 |
< |
* accomdate wall-mounted fixtures; vertical rectangles, not formally |
1560 |
< |
* supported by any version of LM-63, are treated as boxes. |
1569 |
> |
* There are two extensions to the ies standard here: |
1570 |
|
* |
1571 |
+ |
* 1. devised to accomdate wall-mounted fixtures; vertical rectangles, |
1572 |
+ |
* not formally supported by any version of LM-63, are treated as |
1573 |
+ |
* boxes. |
1574 |
+ |
* |
1575 |
+ |
* 2. A 2002-flagged file with only a negative width will be |
1576 |
+ |
* recognized as a disk. |
1577 |
+ |
* |
1578 |
|
* The code is complicated by the way that earlier versions of the |
1579 |
|
* standard (1986 and 1991) prioritize width in their discussions, and |
1580 |
|
* later versions prioritize length. It is not always clear which to |
1602 |
|
break; |
1603 |
|
} |
1604 |
|
|
1605 |
< |
thumbprint = |
1590 |
< |
ver * 1000 + CONVSGN(l) * 100 + CONVSGN(w) * 10 + CONVSGN(h); |
1605 |
> |
thumbprint = TBPR(ver, l, w, h); |
1606 |
|
switch(thumbprint) { |
1607 |
< |
case 86222: case 95222: case 2222: |
1607 |
> |
case TBPR(86,0,0,0): case TBPR(95, 0, 0, 0): case TBPR(02, 0, 0, 0): |
1608 |
|
shp->iesshape = IESPT; |
1609 |
|
shp->type = SPHERE; |
1610 |
|
shp->w = shp->l = shp->h = MINDIM; |
1611 |
|
break; |
1612 |
< |
case 86332: case 95332: case 2332: |
1612 |
> |
case TBPR(86, 1, 1, 0): case TBPR(95, 1, 1, 0): case TBPR(02, 1, 1, 0): |
1613 |
|
shp->iesshape = IESRECT; |
1614 |
|
makeboxshape(shp, lp, wp, hp); |
1615 |
|
break; |
1616 |
< |
case 86333: case 86233: case 86323: |
1617 |
< |
case 95333: case 95233: case 95323: |
1618 |
< |
case 2333: case 2233: case 2323: |
1616 |
> |
case TBPR(86, 1, 1, 1): case TBPR(86, 0, 1, 1): case TBPR(86, 1, 0, 1): |
1617 |
> |
case TBPR(95, 1, 1, 1): case TBPR(95, 0, 1, 1): case TBPR(95, 1, 0, 1): |
1618 |
> |
case TBPR(02, 1, 1, 1): case TBPR(02, 0, 1, 1): case TBPR(02, 1, 0, 1): |
1619 |
|
shp->iesshape = IESBOX; |
1620 |
|
makeboxshape(shp, lp, wp, hp); |
1621 |
|
break; |
1622 |
< |
case 86212: case 95212: |
1622 |
> |
case TBPR(86,0,-1,0): case TBPR(95,0,-1,0): case TBPR(02,0,-1,0): |
1623 |
|
shp->iesshape = IESDISK; |
1624 |
|
makecylshape(shp, wp, hp); |
1625 |
|
break; |
1626 |
< |
case 86213: |
1626 |
> |
case TBPR(86, 0, -1, 1): |
1627 |
|
shp->iesshape = IESVCYL; |
1628 |
|
makecylshape(shp, wp, hp); |
1629 |
|
break; |
1630 |
< |
case 86312: |
1630 |
> |
case TBPR(86, 1, -1, 0): |
1631 |
|
shp->iesshape = IESELLIPSE; |
1632 |
|
makeecylshape(shp, lp, wp, 0); |
1633 |
|
break; |
1634 |
< |
case 86313: |
1634 |
> |
case TBPR(86, 1, -1, 1): |
1635 |
|
shp->iesshape = IESELLIPSOID; |
1636 |
|
makeelshape(shp, wp, lp, hp); |
1637 |
|
break; |
1638 |
< |
case 95211: |
1638 |
> |
case TBPR(95, 0, -1, -1): |
1639 |
|
shp->iesshape = FEQ(lp,hp) ? IESSPHERE : IESNONE; |
1640 |
|
if (shp->iesshape == IESNONE) { |
1641 |
|
shp->warn = "makeshape: cannot determine shape\n"; |
1645 |
|
shp->type = SPHERE; |
1646 |
|
shp->w = shp->l = shp->h = wp; |
1647 |
|
break; |
1648 |
< |
case 95213: |
1648 |
> |
case TBPR(95, 0, -1, 1): |
1649 |
|
shp->iesshape = IESVCYL; |
1650 |
|
makecylshape(shp, wp, hp); |
1651 |
|
break; |
1652 |
< |
case 95321: |
1652 |
> |
case TBPR(95, 1, 0, -1): |
1653 |
|
shp->iesshape = IESHCYL_PH; |
1654 |
|
shp->warn = "makeshape: shape is a horizontal cylinder, which is not supported.\nmakeshape: replaced with box\n"; |
1655 |
|
makeboxshape(shp, lp, wp, hp); |
1656 |
|
break; |
1657 |
< |
case 95231: |
1657 |
> |
case TBPR(95, 0, 1, -1): |
1658 |
|
shp->iesshape = IESHCYL_PPH; |
1659 |
|
shp->warn = "makeshape: shape is a horizontal cylinder, which is not supported.\nmakeshape: replaced with box\n"; |
1660 |
|
makeboxshape(shp, lp, wp, hp); |
1661 |
|
break; |
1662 |
< |
case 95133: case 95313: |
1662 |
> |
case TBPR(95, -1, 1, 1): case TBPR(95, 1, -1, 1): |
1663 |
|
shp->iesshape = IESVECYL; |
1664 |
|
makeecylshape(shp, lp, wp, hp); |
1665 |
|
break; |
1666 |
< |
case 95131: case 95311: |
1666 |
> |
case TBPR(95, -1, 1, -1): case TBPR(95, 1, -1, -1): |
1667 |
|
shp->iesshape = IESELLIPSOID; |
1668 |
|
makeelshape(shp, lp, wp, hp); |
1669 |
|
break; |
1670 |
< |
case 2112: |
1670 |
> |
case TBPR(02, -1, -1, 0): |
1671 |
|
shp->iesshape = FEQ(l,w) ? IESDISK : IESELLIPSE; |
1672 |
|
if (shp->iesshape == IESDISK) |
1673 |
|
makecylshape(shp, wp, hp); |
1674 |
|
else |
1675 |
|
makeecylshape(shp, wp, lp, hp); |
1676 |
|
break; |
1677 |
< |
case 2113: |
1677 |
> |
case TBPR(02, -1, -1, 1): |
1678 |
|
shp->iesshape = FEQ(l,w) ? IESVCYL : IESVECYL; |
1679 |
|
if (shp->iesshape == IESVCYL) |
1680 |
|
makecylshape(shp, wp, hp); |
1681 |
|
else |
1682 |
|
makeecylshape(shp, wp, lp, hp); |
1683 |
|
break; |
1684 |
< |
case 2111: |
1684 |
> |
case TBPR(02, -1, -1, -1): |
1685 |
|
shp->iesshape = FEQ(l,w) && FEQ(l,h) ? IESSPHERE : IESELLIPSOID; |
1686 |
|
if (shp->iesshape == IESSPHERE) { |
1687 |
|
shp->type = SPHERE; |
1690 |
|
else |
1691 |
|
makeelshape(shp, lp, wp, hp); |
1692 |
|
break; |
1693 |
< |
case 2311: |
1693 |
> |
case TBPR(02, 1, -1, -1): |
1694 |
|
shp->iesshape = FEQ(w,h) ? IESHCYL_PH : IESHECYL_PH; |
1695 |
|
shp->warn = "makeshape: shape is a horizontal cylinder, which is not supported.\nmakeshape: replaced with box\n"; |
1696 |
|
makeboxshape(shp, lp, wp, hp); |
1697 |
|
break; |
1698 |
< |
case 2131: |
1698 |
> |
case TBPR(02, -1, 1, -1): |
1699 |
|
shp->iesshape = FEQ(l,h) ? IESHCYL_PPH : IESHECYL_PPH; |
1700 |
|
shp->warn = "makeshape: shape is a horizontal cylinder, which is not supported.\nmakeshape: replaced with box\n"; |
1701 |
|
makeboxshape(shp, lp, wp, hp); |
1702 |
|
break; |
1703 |
< |
case 2121: |
1703 |
> |
case TBPR(02, -1, 0, -1): |
1704 |
|
shp->iesshape = FEQ(w,h) ? IESVDISK_PH : IESVEL_PH; |
1705 |
|
shp->warn = "makeshape: shape is a vertical ellipse, which is not supported.\nmakeshape: replaced with rectangle\n"; |
1706 |
|
makeboxshape(shp, lp, wp, hp); |