class_docstr: An internal class to manage filters/algorithms for polydata datasets.
class_docstr_tok: ["An","internal","class","to","manage","filters\/algorithms","for","polydata","datasets","."]
docstr: Generate filled contours.
  
  Generates filled contours for vtkPolyData. Filled contours are
  bands of cells that all have the same cell scalar value, and can
  therefore be colored the same. The method is also referred to as
  filled contour generation.
  
  This filter implements `vtkBandedPolyDataContourFilter
  <https://vtk.org/doc/nightly/html/classvtkBandedPolyDataContourFilter.html>`_.
  
  Parameters
  ----------
  n_contours : int
      Number of contours.
  
  rng : Sequence, optional
      Range of the scalars. Optional and defaults to the minimum and
      maximum of the active scalars of ``scalars``.
  
  scalars : str, optional
      The name of the scalar array to use for contouring.  If ``None``,
      the active scalar array will be used.
  
  component : int, default: 0
      The component to use of an input scalars array with more than one
      component.
  
  clip_tolerance : float, default: 1e-6
      Set/Get the clip tolerance.  Warning: setting this too large will
      certainly cause numerical issues. Change from the default value at
      your own risk. The actual internal clip tolerance is computed by
      multiplying ``clip_tolerance`` by the scalar range.
  
  generate_contour_edges : bool, default: True
      Controls whether contour edges are generated.  Contour edges are
      the edges between bands. If enabled, they are generated from
      polygons/triangle strips and returned as a second output.
  
  scalar_mode : str, default: 'value'
      Control whether the cell scalars are output as an integer index or
      a scalar value.  If ``'index'``, the index refers to the bands
      produced by the clipping range. If ``'value'``, then a scalar value
      which is a value between clip values is used.
  
  clipping : bool, default: True
      Indicate whether to clip outside ``rng`` and only return cells with
      values within ``rng``.
  
  progress_bar : bool, default: False
      Display a progress bar to indicate progress.
  
  Returns
  -------
  output : pyvista.PolyData
      Surface containing the contour surface.
  
  edges : pyvista.PolyData
      Optional edges when ``generate_contour_edges`` is ``True``.
  
  Examples
  --------
  Plot the random hills dataset and with 8 contour lines. Note how we use 7
  colors here (``n_contours - 1``).
  
  >>> import pyvista as pv
  >>> from pyvista import examples
  
  >>> mesh = examples.load_random_hills()
  >>> n_contours = 8
  >>> _, edges = mesh.contour_banded(n_contours)
  
  >>> pl = pv.Plotter()
  >>> _ = pl.add_mesh(
  ...     edges,
  ...     line_width=5,
  ...     render_lines_as_tubes=True,
  ...     color='k',
  ... )
  >>> _ = pl.add_mesh(mesh, n_colors=n_contours - 1, cmap='Set3')
  >>> pl.show()
  
  Extract the surface from the uniform grid dataset and plot its contours
  alongside the output from the banded contour filter.
  
  >>> surf = examples.load_uniform().extract_surface()
  >>> n_contours = 5
  >>> rng = [200, 500]
  >>> output, edges = surf.contour_banded(n_contours, rng=rng)
  
  >>> dargs = dict(n_colors=n_contours - 1, clim=rng)
  >>> pl = pv.Plotter()
  >>> _ = pl.add_mesh(
  ...     edges,
  ...     line_width=5,
  ...     render_lines_as_tubes=True,
  ...     color='k',
  ... )
  >>> _ = pl.add_mesh(surf, opacity=0.3, **dargs)
  >>> _ = pl.add_mesh(output, **dargs)
  >>> pl.show()
