Example #1
0
 def get_proxy_label(self, xmlgroup, xmlname):
     pxm = servermanager.ProxyManager()
     prototype = pxm.GetPrototypeProxy(xmlgroup, xmlname)
     if not prototype:
         # a bit of a hack but we assume that there's a stub of some
         # writer that's not available in this build but is available
         # with the build used by the simulation code (probably through a plugin)
         # this stub must have the proper name in the coprocessing hints
         print "WARNING: Could not find", xmlname, "writer in", xmlgroup, \
             "XML group. This is not a problem as long as the writer is available with " \
             "the ParaView build used by the simulation code."
         return servermanager._make_name_valid(xmlname)
     return servermanager._make_name_valid(prototype.GetXMLLabel())
Example #2
0
def updateProxyProperties(proxy, properties):
    """
   Loop over the properties object and update the mapping properties
   to the given proxy.
   """
    try:
        allowedProperties = proxy.ListProperties()
        for key in properties:
            validKey = servermanager._make_name_valid(key)
            if validKey in allowedProperties:
                value = removeUnicode(properties[key])
                property = servermanager._wrap_property(
                    proxy, proxy.GetProperty(validKey))
                if property.GetDomain('proxy_list') and len(
                        value) == 1 and type(value[0]) == str:
                    try:
                        idx = property.GetAvailable().index(value[0])
                        proxyToSet = servermanager._getPyProxy(
                            property.GetDomain('proxy_list').GetProxy(idx))
                        property.SetData(proxyToSet)
                    except:
                        traceback.print_stack()
                        pass
                elif value == 'vtkProcessId':
                    property.SetElement(0, value)
                else:
                    property.SetData(value)
    except:
        traceback.print_stack()
Example #3
0
def updateProxyProperties(proxy, properties):
   """
   Loop over the properties object and update the mapping properties
   to the given proxy.
   """
   try:
       allowedProperties = proxy.ListProperties()
       for key in properties:
          validKey = servermanager._make_name_valid(key)
          if validKey in allowedProperties:
             value = removeUnicode(properties[key])
             property = servermanager._wrap_property(proxy, proxy.GetProperty(validKey))
             if property.GetDomain('proxy_list') and len(value) == 1 and type(value[0]) == str:
                 try:
                    idx = property.GetAvailable().index(value[0])
                    proxyToSet = servermanager._getPyProxy(property.GetDomain('proxy_list').GetProxy(idx))
                    property.SetData(proxyToSet)
                 except:
                    traceback.print_stack()
                    pass
             elif value == 'vtkProcessId':
                property.SetElement(0, value)
             else:
                property.SetData(value)
   except:
        traceback.print_stack()
Example #4
0
 def get_proxy_label(self, xmlgroup, xmlname):
     pxm = servermanager.ProxyManager()
     prototype = pxm.GetPrototypeProxy(xmlgroup, xmlname)
     if not prototype:
         # a bit of a hack but we assume that there's a stub of some
         # writer that's not available in this build but is available
         # with the build used by the simulation code (probably through a plugin)
         # this stub must have the proper name in the coprocessing hints
         print "WARNING: Could not find", xmlname, "writer in", xmlgroup, "XML group. This is not a problem as long as the writer is available with " "the ParaView build used by the simulation code."
         ctor = servermanager._make_name_valid(xmlname)
     else:
         ctor = servermanager._make_name_valid(prototype.GetXMLLabel())
     # TODO: use servermanager.ProxyManager().NewProxy() instead
     # we create the writer proxy such that it is not registered with the
     # ParaViewPipelineController, so its state is not sent to ParaView Live.
     return "servermanager.%s.%s" % (xmlgroup, ctor)
Example #5
0
 def get_proxy_label(self, xmlgroup, xmlname):
     pxm = servermanager.ProxyManager()
     prototype = pxm.GetPrototypeProxy(xmlgroup, xmlname)
     if not prototype:
         # a bit of a hack but we assume that there's a stub of some
         # writer that's not available in this build but is available
         # with the build used by the simulation code (probably through a plugin)
         # this stub must have the proper name in the coprocessing hints
         print "WARNING: Could not find", xmlname, "writer in", xmlgroup, \
             "XML group. This is not a problem as long as the writer is available with " \
             "the ParaView build used by the simulation code."
         ctor = servermanager._make_name_valid(xmlname)
     else:
         ctor = servermanager._make_name_valid(prototype.GetXMLLabel())
     # TODO: use servermanager.ProxyManager().NewProxy() instead
     # we create the writer proxy such that it is not registered with the
     # ParaViewPipelineController, so its state is not sent to ParaView Live.
     return "servermanager.%s.%s" % (xmlgroup, ctor)
