Commit b241b6e8 authored by David E. DeMarle's avatar David E. DeMarle
Browse files

Merge branch 'real-filenames-for-cinemaD' into 'for/paraview'

Real filenames for cinema d

See merge request !6
parents a5295e2f 09082c8c
Pipeline #142673 failed with stage
......@@ -282,12 +282,11 @@ def add_control_and_colors(name, cs, userDefined, arrayRanges, disableValues):
defaultName = None
view_proxy = paraview.simple.GetActiveView()
rep = paraview.servermanager.GetRepresentation(source, view_proxy)
defcolorarray = rep.ColorArrayName.GetArrayName()
# select value arrays
if rep.Representation != 'Outline':
defaultName = add_customized_array_selection(
name, source, fields, userDefined, arrayRanges, disableValues, defcolorarray)
name, source, fields, userDefined, arrayRanges, disableValues)
if defaultName is None:
fields['white'] = 'rgb'
......@@ -299,18 +298,19 @@ def add_control_and_colors(name, cs, userDefined, arrayRanges, disableValues):
def add_customized_array_selection(
sourceName, source, fields, userDefined, arrayRanges, disableValues, defcolorarray):
sourceName, source, fields, userDefined, arrayRanges, disableValues):
def isArrayNotSelected(aName, arrays):
return (aName not in arrays)
defaultName = None
if source not in userDefined or "arraySelection" not in userDefined[source]:
if defcolorarray == '':
return defaultName
userDefined = {source : {"arraySelection" : defcolorarray}}
if (source not in userDefined):
return defaultName
if ("arraySelection" not in userDefined[source]):
return defaultName
arrayNames = userDefined[source]["arraySelection"]
cda = source.GetCellDataInformation()
pda = source.GetPointDataInformation()
for datainfo in [cda, pda]:
......@@ -197,8 +197,6 @@ class FileStore(store.Store):
super(FileStore, self).insert(document)
fname = self._get_filename(document.descriptor, readingFile=False)
if not os.path.exists(fname):
dirname = os.path.dirname(fname)
if not os.path.exists(dirname):
......@@ -212,6 +210,8 @@ class FileStore(store.Store):
if is not None:
adjustedfname = None
for parname, parvalue in py23iteritems(document.descriptor):
params = self.get_parameter(parname)
if 'role' in params:
......@@ -223,7 +223,7 @@ class FileStore(store.Store):
doctype = self.determine_type(document.descriptor)
if doctype == 'RGB' or doctype == 'LUMINANCE':
self.raster_wrangler.rgbwriter(, fname)
adjustedfname = self.raster_wrangler.rgbwriter(, fname)
elif doctype == 'VALUE':
# find the range for the value that this raster shows
vrange = [0, 1]
......@@ -235,13 +235,16 @@ class FileStore(store.Store):
vr = param['valueRanges']
if parvalue in vr:
vrange = vr[parvalue]
self.raster_wrangler.valuewriter(, fname, vrange)
adjustedfname = self.raster_wrangler.valuewriter(, fname, vrange)
elif doctype == 'Z':
self.raster_wrangler.zwriter(, fname)
adjustedfname = self.raster_wrangler.zwriter(, fname)
elif doctype == 'MAGNITUDE':
self.raster_wrangler.genericwriter(, fname)
adjustedfname = self.raster_wrangler.genericwriter(, fname)
if adjustedfname is not None:
def _load_data(self, descriptor):
doctype = self.determine_type(descriptor)
......@@ -177,6 +177,7 @@ class RasterWrangler(object):
with open(fname, "w") as file:
return fname
def rgbreader(self, fname):
"""opens a color image file and returns it as a color buffer"""
......@@ -224,14 +225,16 @@ class RasterWrangler(object):
return fname
elif "PIL" in self.backends:
imageslice = numpy.flipud(imageslice)
pimg = PIL.Image.fromarray(imageslice)
return fname
print("Warning: need PIL or VTK to write to " + fname)
raise ValueError("Warning: need PIL or VTK to write to " + fname)
def valuewriter(self, imageSlice, fname, vrange):
""" Takes in either a (1C) float or a RGB (3C) buffer and writes it as
......@@ -244,7 +247,7 @@ class RasterWrangler(object):
dimensions = imageSlice.shape
if len(dimensions) == 2 and imageSlice.dtype == numpy.float32:
# Given as single channel floating point buffer.
self.zwriter(imageSlice, adjustedName)
return self.zwriter(imageSlice, adjustedName)
elif (len(dimensions) > 2) and (dimensions[2] == 3):
# if self.dontConvertValsToFloat
......@@ -263,11 +266,12 @@ class RasterWrangler(object):
value = value.astype(numpy.float32)
adjusted_val = numpy.divide(value, float(0xFFFFFE))
self.zwriter(adjusted_val, adjustedName)
return self.zwriter(adjusted_val, adjustedName)
raise ValueError("Invalid dimensions for a value raster.")
def valuereader(self, fname, shape=None):
""" Opens a value image file and returns it as either a color buffer
or a floating point array (depending on how the image was exported)."""
......@@ -333,7 +337,7 @@ class RasterWrangler(object):
if "OpenEXR" in self.backends:
imageslice = numpy.flipud(imageslice)
exr.save_depth(imageslice, fname)
return fname
# if self.dontCompressFloatVals:
# if "VTK" in self.backends:
......@@ -377,6 +381,7 @@ class RasterWrangler(object):
with open(adjustedName, mode='wb') as file:
return adjustedName
def assertvalidimage(self, filename):
"""tests that a given file is syntactically correct"""
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment