class_docstr: A QuadMesh represents 2D rectangular grid expressed as x- and
  y-coordinates defined as 1D or 2D arrays. Unlike the Image type
  a QuadMesh may be regularly or irregularly spaced and contain
  either bin edges or bin centers. If bin edges are supplied the
  shape of the x/y-coordinate arrays should be one greater than the
  shape of the value array.
  
  The default interface expects data to be specified in the form:
  
      QuadMesh((X, Y, Z))
  
  where X and Y may be 1D or 2D arrays of the shape N(+1) and M(+1)
  respectively or N(+1)xM(+1) and the Z value array should be of
  shape NxM. Other gridded formats such as xarray are also supported
  if installed.
  
  The grid orientation follows the standard matrix convention: An
  array Z with shape (nrows, ncolumns) is plotted with the column
  number as X and the row number as Y.
class_docstr_tok: ["A","QuadMesh","represents","2D","rectangular","grid","expressed","as","x-","and","y-coordinates","defined","as","1D","or","2D","arrays",".","Unlike","the","Image","type","a","QuadMesh","may","be","regularly","or","irregularly","spaced","and","contain","either","bin","edges","or","bin","centers",".","If","bin","edges","are","supplied","the","shape","of","the","x\/y-coordinate","arrays","should","be","one","greater","than","the","shape","of","the","value","array",".","The","default","interface","expects","data","to","be","specified","in","the","form",":","QuadMesh","(","(","X",",","Y",",","Z",")",")","where","X","and","Y","may","be","1D","or","2D","arrays","of","the","shape","N","(","+1",")","and","M","(","+1",")","respectively","or","N","(","+1",")","xM","(","+1",")","and","the","Z","value","array","should","be","of","shape","NxM",".","Other","gridded","formats","such","as","xarray","are","also","supported","if","installed",".","The","grid","orientation","follows","the","standard","matrix","convention",":","An","array","Z","with","shape","(","nrows",",","ncolumns",")","is","plotted","with","the","column","number","as","X","and","the","row","number","as","Y","."]
docstr: Converts a QuadMesh into a TriMesh.
docstr_tok: ["Converts","a","QuadMesh","into","a","TriMesh","."]
code: def trimesh(self):
      """
      Converts a QuadMesh into a TriMesh.
      """
      # Generate vertices
      xs = self.interface.coords(self, 0, edges=True)
      ys = self.interface.coords(self, 1, edges=True)
  
      if xs.ndim == 1:
          if np.all(xs[1:] < xs[:-1]):
              xs = xs[::-1]
          if np.all(ys[1:] < ys[:-1]):
              ys = ys[::-1]
          xs, ys = (
              np.tile(xs[:, np.newaxis], len(ys)).T,
              np.tile(ys[:, np.newaxis], len(xs)),
          )
      vertices = (xs.T.flatten(), ys.T.flatten())
  
      # Generate triangle simplexes
      shape = self.dimension_values(2, flat=False).shape
      s0 = shape[0]
      t1 = np.arange(np.prod(shape))
      js = t1 // s0
      t1s = js * (s0 + 1) + t1 % s0
      t2s = t1s + 1
      t3s = (js + 1) * (s0 + 1) + t1 % s0
      t4s = t2s
      t5s = t3s
      t6s = t3s + 1
      t1 = np.concatenate([t1s, t6s])
      t2 = np.concatenate([t2s, t5s])
      t3 = np.concatenate([t3s, t4s])
      ts = (t1, t2, t3)
      for vd in self.vdims:
          zs = self.dimension_values(vd)
          ts = ts + (np.concatenate([zs, zs]),)
  
      # Construct TriMesh
      params = util.get_param_values(self)
      params["kdims"] = params["kdims"] + TriMesh.node_type.kdims[2:]
      nodes = TriMesh.node_type(
          vertices + (np.arange(len(vertices[0])),),
          **{k: v for k, v in params.items() if k != "vdims"},
      )
      return TriMesh(
          ((ts,), nodes),
          **{k: v for k, v in params.items() if k != "kdims"},
      )
  
imports: import colorsys
  from copy import deepcopy
  from operator import itemgetter
  import numpy
  import param
  from ..core import Dataset, Dimension, Element2D, Overlay, config, util
  from ..core.boundingregion import BoundingBox, BoundingRegion
  from ..core.data import ImageInterface
  from ..core.data.interface import DataError
  from ..core.dimension import dimension_name
  from ..core.sheetcoords import SheetCoordinateSystem, Slice
  from .chart import Curve
  from .geom import Selection2DExpr
  from .graphs import TriMesh
  from .tabular import Table
  from .util import categorical_aggregate2d, compute_slice_bounds
label_desc: Use image node_id 2 for calling the QuadMesh obj's underlying member method code with example usage: obj.trimesh() and returns: TriMesh