Example #6
0
    def make_trace(self):
        """gather trace for the writer proxies that are not in the trace pipeline but
        rather in the new export state.
        """
        res = []
        res.append("")
        res.append("# Now any catalyst writers")
        pxm = servermanager.ProxyManager()
        globalepxy = pxm.GetProxy("export_global", "catalyst")
        exports = pxm.GetProxiesInGroup("export_writers") #todo should use ExportDepot
        for x in exports:
            xs = x[0]
            pxy = pxm.GetProxy('export_writers', xs)
            if not pxy.HasAnnotation('enabled'):
                continue

            xmlname = pxy.GetXMLName()
            if xmlname == "Cinema image options":
                # skip the array and property export information we stuff in this proxy
                continue

            # note: this logic is not truly correct. the way this is setup,
            # there is no good way to really find the variable name used for the input since the names
            # that smtrace assigns are already cleaned up at this point.
            # Ideally, this class should have been written as a true `Accessor` so it could
            # be traced correctly. Right now, I am hacking this to attempt to get a reasonable name
            # that works in most cases.
            inputname = xs.split('|')[0]
            inputname = servermanager._make_name_valid(inputname)
            inputname = inputname[0].lower() + inputname[1:]

            writername = xs.split('|')[1]

            xmlgroup = pxy.GetXMLGroup()

            padding_amount = globalepxy.GetProperty("FileNamePadding").GetElement(0)
            write_frequency = pxy.GetProperty("WriteFrequency").GetElement(0)
            filename = pxy.GetProperty("CatalystFilePattern").GetElement(0)

            cpstate_globals = get_globals()
            sim_inputs = locate_simulation_inputs(pxy)
            for sim_input_name in sim_inputs:
                if not write_frequency in cpstate_globals.write_frequencies[sim_input_name]:
                    cpstate_globals.write_frequencies[sim_input_name].append(write_frequency)
                    cpstate_globals.write_frequencies[sim_input_name].sort()

                if not sim_input_name in cpstate_globals.channels_needed:
                    cpstate_globals.channels_needed.append(sim_input_name)

            prototype = pxm.GetPrototypeProxy(xmlgroup, xmlname)
            if not prototype:
                varname = self.__make_name(xmlname)
            else:
                varname = self.__make_name(prototype.GetXMLLabel())
            # Write pass array proxy
            if pxy.GetProperty("ChooseArraysToWrite").GetElement(0) == 1:
                point_arrays = []
                cell_arrays = []
                arrays_property = pxy.GetProperty("PointDataArrays")
                for i in range(arrays_property.GetNumberOfElements()):
                    point_arrays.append(arrays_property.GetElement(i))
                arrays_property = pxy.GetProperty("CellDataArrays")
                for i in range(arrays_property.GetNumberOfElements()):
                    cell_arrays.append(arrays_property.GetElement(i))
                f = "%s_arrays = PassArrays(Input=%s, PointDataArrays=%s, CellDataArrays=%s)" % \
                    (inputname, inputname, str(point_arrays), str(cell_arrays))
                inputname = "%s_arrays" % inputname
                res.append(f)
            # Actual writer
            f = "%s = servermanager.writers.%s(Input=%s)" % (varname, writername, inputname)
            res.append(f)
            # set various writer properties, except for the filename since that will be set later.
            # point, cell and field arrays should already be set
            notNeededProperties = ['CatalystFilePattern', 'CellDataArrays', 'ChooseArraysToWrite', 'EdgeDataArrays',
                                   'FieldDataArrays', 'FileName', 'FileNameSuffix', 'Filenamesuffix', 'Input',
                                   'PointDataArrays', 'WriteFrequency',]
            for p in pxy.ListProperties():
                if p not in notNeededProperties and len(pxy.GetProperty(p)):
                    if isinstance(pxy.GetProperty(p).GetData(), servermanager.Proxy):
                        proxyvalue = pxy.GetProperty(p).GetData()
                        cpstate_globals = get_globals()
                        if proxyvalue in cpstate_globals.variable_to_name_map:
                            f = "%s.%s = %s" % (varname, p, cpstate_globals.variable_to_name_map[proxyvalue])
                            res.append(f)
                    elif hasattr(pxy.GetProperty(p), 'GetElement'):
                        value = pxy.GetProperty(p).GetElement(0)
                        if isinstance(value, numbers.Number):
                            f = "%s.%s = %s" % (varname, p, value)
                        elif  isinstance(value, str):
                            f = "%s.%s = '%s'" % (varname, p, value)
                        else:
                            f = "%s.%s = %s" % (varname, p, str(value))
                        res.append(f)

            if self.__make_temporal_script:
                f = "STP.RegisterWriter(%s, '%s', tp_writers)" % (
                    varname, filename)
            else:
                f = "coprocessor.RegisterWriter(%s, filename='%s', freq=%s, paddingamount=%s)" % (
                    varname, filename, write_frequency, padding_amount)
            res.append(f)
            res.append("")
        if len(res) == 2:
            return [] # don't clutter output if there are no writers
        return res
