def _decimate_surface(points, triangles, reduction):
 if (('DISPLAY' not in os.environ) and (sys.platform != 'win32')):
  os.environ['ETS_TOOLKIT'] = 'null'
 try:
  from tvtk.api import tvtk
  from tvtk.common import configure_input
 except ImportError:
  raise ValueError('This function requires the TVTK package to be installed')
 if (triangles.max() > (len(points) - 1)):
  raise ValueError('The triangles refer to undefined points. Please check your mesh.')
 src = tvtk.PolyData(points=points, polys=triangles)
 decimate = tvtk.QuadricDecimation(target_reduction=reduction)
 configure_input(decimate, src)
 decimate.update()
 out = decimate.output
 tris = out.polys.to_array()
 return (out.points.to_array(), tris.reshape((tris.size / 4), 4)[:, 1:])

def _decimate_surface ( points , triangles , reduction ) : if ( ( 'DISPLAY' not in os . environ ) and ( sys . platform != 'win32' ) ) : os . environ [ 'ETS_TOOLKIT' ] = 'null' try : from tvtk . api import tvtk from tvtk . common import configure_input except ImportError : raise ValueError ( 'This function requires the TVTK package to be installed' ) if ( triangles . max ( ) > ( len ( points ) - 1 ) ) : raise ValueError ( 'The triangles refer to undefined points. Please check your mesh.' ) src = tvtk . PolyData ( points = points , polys = triangles ) decimate = tvtk . QuadricDecimation ( target_reduction = reduction ) configure_input ( decimate , src ) decimate . update ( ) out = decimate . output tris = out . polys . to_array ( ) return ( out . points . to_array ( ) , tris . reshape ( ( tris . size / 4 ) , 4 ) [ : , 1 : ] )
aux function .