# Path: bssrdf_estimate/tools/diffuse_bssrdf.py
# class DiffuseBSSRDF(object):
#     def __init__(self):
#         self.distances = None
#         self.colors    = None
# 
#     @staticmethod
#     def load(filename):
#         ret = DiffuseBSSRDF()
#         with open(filename, 'rb') as fp:
#             ret.colors = [None] * 3
#             sz = struct.unpack('i', fp.read(4))[0]
#             ret.distances = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors = np.zeros((sz,3), dtype='float32')
#             ret.colors[:,0] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors[:,1] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors[:,2] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#         return ret
# 
#     def save(self, filename):
#         with open(filename, 'wb') as fp:
#             sz = self.distances.size
#             fp.write(struct.pack('i', sz))
#             fp.write(struct.pack('f' * sz, *self.distances))
#             fp.write(struct.pack('f' * sz, *self.colors[:,0]))
#             fp.write(struct.pack('f' * sz, *self.colors[:,1]))
#             fp.write(struct.pack('f' * sz, *self.colors[:,2]))
# 
#     def scaled(self, sc):
#         ret = DiffuseBSSRDF()
#         ret.distances = self.distances / sc
#         ret.colors    = self.colors / (sc * sc)
#         return ret
# 
# Path: bssrdf_estimate/tools/render_parameters.py
# class RenderParameters(object):
#     def __init__(self, image_width=400, image_height=300, spp=1, photons=1000000, scale=1.0):
#         self._image_width = image_width
#         self._image_height = image_height
#         self._spp = spp
#         self._photons = photons
#         self._bssrdf_scale = scale
# 
#     @property
#     def image_width(self):
#         return self._image_width
# 
#     @property
#     def image_height(self):
#         return self._image_height
# 
#     @property
#     def spp(self):
#         return self._spp
# 
#     @property
#     def photons(self):
#         return self._photons
# 
#     @property
#     def bssrdf_scale(self):
#         return self._bssrdf_scale


import os
import numpy as np
import scipy as sp
import scipy.misc
import xml.dom.minidom
import bssrdf_estimate.hdr as hdr
from xml.etree.ElementTree import ElementTree
from .diffuse_bssrdf import DiffuseBSSRDF
from .render_parameters import RenderParameters

            if e.get('type') != 'render-params':
                self.entries[e.get('type')] = e.text

    def add_entry(self, key, val):
        self.entries[key] = val

    def overwrite(self):
        impl = xml.dom.minidom.getDOMImplementation()
        doc  = impl.createDocument(None, 'content', None)
        root = doc.documentElement
        for k, v in self.entries.items():
                node = doc.createElement('entry')
                if k == 'render-params':
                    subnodes = self.serializeRenderParams(doc, v)
                    for sn in subnodes:
                        node.appendChild(sn)
                else:
                    text = doc.createTextNode(v)
                    node.appendChild(text)
                attr = doc.createAttribute('type')
                attr.value = k
                node.setAttributeNode(attr)
                root.appendChild(node)

        with open(self.filename, 'w') as f:
            f.write(doc.toprettyxml())

    @classmethod
    def serializeRenderParams(cls, doc, renderparams):

# Path: bssrdf_estimate/tools/diffuse_bssrdf.py
# class DiffuseBSSRDF(object):
#     def __init__(self):
#         self.distances = None
#         self.colors    = None
# 
#     @staticmethod
#     def load(filename):
#         ret = DiffuseBSSRDF()
#         with open(filename, 'rb') as fp:
#             ret.colors = [None] * 3
#             sz = struct.unpack('i', fp.read(4))[0]
#             ret.distances = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors = np.zeros((sz,3), dtype='float32')
#             ret.colors[:,0] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors[:,1] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#             ret.colors[:,2] = np.array(struct.unpack('f' * sz, fp.read(4 * sz)), dtype='float32')
#         return ret
# 
#     def save(self, filename):
#         with open(filename, 'wb') as fp:
#             sz = self.distances.size
#             fp.write(struct.pack('i', sz))
#             fp.write(struct.pack('f' * sz, *self.distances))
#             fp.write(struct.pack('f' * sz, *self.colors[:,0]))
#             fp.write(struct.pack('f' * sz, *self.colors[:,1]))
#             fp.write(struct.pack('f' * sz, *self.colors[:,2]))
# 
#     def scaled(self, sc):
#         ret = DiffuseBSSRDF()
#         ret.distances = self.distances / sc
#         ret.colors    = self.colors / (sc * sc)
#         return ret
# 
# Path: bssrdf_estimate/tools/render_parameters.py
# class RenderParameters(object):
#     def __init__(self, image_width=400, image_height=300, spp=1, photons=1000000, scale=1.0):
#         self._image_width = image_width
#         self._image_height = image_height
#         self._spp = spp
#         self._photons = photons
#         self._bssrdf_scale = scale
# 
#     @property
#     def image_width(self):
#         return self._image_width
# 
#     @property
#     def image_height(self):
#         return self._image_height
# 
#     @property
#     def spp(self):
#         return self._spp
# 
#     @property
#     def photons(self):
#         return self._photons
# 
#     @property
#     def bssrdf_scale(self):
#         return self._bssrdf_scale


# Path: bssrdf_estimate/tools/project.py
import os
import numpy as np
import scipy as sp
import scipy.misc
import xml.dom.minidom
import bssrdf_estimate.hdr as hdr
from xml.etree.ElementTree import ElementTree
from .diffuse_bssrdf import DiffuseBSSRDF
from .render_parameters import RenderParameters


            if e.get('type') != 'render-params':
                self.entries[e.get('type')] = e.text

    def add_entry(self, key, val):
        self.entries[key] = val

    def overwrite(self):
        impl = xml.dom.minidom.getDOMImplementation()
        doc  = impl.createDocument(None, 'content', None)
        root = doc.documentElement
        for k, v in self.entries.items():
                node = doc.createElement('entry')
                if k == 'render-params':
                    subnodes = self.serializeRenderParams(doc, v)
                    for sn in subnodes:
                        node.appendChild(sn)
                else:
                    text = doc.createTextNode(v)
                    node.appendChild(text)
                attr = doc.createAttribute('type')
                attr.value = k
                node.setAttributeNode(attr)
                root.appendChild(node)

        with open(self.filename, 'w') as f:
            f.write(doc.toprettyxml())

    @classmethod
    def serializeRenderParams(cls, doc, renderparams):

        if not isinstance(renderparams, RenderParameters):