Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #16 from mikrosimage/fix_cube_domain
Browse files Browse the repository at this point in the history
Fix cube domain
  • Loading branch information
cpichard committed Mar 19, 2015
2 parents 82f832f + 0f89a8c commit 388036e
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions utils/cube_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ def _write_1d_2d_lut(self, process_function, file_path, preset,
# Get data
data = self._get_1d_data(process_function, preset)
title = preset['title']
lutfile = open(file_path, 'w+')
# TODO add metadata
# skip comment because not supported by every soft
# title
if title is None:
title = self.get_generated_title(file_path, preset)
lutfile.write("TITLE {0}\n\n".format(title))
# lut size
lutfile.write("{0} {1}\n\n".format(CUBE_1D, len(data)))
# data
for rgb in data:
lutfile.write(line_function(preset, rgb))
lutfile.close()
with open(file_path, 'w+') as lutfile:
# TODO add metadata
# skip comment because not supported by every soft
# title
if title is None:
title = self.get_generated_title(file_path, preset)
lutfile.write("TITLE {0}\n\n".format(title))

# input range
domain = preset['input_range']
if domain:
domain_min = domain[0]
domain_max = domain[1]
if domain_min:
lutfile.write("DOMAIN_MIN {0} {0} {0}\n".format(domain_min))
if domain_max != 1.0:
lutfile.write("DOMAIN_MAX {0} {0} {0}\n".format(domain_max))
lutfile.write("\n")

# lut size
lutfile.write("{0} {1}\n\n".format(CUBE_1D, len(data)))
# data
for rgb in data:
lutfile.write(line_function(preset, rgb))
return self.get_export_message(file_path)

def write_1d_lut(self, process_function, file_path, preset):
Expand All @@ -72,20 +83,19 @@ def write_3d_lut(self, process_function, file_path, preset):
data = self._get_3d_data(process_function, preset)[1]
title = preset['title']
cube_size = preset['cube_size']
lutfile = open(file_path, 'w+')
# Test output range
self._check_output_range(preset)
# skip comment because not supported by every soft
# title
if title is None:
title = self.get_generated_title(file_path, preset)
lutfile.write("TITLE {0}\n\n".format(title))
# lut size
lutfile.write("{0} {1}\n\n".format(CUBE_3D, cube_size))
# data
for rgb in data:
lutfile.write(self._get_rgb_value_line(preset, rgb))
lutfile.close()
with open(file_path, 'w+') as lutfile:
# Test output range
self._check_output_range(preset)
# skip comment because not supported by every soft
# title
if title is None:
title = self.get_generated_title(file_path, preset)
lutfile.write("TITLE {0}\n\n".format(title))
# lut size
lutfile.write("{0} {1}\n\n".format(CUBE_3D, cube_size))
# data
for rgb in data:
lutfile.write(self._get_rgb_value_line(preset, rgb))
return self.get_export_message(file_path)

@staticmethod
Expand Down

0 comments on commit 388036e

Please sign in to comment.