docstr_tok: ["Generate","filled","contours",".","Generates","filled","contours","for","vtkPolyData",".","Filled","contours","are","bands","of","cells","that","all","have","the","same","cell","scalar","value",",","and","can","therefore","be","colored","the","same",".","The","method","is","also","referred","to","as","filled","contour","generation",".","This","filter","implements","`","vtkBandedPolyDataContourFilter","<","https",":","\/\/vtk.org\/doc\/nightly\/html\/classvtkBandedPolyDataContourFilter.html",">","`","_",".","Parameters","--","--","--","--","--","n_contours",":","int","Number","of","contours",".","rng",":","Sequence",",","optional","Range","of","the","scalars",".","Optional","and","defaults","to","the","minimum","and","maximum","of","the","active","scalars","of","``","scalars","``",".","scalars",":","str",",","optional","The","name","of","the","scalar","array","to","use","for","contouring",".","If","``","None","``",",","the","active","scalar","array","will","be","used",".","component",":","int",",","default",":","0","The","component","to","use","of","an","input","scalars","array","with","more","than","one","component",".","clip_tolerance",":","float",",","default",":","1e-6","Set\/Get","the","clip","tolerance",".","Warning",":","setting","this","too","large","will","certainly","cause","numerical","issues",".","Change","from","the","default","value","at","your","own","risk",".","The","actual","internal","clip","tolerance","is","computed","by","multiplying","``","clip_tolerance","``","by","the","scalar","range",".","generate_contour_edges",":","bool",",","default",":","True","Controls","whether","contour","edges","are","generated",".","Contour","edges","are","the","edges","between","bands",".","If","enabled",",","they","are","generated","from","polygons\/triangle","strips","and","returned","as","a","second","output",".","scalar_mode",":","str",",","default",":","'value'","Control","whether","the","cell","scalars","are","output","as","an","integer","index","or","a","scalar","value",".","If","``","'index","'","``",",","the","index","refers","to","the","bands","produced","by","the","clipping","range",".","If","``","'value","'","``",",","then","a","scalar","value","which","is","a","value","between","clip","values","is","used",".","clipping",":","bool",",","default",":","True","Indicate","whether","to","clip","outside","``","rng","``","and","only","return","cells","with","values","within","``","rng","``",".","progress_bar",":","bool",",","default",":","False","Display","a","progress","bar","to","indicate","progress",".","Returns","--","--","--","-","output",":","pyvista.PolyData","Surface","containing","the","contour","surface",".","edges",":","pyvista.PolyData","Optional","edges","when","``","generate_contour_edges","``","is","``","True","``",".","Examples","--","--","--","--","Plot","the","random","hills","dataset","and","with","8","contour","lines",".","Note","how","we","use","7","colors","here","(","``","n_contours","-","1","``",")",".",">",">",">","import","pyvista","as","pv",">",">",">","from","pyvista","import","examples",">",">",">","mesh","=","examples.load_random_hills","(",")",">",">",">","n_contours","=","8",">",">",">","_",",","edges","=","mesh.contour_banded","(","n_contours",")",">",">",">","pl","=","pv.Plotter","(",")",">",">",">","_","=","pl.add_mesh","(","...","edges",",","...","line_width=5",",","...","render_lines_as_tubes=True",",","...","color=","'","k","'",",","...",")",">",">",">","_","=","pl.add_mesh","(","mesh",",","n_colors=n_contours","-","1",",","cmap='Set3","'",")",">",">",">","pl.show","(",")","Extract","the","surface","from","the","uniform","grid","dataset","and","plot","its","contours","alongside","the","output","from","the","banded","contour","filter",".",">",">",">","surf","=","examples.load_uniform","(",")",".extract_surface","(",")",">",">",">","n_contours","=","5",">",">",">","rng","=","[","200",",","500","]",">",">",">","output",",","edges","=","surf.contour_banded","(","n_contours",",","rng=rng",")",">",">",">","dargs","=","dict","(","n_colors=n_contours","-","1",",","clim=rng",")",">",">",">","pl","=","pv.Plotter","(",")",">",">",">","_","=","pl.add_mesh","(","...","edges",",","...","line_width=5",",","...","render_lines_as_tubes=True",",","...","color=","'","k","'",",","...",")",">",">",">","_","=","pl.add_mesh","(","surf",",","opacity=0.3",",","*","*","dargs",")",">",">",">","_","=","pl.add_mesh","(","output",",","*","*","dargs",")",">",">",">","pl.show","(",")"]
code: def contour_banded(
      self,
      n_contours,
      rng=None,
      scalars=None,
      component=0,
      clip_tolerance=1e-6,
      generate_contour_edges=True,
      scalar_mode="value",
      clipping=True,
      progress_bar=False,
  ):
      """Generate filled contours.
  
      Generates filled contours for vtkPolyData. Filled contours are
      bands of cells that all have the same cell scalar value, and can
      therefore be colored the same. The method is also referred to as
      filled contour generation.
  
      This filter implements `vtkBandedPolyDataContourFilter
      <https://vtk.org/doc/nightly/html/classvtkBandedPolyDataContourFilter.html>`_.
  
      Parameters
      ----------
      n_contours : int
          Number of contours.
  
      rng : Sequence, optional
          Range of the scalars. Optional and defaults to the minimum and
          maximum of the active scalars of ``scalars``.
  
      scalars : str, optional
          The name of the scalar array to use for contouring.  If ``None``,
          the active scalar array will be used.
  
      component : int, default: 0
          The component to use of an input scalars array with more than one
          component.
  
      clip_tolerance : float, default: 1e-6
          Set/Get the clip tolerance.  Warning: setting this too large will
          certainly cause numerical issues. Change from the default value at
          your own risk. The actual internal clip tolerance is computed by
          multiplying ``clip_tolerance`` by the scalar range.
  
      generate_contour_edges : bool, default: True
          Controls whether contour edges are generated.  Contour edges are
          the edges between bands. If enabled, they are generated from
          polygons/triangle strips and returned as a second output.
  
      scalar_mode : str, default: 'value'
          Control whether the cell scalars are output as an integer index or
          a scalar value.  If ``'index'``, the index refers to the bands
          produced by the clipping range. If ``'value'``, then a scalar value
          which is a value between clip values is used.
  
      clipping : bool, default: True
          Indicate whether to clip outside ``rng`` and only return cells with
          values within ``rng``.
  
      progress_bar : bool, default: False
          Display a progress bar to indicate progress.
  
      Returns
      -------
      output : pyvista.PolyData
          Surface containing the contour surface.
  
      edges : pyvista.PolyData
          Optional edges when ``generate_contour_edges`` is ``True``.
  
      Examples
      --------
      Plot the random hills dataset and with 8 contour lines. Note how we use 7
      colors here (``n_contours - 1``).
  
      >>> import pyvista as pv
      >>> from pyvista import examples
  
      >>> mesh = examples.load_random_hills()
      >>> n_contours = 8
      >>> _, edges = mesh.contour_banded(n_contours)
  
      >>> pl = pv.Plotter()
      >>> _ = pl.add_mesh(
      ...     edges,
      ...     line_width=5,
      ...     render_lines_as_tubes=True,
      ...     color='k',
      ... )
      >>> _ = pl.add_mesh(mesh, n_colors=n_contours - 1, cmap='Set3')
      >>> pl.show()
  
      Extract the surface from the uniform grid dataset and plot its contours
      alongside the output from the banded contour filter.
  
      >>> surf = examples.load_uniform().extract_surface()
      >>> n_contours = 5
      >>> rng = [200, 500]
      >>> output, edges = surf.contour_banded(n_contours, rng=rng)
  
      >>> dargs = dict(n_colors=n_contours - 1, clim=rng)
      >>> pl = pv.Plotter()
      >>> _ = pl.add_mesh(
      ...     edges,
      ...     line_width=5,
      ...     render_lines_as_tubes=True,
      ...     color='k',
      ... )
      >>> _ = pl.add_mesh(surf, opacity=0.3, **dargs)
      >>> _ = pl.add_mesh(output, **dargs)
      >>> pl.show()
  
      """
      if scalars is None:
          set_default_active_scalars(self)
          if self.point_data.active_scalars_name is None:
              raise MissingDataError("No point scalars to contour.")
          scalars = self.active_scalars_name
      arr = get_array(self, scalars, preference="point", err=False)
      if arr is None:
          raise ValueError("No arrays present to contour.")
      field = get_array_association(self, scalars, preference="point")
      if field != FieldAssociation.POINT:
          raise ValueError("Only point data can be contoured.")
  
      if rng is None:
          rng = (self.active_scalars.min(), self.active_scalars.max())
  
      alg = _vtk.vtkBandedPolyDataContourFilter()
      alg.SetInputArrayToProcess(
          0, 0, 0, field.value, scalars
      )  # args: (idx, port, connection, field, name)
      alg.GenerateValues(n_contours, rng[0], rng[1])
      alg.SetInputDataObject(self)
      alg.SetClipping(clipping)
      if scalar_mode == "value":
          alg.SetScalarModeToValue()
      elif scalar_mode == "index":
          alg.SetScalarModeToIndex()
      else:
          raise ValueError(
              f'Invalid scalar mode "{scalar_mode}". Should be either "value" or "index".'
          )
      alg.SetGenerateContourEdges(generate_contour_edges)
      alg.SetClipTolerance(clip_tolerance)
      alg.SetComponent(component)
      _update_alg(alg, progress_bar, "Contouring Mesh")
      mesh = _get_output(alg)
  
      # Must rename array as VTK sets the active scalars array name to a nullptr.
      # Please note this was fixed upstream in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9840
      for i in range(mesh.GetPointData().GetNumberOfArrays()):
          array = mesh.GetPointData().GetAbstractArray(i)
          name = array.GetName()
          if name is None:
              array.SetName(self.point_data.active_scalars_name)
      for i in range(mesh.GetCellData().GetNumberOfArrays()):
          array = mesh.GetCellData().GetAbstractArray(i)
          name = array.GetName()
          if name is None:
              array.SetName(self.cell_data.active_scalars_name)
  
      if generate_contour_edges:
          return mesh, wrap(alg.GetContourEdgesOutput())
      return mesh
  
imports: import collections.abc
  import warnings
  import numpy
  import pyvista
  from pyvista.core import _vtk_core
  from pyvista.core.errors import MissingDataError, NotAllTrianglesError, PyVistaFutureWarning, VTKVersionError
  from pyvista.core.filters import _get_output, _update_alg
  from pyvista.core.filters.data_set import DataSetFilters
  from pyvista.core.utilities.arrays import FieldAssociation, get_array, get_array_association, set_default_active_scalars, vtk_id_list_to_array
  from pyvista.core.utilities.geometric_objects import NORMALS
  from pyvista.core.utilities.helpers import generate_plane, wrap
  from pyvista.core.utilities.misc import abstract_class, assert_empty_kwargs
label_desc: Use image node_id 42 for calling the PolyDataFilters obj's underlying member method code with example usage: obj.contour_banded(n_contours, rng, scalars, component, clip_tolerance, generate_contour_edges, scalar_mode, clipping, progress_bar) and returns: mesh, mesh,  wrap