Example #7
0
    def make_trace(self):
        """gather trace for the writer proxies that are not in the trace pipeline but
        rather in the new export state.
        """
        res = []
        res.append("")
        res.append("# Now any catalyst writers")
        pxm = servermanager.ProxyManager()
        globalepxy = pxm.GetProxy("export_global", "catalyst")
        exports = pxm.GetProxiesInGroup(
            "export_writers")  #todo should use ExportDepot
        for x in exports:
            xs = x[0]
            pxy = pxm.GetProxy('export_writers', xs)
            if not pxy.HasAnnotation('enabled'):
                continue

            xmlname = pxy.GetXMLName()
            if xmlname == "Cinema image options":
                # skip the array and property export information we stuff in this proxy
                continue

            # note: this logic is not truly correct. the way this is setup,
            # there is no good way to really find the variable name used for the input since the names
            # that smtrace assigns are already cleaned up at this point.
            # Ideally, this class should have been written as a true `Accessor` so it could
            # be traced correctly. Right now, I am hacking this to attempt to get a reasonable name
            # that works in most cases.
            inputname = xs.split('|')[0]
            inputname = servermanager._make_name_valid(inputname)
            inputname = inputname[0].lower() + inputname[1:]

            writername = xs.split('|')[1]

            xmlgroup = pxy.GetXMLGroup()

            padding_amount = globalepxy.GetProperty(
                "FileNamePadding").GetElement(0)
            write_frequency = pxy.GetProperty("WriteFrequency").GetElement(0)
            filename = pxy.GetProperty("CatalystFilePattern").GetElement(0)
            DataMode = pxy.GetProperty("DataMode")
            if DataMode is not None:
                DataMode = pxy.GetProperty("DataMode").GetElement(0)
            HeaderType = pxy.GetProperty("HeaderType")
            if HeaderType is not None:
                HeaderType = pxy.GetProperty("HeaderType").GetElement(0)
            EncodeAppendedData = pxy.GetProperty("EncodeAppendedData")
            if EncodeAppendedData is not None:
                EncodeAppendedData = pxy.GetProperty(
                    "EncodeAppendedData").GetElement(0) != 0
            CompressorType = pxy.GetProperty("CompressorType")
            if CompressorType is not None:
                CompressorType = pxy.GetProperty("CompressorType").GetElement(
                    0)
            CompressionLevel = pxy.GetProperty("CompressionLevel")
            if CompressionLevel is not None:
                CompressionLevel = pxy.GetProperty(
                    "CompressionLevel").GetElement(0)

            cpstate_globals = get_globals()
            sim_inputs = locate_simulation_inputs(pxy)
            for sim_input_name in sim_inputs:
                if not write_frequency in cpstate_globals.write_frequencies[
                        sim_input_name]:
                    cpstate_globals.write_frequencies[sim_input_name].append(
                        write_frequency)
                    cpstate_globals.write_frequencies[sim_input_name].sort()

                if not sim_input_name in cpstate_globals.channels_needed:
                    cpstate_globals.channels_needed.append(sim_input_name)

            prototype = pxm.GetPrototypeProxy(xmlgroup, xmlname)
            if not prototype:
                varname = self.__make_name(xmlname)
            else:
                varname = self.__make_name(prototype.GetXMLLabel())
            # Write pass array proxy
            if pxy.GetProperty("ChooseArraysToWrite").GetElement(0) == 1:
                point_arrays = []
                cell_arrays = []
                arrays_property = pxy.GetProperty("PointDataArrays")
                for i in range(arrays_property.GetNumberOfElements()):
                    point_arrays.append(arrays_property.GetElement(i))
                arrays_property = pxy.GetProperty("CellDataArrays")
                for i in range(arrays_property.GetNumberOfElements()):
                    cell_arrays.append(arrays_property.GetElement(i))
                f = "%s_arrays = PassArrays(Input=%s, PointDataArrays=%s, CellDataArrays=%s)" % \
                    (inputname, inputname, str(point_arrays), str(cell_arrays))
                inputname = "%s_arrays" % inputname
                res.append(f)
            # Actual writer
            f = "%s = servermanager.writers.%s(Input=%s)" % (
                varname, writername, inputname)
            res.append(f)
            if self.__make_temporal_script:
                f = "STP.RegisterWriter(%s, '%s', tp_writers)" % (varname,
                                                                  filename)
            else:
                f = "coprocessor.RegisterWriter(%s, filename='%s', freq=%s, paddingamount=%s, DataMode='%s', HeaderType='%s', EncodeAppendedData=%s, CompressorType='%s', CompressionLevel='%s')" % (
                    varname, filename, write_frequency, padding_amount,
                    DataMode, HeaderType, EncodeAppendedData, CompressorType,
                    CompressionLevel)
            res.append(f)
            res.append("")
        if len(res) == 2:
            return []  # don't clutter output if there are no writers
        return res