diff --git a/pyradiance/__init__.py b/pyradiance/__init__.py index ba0875a..62d7eb6 100644 --- a/pyradiance/__init__.py +++ b/pyradiance/__init__.py @@ -22,9 +22,11 @@ ) from .gen import ( genblinds, + genbox, genbsdf, gendaylit, gendaymtx, + genrev, gensdaymtx, gensky, genssky, @@ -79,9 +81,11 @@ "evalglare", "falsecolor", "genblinds", + "genbox", "genbsdf", "gendaylit", "gendaymtx", + "genrev", "gensdaymtx", "gensky", "genssky", diff --git a/pyradiance/gen.py b/pyradiance/gen.py index 50d27da..c1fba48 100644 --- a/pyradiance/gen.py +++ b/pyradiance/gen.py @@ -48,6 +48,40 @@ def genblinds( cmd.extend(["-r", str(rcurv)]) return sp.run(cmd, check=True, stdout=sp.PIPE).stdout +@handle_called_process_error +def genbox( + mat: str, + name: str, + xsiz: float, + ysiz: float, + zsiz: float, + inward: bool = False, + beveled: Optional[float] = None, + rounded: Optional[float] = None, + nsegs: Optional[int] = None, + smoothing: bool = False, + waveout: bool = False, +) -> bytes: + cmd = [str(BINPATH / "genbox")] + cmd.append(mat) + cmd.append(name) + cmd.append(str(xsiz)) + cmd.append(str(ysiz)) + cmd.append(str(zsiz)) + if inward: + cmd.append("-i") + if beveled is not None: + cmd.extend(["-b", str(beveled)]) + if rounded is not None: + cmd.extend(["-r", str(rounded)]) + if nsegs is not None: + cmd.extend(["-n", str(nsegs)]) + if smoothing: + cmd.append("-s") + if waveout: + cmd.append("-o") + return sp.run(cmd, stdout=sp.PIPE).stdout + @handle_called_process_error def genbsdf( @@ -296,6 +330,31 @@ def gendaymtx( out = sp.run(cmd, check=True, input=stdin, stdout=sp.PIPE, stderr=sp.PIPE) return out.stdout +@handle_called_process_error +def genrev( + mat: str, + name: str, + z_t: str, + r_t: str, + nseg: int, + expr: Optional[str] = None, + file: Optional[str] = None, + smooth: bool = False, +) -> bytes: + cmd = [str(BINPATH/"genrev")] + cmd.append(mat) + cmd.append(name) + cmd.append(z_t) + cmd.append(r_t) + cmd.append(str(nseg)) + if expr is not None: + cmd.extend(["-e", expr]) + if file is not None: + cmd.extend(["-f", file]) + if smooth: + cmd.append("-s") + return sp.run(cmd, stdout=sp.PIPE).stdout + @handle_called_process_error def gensdaymtx( diff --git a/setup.py b/setup.py index 8d19eb1..1732138 100644 --- a/setup.py +++ b/setup.py @@ -15,52 +15,72 @@ RADTAG = "f275c068" RADBINS = [ - "bsdf2ttree", "bsdf2klems", + "bsdf2ttree", "bsdfquery", "cnt", "dctimestep", + "epw2wea", "evalglare", "falsecolor", - "getbbox", - "getinfo", - "genblinds", "genBSDF", + "genblinds", + "genbox", "gendaylit", "gendaymtx", + "genprism", + "genrev", "gensdaymtx", "gensky", "genssky", + "gensurf", + "genworm", + "getbbox", + "getinfo", + "histo", "ies2rad", "mgf2rad", "mkillum", - "obj2rad", + "mkpmap", "obj2mesh", + "obj2rad", "oconv", "pabopto2bsdf", "pcomb", "pcompos", "pcond", + "pextrem", "pfilt", + "pflip", "pkgBSDF", + "protate", "pvalue", - "rad", - "ra_tiff", + "ra_bmp", "ra_ppm", + "ra_tiff", + "ra_xyze", + "rad", "rcalc", + "rcode2bmp", "rcode_depth", "rcode_ident", "rcode_norm", + "rcollate", "rcomb", "rcontrib", + "rcrop", "rfluxmtx", "rlam", "rmtxop", "robjutil", "rpict", + "rpiece", "rsensor", + "rsplit", "rtpict", "rtrace", + "rttree_reduce", + "tabfunc", "total", "vwrays", "vwright", @@ -68,8 +88,8 @@ "xform", # For Windows Perl scripts "perl530", - "libgcc_s_seh-1", "libstdc++-6", + "libgcc_s_seh-1", "libwinpthread-1", ] diff --git a/test/test_api.py b/test/test_api.py index 73a59d1..527f899 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -169,3 +169,16 @@ def test_ra_tiff(tmpdir: Path, resources_dir: Path): out = tmpdir / "test.tif" pr.ra_tiff(hdr, out=str(out)) assert out.exists() + +def test_genbox(): + out_bytes = pr.genbox("mat", "name", 1, 2, 3) + out_str = out_bytes.decode() + prims = pr.parse_primitive(out_str) + assert prims[0] == pr.Primitive("mat", "polygon", "name.1540", [], [1, 0, 0,1,0,3,0,0,3,0,0,0]) + + +def test_genrev(): + out_bytes = pr.genrev("steel", "torus", "sin(2*PI*t)", "2+cos(2*PI*t)", 2) + out_str = out_bytes.decode() + prims = pr.parse_primitive(out_str) + assert prims[0] == pr.Primitive("steel", "ring", "torus.1", [], [0, 0,1.22464679915e-16,0,0,1,3,1])