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: Increase the number of triangles in a single, connected triangular mesh.
  
  Uses one of the following vtk subdivision filters to subdivide a mesh:
  
  * ``vtkButterflySubdivisionFilter``
  * ``vtkLoopSubdivisionFilter``
  * ``vtkLinearSubdivisionFilter``
  
  Linear subdivision results in the fastest mesh subdivision,
  but it does not smooth mesh edges, but rather splits each
  triangle into 4 smaller triangles.
  
  Butterfly and loop subdivision perform smoothing when
  dividing, and may introduce artifacts into the mesh when
  dividing.
  
  .. note::
     Subdivision filter sometimes fails for multiple part
     meshes.  The input should be one connected mesh.
  
  Parameters
  ----------
  nsub : int
      Number of subdivisions.  Each subdivision creates 4 new
      triangles, so the number of resulting triangles is
      ``nface*4**nsub`` where ``nface`` is the current number of
      faces.
  
  subfilter : str, default: "linear"
      Can be one of the following:
  
      * ``'butterfly'``
      * ``'loop'``
      * ``'linear'``
  
  inplace : bool, default: False
      Updates mesh in-place.
  
  progress_bar : bool, default: False
      Display a progress bar to indicate progress.
  
  Returns
  -------
  pyvista.PolyData
      Subdivided mesh.
  
  Examples
  --------
  First, create an example coarse sphere mesh and plot it.
  
  >>> from pyvista import examples
  >>> import pyvista as pv
  >>> mesh = pv.Sphere(phi_resolution=10, theta_resolution=10)
  >>> mesh.plot(show_edges=True, line_width=3)
  
  Subdivide the sphere mesh using linear subdivision.
  
  >>> submesh = mesh.subdivide(1, 'linear')
  >>> submesh.plot(show_edges=True, line_width=3)
  
  Subdivide the sphere mesh using loop subdivision.
  
  >>> submesh = mesh.subdivide(1, 'loop')
  >>> submesh.plot(show_edges=True, line_width=3)
  
  Subdivide the sphere mesh using butterfly subdivision.
  
  >>> submesh = mesh.subdivide(1, 'butterfly')
  >>> submesh.plot(show_edges=True, line_width=3)
