Beispiel #1
0
def Polygon(center=(0.,0.,0.), radius=1, normal=(0,0,1), n_sides=6):
    """Create a polygon.

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

    radius : float
        The radius of the polygon.

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

    n_sides : int
        Number of sides of the polygon.

    """
    src = _vtk.vtkRegularPolygonSource()
    src.SetCenter(center)
    src.SetNumberOfSides(n_sides)
    src.SetRadius(radius)
    src.SetNormal(normal)
    src.Update()
    return pyvista.wrap(src.GetOutput())
Beispiel #2
0
def Polygon(center=(0.,0.,0.), radius=1, normal=(0,0,1), n_sides=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 polygon.

    radius : float
        The radius of the polygon

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

    n_sides : int
        Number of sides of the polygon

    """
    src = _vtk.vtkRegularPolygonSource()
    src.SetCenter(center)
    src.SetNumberOfSides(n_sides)
    src.SetRadius(radius)
    src.SetNormal(normal)
    src.Update()
    return pyvista.wrap(src.GetOutput())
def Polygon(center=(0., 0., 0.), radius=1, normal=(0, 0, 1), n_sides=6):
    """Create a polygon.

    Parameters
    ----------
    center : iterable, optional
        Center in ``[x, y, z]``. Central axis of the polygon passes
        through this point.

    radius : float, optional
        The radius of the polygon.

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

    n_sides : int, optional
        Number of sides of the polygon.

    Returns
    -------
    pyvista.PolyData
        Mesh of the polygon.

    Examples
    --------
    Create an 8 sided polygon.

    >>> import pyvista
    >>> mesh = pyvista.Polygon(n_sides=8)
    >>> mesh.plot(show_edges=True, line_width=5)

    """
    src = _vtk.vtkRegularPolygonSource()
    src.SetCenter(center)
    src.SetNumberOfSides(n_sides)
    src.SetRadius(radius)
    src.SetNormal(normal)
    src.Update()
    return pyvista.wrap(src.GetOutput())