Build entwine files one at a time

Former-commit-id: 35130e9e7d
pull/1161/head
Piero Toffanin 2019-06-12 09:45:44 -04:00
rodzic fef5ceb345
commit cab8caf091
1 zmienionych plików z 3 dodań i 22 usunięć

Wyświetl plik

@ -5,15 +5,6 @@ from opendm import io
from opendm import log
from opendm import system
from opendm import concurrency
import math
def closest_power_of_4(x):
if x <= 0:
return 1
n = 1
while n < x:
n *= 4
return n
def build(input_point_cloud_files, output_path, max_concurrency=8, rerun=False):
num_files = len(input_point_cloud_files)
@ -30,24 +21,14 @@ def build(input_point_cloud_files, output_path, max_concurrency=8, rerun=False):
kwargs = {
'threads': max_concurrency,
'tmpdir': tmpdir,
'input': "-i " + " ".join(map(quote, input_point_cloud_files)),
'outputdir': output_path
}
entwine_cmd = "entwine build --threads {threads} --tmp {tmpdir} {input} -o {outputdir}".format(**kwargs)
for in_file in input_point_cloud_files:
kwargs['input'] = in_file
# Need to split into subsets?
if num_files > 1:
subsets = closest_power_of_4(num_files)
for s in range(1, subsets + 1):
system.run(entwine_cmd + " --subset %s %s" % (s, subsets))
# Merge
# TODO: add --tmp {tmpdir}
system.run("entwine merge --threads {threads} -o {outputdir}".format(**kwargs))
else:
# Single run
system.run(entwine_cmd)
system.run('entwine build --threads {threads} --tmp "{tmpdir}" -i "{input}" -o "{outputdir}"'.format(**kwargs))
if os.path.exists(tmpdir):
shutil.rmtree(tmpdir)