#NEWLINE# def get_vtk_src( mayavi_object , stop_at_filter = True ) : #NEWLINE# #INDENT# " Goes up the Mayavi pipeline to find the data sources of a given\n        object.\n\n        **Parameters**\n\n        :object: any Mayavi visualization object\n\n        :stop_at_filter: optional boolean flag: if True, the first object\n                         exposing data found going up the pipeline is\n                         returned. If False, only the source itself\n                         is returned.\n\n        **Returns**\n\n        :sources: List of vtk data sources (vtk data sources, and not\n                  Mayavi source objects).\n\n        **Notes**\n\n        This function traverses the Mayavi pipeline. Thus the input\n        object 'mayavi_object' should already be added to the pipeline.\n    " #NEWLINE# if isinstance ( mayavi_object , tvtk . Object ) : #NEWLINE# #INDENT# if mayavi_object . is_a ( 'vtkDataSet' ) : #NEWLINE# #INDENT# return [ mayavi_object ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( mayavi_object , 'output' ) : #NEWLINE# #INDENT# return [ mayavi_object . output ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not ( hasattr ( mayavi_object , 'parent' ) or isinstance ( mayavi_object , Source ) ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'Cannot find data source for given object %s' % mayavi_object ) ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# if isinstance ( mayavi_object , Source ) : #NEWLINE# #INDENT# if ( stop_at_filter or ( not isinstance ( mayavi_object , Filter ) ) ) : #NEWLINE# #INDENT# get_output = ( lambda x : ( x if x . is_a ( 'vtkDataSet' ) else x . output ) ) #NEWLINE# return [ get_output ( x ) for x in mayavi_object . outputs ] #NEWLINE# #UNINDENT# #UNINDENT# mayavi_object = mayavi_object . parent