def Cylinder(center=(0., 0., 0.), direction=(1., 0., 0.), radius=0.5, height=1.0, resolution=100, capping=True, **kwargs): """Create the surface of a cylinder. See also :func:`pyvista.CylinderStructured`. Parameters ---------- center : list or np.ndarray Location of the centroid in [x, y, z] direction : list or np.ndarray Direction cylinder points to in [x, y, z] radius : float Radius of the cylinder. height : float Height of the cylinder. resolution : int Number of points on the circular face of the cylinder. capping : bool, optional Cap cylinder ends with polygons. Default True Return ------ cylinder : pyvista.PolyData Cylinder surface. Examples -------- >>> import pyvista >>> import numpy as np >>> cylinder = pyvista.Cylinder(np.array([1, 2, 3]), np.array([1, 1, 1]), 1, 1) >>> cylinder.plot() # doctest:+SKIP """ capping = kwargs.pop('cap_ends', capping) assert_empty_kwargs(**kwargs) cylinderSource = vtk.vtkCylinderSource() cylinderSource.SetRadius(radius) cylinderSource.SetHeight(height) cylinderSource.SetCapping(capping) cylinderSource.SetResolution(resolution) cylinderSource.Update() surf = pyvista.PolyData(cylinderSource.GetOutput()) surf.rotate_z(-90) translate(surf, center, direction) return surf
def __init__(self, *args, **kwargs): """Initialize the texture.""" assert_empty_kwargs(**kwargs) if len(args) == 1: if isinstance(args[0], vtk.vtkTexture): self._from_texture(args[0]) elif isinstance(args[0], np.ndarray): self._from_array(args[0]) elif isinstance(args[0], vtk.vtkImageData): self._from_image_data(args[0]) elif isinstance(args[0], str): self._from_texture(pyvista.read_texture(args[0])) else: raise TypeError('Table unable to be made from ({})'.format(type(args[0])))
def __init__(self, *args, **kwargs): """Initialize the texture.""" super().__init__(*args, **kwargs) assert_empty_kwargs(**kwargs) if len(args) == 1: if isinstance(args[0], _vtk.vtkTexture): self._from_texture(args[0]) elif isinstance(args[0], np.ndarray): self._from_array(args[0]) elif isinstance(args[0], _vtk.vtkImageData): self._from_image_data(args[0]) elif isinstance(args[0], str): self._from_file(filename=args[0]) else: raise TypeError(f'Table unable to be made from ({type(args[0])})')