Bathy to stl + porosity
This commit is contained in:
parent
c64ba2b31c
commit
764e2cc5bc
4 changed files with 43 additions and 13 deletions
18
olaflow/processing/stl.py
Normal file
18
olaflow/processing/stl.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def stl_from_1d(data, output, scale=[1, 1, 1]):
|
||||
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");""")
|
||||
|
||||
subprocess.run(("openscad", "scad", "-o", "data.stl"), cwd=tmpdir)
|
||||
|
||||
shutil.copy2(tmpdir.joinpath("data.stl"), output)
|
Reference in a new issue