# Path: pcloudpy/core/io/base.py
# class PolyDataBase(DataBase):
#     """
#     PolyData Base Class
# 
# 
#     Attributes
#     ---------
#     data_: Array
#         store array od points of the the point cloud
# 
#     props_: OrderedDict
#         Dictionary used for the props storing
# 
#     """
# 
#     def __init__(self):
#         super(PolyDataBase, self).__init__()
#         self.type_ = DataType.POLYDATA
# 
#     def get_polydata(self):
#         """
#         Gets PolyData (vtkPolyData)
#         """
#         if self._polydata:
#             return self._polydata
# 
#     def set_polydata(self, polydata):
#         self._polydata = polydata
#         self._actor = actor_from_polydata(self._polydata)
#         self.update_props()
# 
#     def update(self):
#         """
#         Update Reader
#         """
#         self._update()
#         self.set_polydata(self._polydata)
#         self.update_props()
# 
#     def _update(self):
#         pass
# 
#     def clone(self):
#         polydata = vtkPolyData()
#         polydata.DeepCopy(self._polydata)
# 
#         clone = copy.copy(self)
#         clone.set_polydata(polydata)
#         clone.set_actor(actor_from_polydata(polydata))
#         return clone
# 
#     def update_data_from(self, polydata):
# 
#         self._data = numpy_from_polydata(polydata)
#         self._polydata = polydata
#         self._actor = actor_from_polydata(self._polydata)
#         self.update_props()
# 
#     def update_props(self):
# 
#         if self._polydata:
#             self.props_ = OrderedDict()
#             self.props_["Number of Points"] = self._polydata.GetNumberOfPoints()
# 
#             if isinstance(self._polydata, vtkPolyData):
#                 polys = self._polydata.GetNumberOfPolys()
#                 lines = self._polydata.GetNumberOfLines()
# 
#                 if polys !=0:
#                     self.props_["Number of Polygons"] = polys
#                 if lines !=0:
#                     self.props_["Number of Lines"] = lines
# 
#                 verts = self._polydata.GetNumberOfVerts()
#                 if verts !=0:
#                     self.props_["Number of Vertices"] = verts
# 
#                 strips = self._polydata.GetNumberOfStrips()
#                 if strips !=0:
#                     self.props_["Number of Triangles"] = strips
# 
#             bounds = self._polydata.GetBounds()
#             self.props_["xmin"] = bounds[0]
#             self.props_["xmax"] = bounds[1]
#             self.props_["ymin"] = bounds[2]
#             self.props_["ymax"] = bounds[3]
#             self.props_["zmin"] = bounds[4]
#             self.props_["zmax"] = bounds[5]
# 
# Path: pcloudpy/core/io/converters.py
# def get_polydata_from(points, tr_re):
# 
#     numberPoints = len(points)
#     Points = vtkPoints()
#     ntype = get_numpy_array_type(Points.GetDataType())
#     points_vtk = numpy_to_vtk(np.asarray(points, order='C',dtype=ntype), deep=1)
#     Points.SetNumberOfPoints(numberPoints)
#     Points.SetData(points_vtk)
# 
#     Triangles = vtkCellArray()
#     for item in tr_re:
#         Triangle = vtkTriangle()
#         Triangle.GetPointIds().SetId(0,item[0])
#         Triangle.GetPointIds().SetId(1,item[1])
#         Triangle.GetPointIds().SetId(2,item[2])
#         Triangles.InsertNextCell(Triangle)
# 
#     polydata = vtkPolyData()
#     polydata.SetPoints(Points)
#     polydata.SetPolys(Triangles)
# 
#     polydata.Modified()
#     polydata.Update()
# 
#     return polydata


import numpy as np
from vtk import vtkPLYReader, vtkPolyData, vtkPLYWriter
from .base import PolyDataBase
from .converters import get_polydata_from
    example:
        reader = ReaderPLY(filename)
        reader.update()

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

    def _update(self):
        reader = vtkPLYReader()
        reader.SetFileName(self.filename_)
        reader.Update()
        self._polydata = reader.GetOutput()


class WriterPLY:
    """
    Function library for exporting different data into PLY format


    - from_numpy
    - from_polydata


    """

    @staticmethod
    def from_numpy(points, tr_re, output_filename):


