Exemplo n.º 1
0
def Disc(center=(0., 0., 0.),
         inner=0.25,
         outer=0.5,
         normal=(0, 0, 1),
         r_res=1,
         c_res=6):
    """Create a polygonal disk with a hole in the center.

    The disk has zero height. The user can specify the inner and outer
    radius of the disk, and the radial and circumferential resolution
    of the polygonal representation.

    Parameters
    ----------
    center : iterable
        Center in ``[x, y, z]``. Middle of the axis of the disc.

    inner : float, optional
        The inner radius.

    outer : float, optional
        The outer radius.

    normal : iterable
        Direction vector in ``[x, y, z]``. Orientation vector of the disc.

    r_res : int, optional
        Number of points in radial direction.

    c_res : int, optional
        Number of points in circumferential direction.

    Returns
    -------
    pyvista.PolyData
        Disk mesh.

    Examples
    --------
    Create a disc with 50 points in the circumferential direction.

    >>> import pyvista
    >>> mesh = pyvista.Disc(c_res=50)
    >>> mesh.plot(show_edges=True, line_width=5)

    """
    src = _vtk.vtkDiskSource()
    src.SetInnerRadius(inner)
    src.SetOuterRadius(outer)
    src.SetRadialResolution(r_res)
    src.SetCircumferentialResolution(c_res)
    src.Update()
    normal = np.array(normal)
    center = np.array(center)
    surf = pyvista.wrap(src.GetOutput())
    surf.rotate_y(90)
    translate(surf, center, normal)
    return surf
Exemplo n.º 2
0
def Disc(center=(0., 0., 0.),
         inner=0.25,
         outer=0.5,
         normal=(0, 0, 1),
         r_res=1,
         c_res=6):
    """Create a polygonal disk with a hole in the center.

    The disk has zero height. The user can specify the inner and outer radius
    of the disk, and the radial and circumferential resolution of the polygonal
    representation.

    Parameters
    ----------
    center : np.ndarray or list
        Center in [x, y, z]. Middle of the axis of the disc.

    inner : float
        The inner radius.

    outer : float
        The outer radius.

    normal : np.ndarray or list
        Direction vector in [x, y, z]. Orientation vector of the disc.

    r_res: int
        Number of points in radius direction.

    c_res: int
        Number of points in circumferential direction.

    """
    src = _vtk.vtkDiskSource()
    src.SetInnerRadius(inner)
    src.SetOuterRadius(outer)
    src.SetRadialResolution(r_res)
    src.SetCircumferentialResolution(c_res)
    src.Update()
    normal = np.array(normal)
    center = np.array(center)
    surf = pyvista.PolyData(src.GetOutput())
    surf.rotate_y(90)
    translate(surf, center, normal)
    return surf