docstr_tok: ["Increase","the","number","of","triangles","in","a","single",",","connected","triangular","mesh",".","Uses","one","of","the","following","vtk","subdivision","filters","to","subdivide","a","mesh",":","*","``","vtkButterflySubdivisionFilter","``","*","``","vtkLoopSubdivisionFilter","``","*","``","vtkLinearSubdivisionFilter","``","Linear","subdivision","results","in","the","fastest","mesh","subdivision",",","but","it","does","not","smooth","mesh","edges",",","but","rather","splits","each","triangle","into","4","smaller","triangles",".","Butterfly","and","loop","subdivision","perform","smoothing","when","dividing",",","and","may","introduce","artifacts","into","the","mesh","when","dividing",".","..","note",":",":","Subdivision","filter","sometimes","fails","for","multiple","part","meshes",".","The","input","should","be","one","connected","mesh",".","Parameters","--","--","--","--","--","nsub",":","int","Number","of","subdivisions",".","Each","subdivision","creates","4","new","triangles",",","so","the","number","of","resulting","triangles","is","``","nface","*","4","*","*","nsub","``","where","``","nface","``","is","the","current","number","of","faces",".","subfilter",":","str",",","default",":","``","linear","''","Can","be","one","of","the","following",":","*","``","'butterfly","'","``","*","``","'loop","'","``","*","``","'linear","'","``","inplace",":","bool",",","default",":","False","Updates","mesh","in-place",".","progress_bar",":","bool",",","default",":","False","Display","a","progress","bar","to","indicate","progress",".","Returns","--","--","--","-","pyvista.PolyData","Subdivided","mesh",".","Examples","--","--","--","--","First",",","create","an","example","coarse","sphere","mesh","and","plot","it",".",">",">",">","from","pyvista","import","examples",">",">",">","import","pyvista","as","pv",">",">",">","mesh","=","pv.Sphere","(","phi_resolution=10",",","theta_resolution=10",")",">",">",">","mesh.plot","(","show_edges=True",",","line_width=3",")","Subdivide","the","sphere","mesh","using","linear","subdivision",".",">",">",">","submesh","=","mesh.subdivide","(","1",",","'linear","'",")",">",">",">","submesh.plot","(","show_edges=True",",","line_width=3",")","Subdivide","the","sphere","mesh","using","loop","subdivision",".",">",">",">","submesh","=","mesh.subdivide","(","1",",","'loop","'",")",">",">",">","submesh.plot","(","show_edges=True",",","line_width=3",")","Subdivide","the","sphere","mesh","using","butterfly","subdivision",".",">",">",">","submesh","=","mesh.subdivide","(","1",",","'butterfly","'",")",">",">",">","submesh.plot","(","show_edges=True",",","line_width=3",")"]
code: def subdivide(
      self, nsub, subfilter="linear", inplace=False, progress_bar=False
  ):
      """Increase the number of triangles in a single, connected triangular mesh.
  
      Uses one of the following vtk subdivision filters to subdivide a mesh:
  
      * ``vtkButterflySubdivisionFilter``
      * ``vtkLoopSubdivisionFilter``
      * ``vtkLinearSubdivisionFilter``
  
      Linear subdivision results in the fastest mesh subdivision,
      but it does not smooth mesh edges, but rather splits each
      triangle into 4 smaller triangles.
  
      Butterfly and loop subdivision perform smoothing when
      dividing, and may introduce artifacts into the mesh when
      dividing.
  
      .. note::
         Subdivision filter sometimes fails for multiple part
         meshes.  The input should be one connected mesh.
  
      Parameters
      ----------
      nsub : int
          Number of subdivisions.  Each subdivision creates 4 new
          triangles, so the number of resulting triangles is
          ``nface*4**nsub`` where ``nface`` is the current number of
          faces.
  
      subfilter : str, default: "linear"
          Can be one of the following:
  
          * ``'butterfly'``
          * ``'loop'``
          * ``'linear'``
  
      inplace : bool, default: False
          Updates mesh in-place.
  
      progress_bar : bool, default: False
          Display a progress bar to indicate progress.
  
      Returns
      -------
      pyvista.PolyData
          Subdivided mesh.
  
      Examples
      --------
      First, create an example coarse sphere mesh and plot it.
  
      >>> from pyvista import examples
      >>> import pyvista as pv
      >>> mesh = pv.Sphere(phi_resolution=10, theta_resolution=10)
      >>> mesh.plot(show_edges=True, line_width=3)
  
      Subdivide the sphere mesh using linear subdivision.
  
      >>> submesh = mesh.subdivide(1, 'linear')
      >>> submesh.plot(show_edges=True, line_width=3)
  
      Subdivide the sphere mesh using loop subdivision.
  
      >>> submesh = mesh.subdivide(1, 'loop')
      >>> submesh.plot(show_edges=True, line_width=3)
  
      Subdivide the sphere mesh using butterfly subdivision.
  
      >>> submesh = mesh.subdivide(1, 'butterfly')
      >>> submesh.plot(show_edges=True, line_width=3)
  
      """
      if not self.is_all_triangles:
          raise NotAllTrianglesError(
              "Input mesh for subdivision must be all triangles."
          )
  
      subfilter = subfilter.lower()
      if subfilter == "linear":
          sfilter = _vtk.vtkLinearSubdivisionFilter()
      elif subfilter == "butterfly":
          sfilter = _vtk.vtkButterflySubdivisionFilter()
      elif subfilter == "loop":
          sfilter = _vtk.vtkLoopSubdivisionFilter()
      else:
          raise ValueError(
              "Subdivision filter must be one of the following: "
              "'butterfly', 'loop', or 'linear'"
          )
  
      # Subdivide
      sfilter.SetCheckForTriangles(False)  # we already check for this
      sfilter.SetNumberOfSubdivisions(nsub)
      sfilter.SetInputData(self)
      _update_alg(sfilter, progress_bar, "Subdividing Mesh")
  
      submesh = _get_output(sfilter)
      if inplace:
          self.copy_from(submesh, deep=False)
          return self
  
      return submesh
  
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 18 for calling the PolyDataFilters obj's underlying member method code with example usage: obj.subdivide(nsub, subfilter, inplace, progress_bar) and returns: submesh, self