# Path: pcloudpy/core/io/base.py
# class PolyDataBase(DataBase):
#     """
#     PolyData Base Class
# 
# 
#     Attributes
#     ---------
#     data_: Array
#         store array od points of the the point cloud
# 
#     props_: OrderedDict
#         Dictionary used for the props storing
# 
#     """
# 
#     def __init__(self):
#         super(PolyDataBase, self).__init__()
#         self.type_ = DataType.POLYDATA
# 
#     def get_polydata(self):
#         """
#         Gets PolyData (vtkPolyData)
#         """
#         if self._polydata:
#             return self._polydata
# 
#     def set_polydata(self, polydata):
#         self._polydata = polydata
#         self._actor = actor_from_polydata(self._polydata)
#         self.update_props()
# 
#     def update(self):
#         """
#         Update Reader
#         """
#         self._update()
#         self.set_polydata(self._polydata)
#         self.update_props()
# 
#     def _update(self):
#         pass
# 
#     def clone(self):
#         polydata = vtkPolyData()
#         polydata.DeepCopy(self._polydata)
# 
#         clone = copy.copy(self)
#         clone.set_polydata(polydata)
#         clone.set_actor(actor_from_polydata(polydata))
#         return clone
# 
#     def update_data_from(self, polydata):
# 
#         self._data = numpy_from_polydata(polydata)
#         self._polydata = polydata
#         self._actor = actor_from_polydata(self._polydata)
#         self.update_props()
# 
#     def update_props(self):
# 
#         if self._polydata:
#             self.props_ = OrderedDict()
#             self.props_["Number of Points"] = self._polydata.GetNumberOfPoints()
# 
#             if isinstance(self._polydata, vtkPolyData):
#                 polys = self._polydata.GetNumberOfPolys()
#                 lines = self._polydata.GetNumberOfLines()
# 
#                 if polys !=0:
#                     self.props_["Number of Polygons"] = polys
#                 if lines !=0:
#                     self.props_["Number of Lines"] = lines
# 
#                 verts = self._polydata.GetNumberOfVerts()
#                 if verts !=0:
#                     self.props_["Number of Vertices"] = verts
# 
#                 strips = self._polydata.GetNumberOfStrips()
#                 if strips !=0:
#                     self.props_["Number of Triangles"] = strips
# 
#             bounds = self._polydata.GetBounds()
#             self.props_["xmin"] = bounds[0]
#             self.props_["xmax"] = bounds[1]
#             self.props_["ymin"] = bounds[2]
#             self.props_["ymax"] = bounds[3]
#             self.props_["zmin"] = bounds[4]
#             self.props_["zmax"] = bounds[5]
# 
# Path: pcloudpy/core/io/converters.py
# def get_polydata_from(points, tr_re):
# 
#     numberPoints = len(points)
#     Points = vtkPoints()
#     ntype = get_numpy_array_type(Points.GetDataType())
#     points_vtk = numpy_to_vtk(np.asarray(points, order='C',dtype=ntype), deep=1)
#     Points.SetNumberOfPoints(numberPoints)
#     Points.SetData(points_vtk)
# 
#     Triangles = vtkCellArray()
#     for item in tr_re:
#         Triangle = vtkTriangle()
#         Triangle.GetPointIds().SetId(0,item[0])
#         Triangle.GetPointIds().SetId(1,item[1])
#         Triangle.GetPointIds().SetId(2,item[2])
#         Triangles.InsertNextCell(Triangle)
# 
#     polydata = vtkPolyData()
#     polydata.SetPoints(Points)
#     polydata.SetPolys(Triangles)
# 
#     polydata.Modified()
#     polydata.Update()
# 
#     return polydata


# Path: pcloudpy/core/io/ReaderPLY.py
import numpy as np
from vtk import vtkPLYReader, vtkPolyData, vtkPLYWriter
from .base import PolyDataBase
from .converters import get_polydata_from

    example:
        reader = ReaderPLY(filename)
        reader.update()

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

    def _update(self):
        reader = vtkPLYReader()
        reader.SetFileName(self.filename_)
        reader.Update()
        self._polydata = reader.GetOutput()


class WriterPLY:
    """
    Function library for exporting different data into PLY format


    - from_numpy
    - from_polydata


    """

    @staticmethod
    def from_numpy(points, tr_re, output_filename):


        polydata = get_polydata_from(points, tr_re)