# Path: pcloudpy/core/utils/vtkhelpers.py
# def numpy_to_image(numpy_array):
#     """
#     @brief Convert a numpy 2D or 3D array to a vtkImageData object
#     @param numpy_array 2D or 3D numpy array containing image data
#     @return vtkImageData with the numpy_array content
#     """
# 
#     shape = numpy_array.shape
#     if len(shape) < 2:
#         raise Exception('numpy array must have dimensionality of at least 2')
# 
#     h, w = shape[0], shape[1]
#     c = 1
#     if len(shape) == 3:
#         c = shape[2]
# 
#     # Reshape 2D image to 1D array suitable for conversion to a
#     # vtkArray with numpy_support.numpy_to_vtk()
#     linear_array = np.reshape(numpy_array, (w*h, c))
#     vtk_array = numpy_to_vtk(linear_array)
# 
#     image = vtkImageData()
#     image.SetDimensions(w, h, 1)
#     image.AllocateScalars()
#     image.GetPointData().GetScalars().DeepCopy(vtk_array)
# 
#     return image
# 
# Path: pcloudpy/core/io/base.py
# class ImageDataBase(DataBase):
#     """
#     ImageData Base Class
# 
#     Attributes
#     ----------
#     props_: OrderedDict
#         Dictionary used for the props storing
# 
#     data_: array
#         raw data
# 
# 
#     """
#     def __init__(self):
#         super(ImageDataBase, self).__init__()
#         self.type_ = DataType.IMAGEDATA
# 
#     def get_imagedata(self):
#         """
#         Gets ImageData
#         """
#         if self._imagedata:
#             return self._imagedata
# 
#     def set_imagedata(self, imagedata):
#         """
#         Sets ImageData
#         """
#         self._imagedata = imagedata
#         self._actor = actor_from_imagedata(self._imagedata)
#         self.update_props()
# 
#     def _update(self):
#         pass
# 
#     def update(self):
#         self._update()
#         self.set_imagedata(self._imagedata)
#         self.update_props()
# 
#     def clone(self):
#         """
#         Returns a Clone of an ImageDataBase instance
#         """
#         imagedata = vtkImageData()
#         imagedata.DeepCopy(self._imagedata)
#         clone = copy.copy(self)
#         clone.set_imagedata(imagedata)
#         clone.set_actor(actor_from_imagedata(self._imagedata))
#         return clone
# 
#     def update_props(self):
# 
#         if self._imagedata:
#             self.props_ = OrderedDict()
#             self.props_["Number of Points"] = self._imagedata.GetNumberOfPoints()
#             bounds = self._imagedata.GetBounds()
# 
#             self.props_["xmin"] = bounds[0]
#             self.props_["xmax"] = bounds[1]
#             self.props_["ymin"] = bounds[2]
#             self.props_["ymax"] = bounds[3]
#             self.props_["zmin"] = np.min(self.data_)
#             self.props_["zmax"] = np.max(self.data_)


import gdal
import numpy as np
from ..utils.vtkhelpers import numpy_to_image
from .base import ImageDataBase
#Author: Miguel Molero <miguel.molero@gmail.com>

__all__=['ReaderTIFF']




class ReaderTIFF(ImageDataBase):

    def __init__(self, filename):
        super(ReaderTIFF, self).__init__()
        self.filename_ = filename

    def _update(self):

        dataset = gdal.Open(self.filename_)

# Path: pcloudpy/core/utils/vtkhelpers.py
# def numpy_to_image(numpy_array):
#     """
#     @brief Convert a numpy 2D or 3D array to a vtkImageData object
#     @param numpy_array 2D or 3D numpy array containing image data
#     @return vtkImageData with the numpy_array content
#     """
# 
#     shape = numpy_array.shape
#     if len(shape) < 2:
#         raise Exception('numpy array must have dimensionality of at least 2')
# 
#     h, w = shape[0], shape[1]
#     c = 1
#     if len(shape) == 3:
#         c = shape[2]
# 
#     # Reshape 2D image to 1D array suitable for conversion to a
#     # vtkArray with numpy_support.numpy_to_vtk()
#     linear_array = np.reshape(numpy_array, (w*h, c))
#     vtk_array = numpy_to_vtk(linear_array)
# 
#     image = vtkImageData()
#     image.SetDimensions(w, h, 1)
#     image.AllocateScalars()
#     image.GetPointData().GetScalars().DeepCopy(vtk_array)
# 
#     return image
# 
# Path: pcloudpy/core/io/base.py
# class ImageDataBase(DataBase):
#     """
#     ImageData Base Class
# 
#     Attributes
#     ----------
#     props_: OrderedDict
#         Dictionary used for the props storing
# 
#     data_: array
#         raw data
# 
# 
#     """
#     def __init__(self):
#         super(ImageDataBase, self).__init__()
#         self.type_ = DataType.IMAGEDATA
# 
#     def get_imagedata(self):
#         """
#         Gets ImageData
#         """
#         if self._imagedata:
#             return self._imagedata
# 
#     def set_imagedata(self, imagedata):
#         """
#         Sets ImageData
#         """
#         self._imagedata = imagedata
#         self._actor = actor_from_imagedata(self._imagedata)
#         self.update_props()
# 
#     def _update(self):
#         pass
# 
#     def update(self):
#         self._update()
#         self.set_imagedata(self._imagedata)
#         self.update_props()
# 
#     def clone(self):
#         """
#         Returns a Clone of an ImageDataBase instance
#         """
#         imagedata = vtkImageData()
#         imagedata.DeepCopy(self._imagedata)
#         clone = copy.copy(self)
#         clone.set_imagedata(imagedata)
#         clone.set_actor(actor_from_imagedata(self._imagedata))
#         return clone
# 
#     def update_props(self):
# 
#         if self._imagedata:
#             self.props_ = OrderedDict()
#             self.props_["Number of Points"] = self._imagedata.GetNumberOfPoints()
#             bounds = self._imagedata.GetBounds()
# 
#             self.props_["xmin"] = bounds[0]
#             self.props_["xmax"] = bounds[1]
#             self.props_["ymin"] = bounds[2]
#             self.props_["ymax"] = bounds[3]
#             self.props_["zmin"] = np.min(self.data_)
#             self.props_["zmax"] = np.max(self.data_)


# Path: pcloudpy/core/io/ReaderTIFF.py
import gdal
import numpy as np
from ..utils.vtkhelpers import numpy_to_image
from .base import ImageDataBase

#Author: Miguel Molero <miguel.molero@gmail.com>

__all__=['ReaderTIFF']




class ReaderTIFF(ImageDataBase):

    def __init__(self, filename):
        super(ReaderTIFF, self).__init__()
        self.filename_ = filename

    def _update(self):

        dataset = gdal.Open(self.filename_)

        band = dataset.GetRasterBand(1)