def _from_arrays(self, vertices, faces, deep=True, verts=False):
        """
        Set polygons and points from numpy arrays

        Parameters
        ----------
        vertices : np.ndarray of dtype=np.float32 or np.float64
            Vertex array.  3D points.

        faces : np.ndarray of dtype=np.int64
            Face index array.  Faces can contain any number of points.

        Examples
        --------
        >>> import numpy as np
        >>> import vtki
        >>> vertices = np.array([[0, 0, 0],
        ...                      [1, 0, 0],
        ...                      [1, 1, 0],
        ...                      [0, 1, 0],
        ...                      [0.5, 0.5, 1]])
        >>> faces = np.hstack([[4, 0, 1, 2, 3],
        ...                    [3, 0, 1, 4],
        ...                    [3, 1, 2, 4]])  # one square and two triangles
        >>> surf = vtki.PolyData(vertices, faces)

        """
        if deep or verts:
            vtkpoints = vtk.vtkPoints()
            vtkpoints.SetData(numpy_to_vtk(vertices, deep=deep))
            self.SetPoints(vtkpoints)

            # Convert to a vtk array
            vtkcells = vtk.vtkCellArray()
            if faces.dtype != vtki.ID_TYPE:
                faces = faces.astype(vtki.ID_TYPE)

            # get number of faces
            if faces.ndim == 1:
                c = 0
                nfaces = 0
                while c < faces.size:
                    c += faces[c] + 1
                    nfaces += 1
            else:
                nfaces = faces.shape[0]

            idarr = numpy_to_vtkIdTypeArray(faces.ravel(), deep=deep)
            vtkcells.SetCells(nfaces, idarr)
            if (faces.ndim > 1 and faces.shape[1] == 2) or verts:
                self.SetVerts(vtkcells)
            else:
                self.SetPolys(vtkcells)
        else:
            self.points = vertices
            self.faces = faces
def _from_arrays ( self , vertices , faces , deep = True , verts = False ) : if deep or verts : vtkpoints = vtk . vtkPoints ( ) vtkpoints . SetData ( numpy_to_vtk ( vertices , deep = deep ) ) self . SetPoints ( vtkpoints ) vtkcells = vtk . vtkCellArray ( ) if faces . dtype != vtki . ID_TYPE : faces = faces . astype ( vtki . ID_TYPE ) if faces . ndim == 1 : c = 0 nfaces = 0 while c < faces . size : c += faces [ c ] + 1 nfaces += 1 else : nfaces = faces . shape [ 0 ] idarr = numpy_to_vtkIdTypeArray ( faces . ravel ( ) , deep = deep ) vtkcells . SetCells ( nfaces , idarr ) if ( faces . ndim > 1 and faces . shape [ 1 ] == 2 ) or verts : self . SetVerts ( vtkcells ) else : self . SetPolys ( vtkcells ) else : self . points = vertices self . faces = faces
Set polygons and points from numpy arrays

        Parameters
        ----------
        vertices : np.ndarray of dtype=np.float32 or np.float64
            Vertex array.  3D points.

        faces : np.ndarray of dtype=np.int64
            Face index array.  Faces can contain any number of points.

        Examples
        --------
        >>> import numpy as np
        >>> import vtki
        >>> vertices = np.array([[0, 0, 0],
        ...                      [1, 0, 0],
        ...                      [1, 1, 0],
        ...                      [0, 1, 0],
        ...                      [0.5, 0.5, 1]])
        >>> faces = np.hstack([[4, 0, 1, 2, 3],
        ...                    [3, 0, 1, 4],
        ...                    [3, 1, 2, 4]])  # one square and two triangles
        >>> surf = vtki.PolyData(vertices, faces)