diff --git a/olaflow/config.ini b/olaflow/config.ini index 57bed2c..133135f 100644 --- a/olaflow/config.ini +++ b/olaflow/config.ini @@ -4,5 +4,6 @@ npz_out=../swash/inp_post [bathy] bathy=../swash/data/bathyhires.dat hstru=../swash/data/Hstru.dat -scale=[0.5,10,1] +scale=[0.5,1,1] +translate=[-150,0,0] out=out_bathy diff --git a/olaflow/processing/bathy.py b/olaflow/processing/bathy.py index c2d8906..f5de063 100644 --- a/olaflow/processing/bathy.py +++ b/olaflow/processing/bathy.py @@ -28,10 +28,12 @@ out.mkdir(exist_ok=True) stl_from_1d( bathy, out.joinpath("bathy.stl"), - config.get("bathy", "scale"), + config.get("bathy", "scale", fallback=[1,1,1]), + config.get("bathy", "translate", fallback=[0,0,0]), ) stl_from_1d( poro, out.joinpath("poro.stl"), - config.get("bathy", "scale"), + config.get("bathy", "scale", fallback=[1,1,1]), + config.get("bathy", "translate", fallback=[0,0,0]), ) diff --git a/olaflow/processing/stl.py b/olaflow/processing/stl.py index a69bbf3..a70fe75 100644 --- a/olaflow/processing/stl.py +++ b/olaflow/processing/stl.py @@ -6,12 +6,16 @@ import tempfile import numpy as np -def stl_from_1d(data, output, scale=[1, 1, 1]): +def stl_from_1d(data, output, scale=[1, 1, 1], translate=[0, 0, 0]): with tempfile.TemporaryDirectory() as tmppath: tmpdir = pathlib.Path(tmppath) np.savetxt(tmpdir.joinpath("data.dat"), np.stack((data, data))) with open(tmpdir.joinpath("scad"), "wt") as scad: - scad.write(f"""scale({scale})surface("data.dat");""") + scad.write( + f"translate({translate})" + f"scale({scale})" + f"""surface("data.dat");""" + ) subprocess.run(("openscad", "scad", "-o", "data.stl"), cwd=tmpdir)