#NEWLINE# def do( self ) : #NEWLINE# #INDENT# script = self . script #NEWLINE# from mayavi.sources.vtk_file_reader import VTKFileReader #NEWLINE# from mayavi.filters.contour import Contour #NEWLINE# from mayavi.filters.optional import Optional #NEWLINE# from mayavi.filters.collection import Collection #NEWLINE# from mayavi.filters.api import PolyDataNormals #NEWLINE# from mayavi.modules.api import Surface #NEWLINE# s = self . new_scene ( ) #NEWLINE# r = VTKFileReader ( ) #NEWLINE# r . initialize ( get_example_data ( 'heart.vtk' ) ) #NEWLINE# script . add_source ( r ) #NEWLINE# c = Contour ( ) #NEWLINE# n = PolyDataNormals ( name = 'Normals' ) #NEWLINE# o = Optional ( filter = n , label_text = 'Compute normals' ) #NEWLINE# coll = Collection ( filters = [ c , o ] , name = 'IsoSurface' ) #NEWLINE# script . add_filter ( coll ) #NEWLINE# s = Surface ( ) #NEWLINE# script . add_module ( s ) #NEWLINE# def check( coll ) : #NEWLINE# #INDENT# 'Check if test status is OK given the collection.' #NEWLINE# ( c , o ) = coll . filters #NEWLINE# c = c . filter #NEWLINE# n = o . filter #NEWLINE# assert ( coll . get_output_dataset ( ) . point_data . scalars . range == ( 127.5 , 127.5 ) ) #NEWLINE# c . contours . append ( 200 ) #NEWLINE# assert ( coll . get_output_dataset ( ) . point_data . scalars . range == ( 127.5 , 200.0 ) ) #NEWLINE# assert ( coll . get_output_dataset ( ) is n . get_output_dataset ( ) ) #NEWLINE# o . enabled = False #NEWLINE# assert ( 'disabled' in o . name ) #NEWLINE# assert ( coll . get_output_dataset ( ) is c . get_output_dataset ( ) ) #NEWLINE# c . contours . pop ( ) #NEWLINE# o . enabled = True #NEWLINE# assert ( coll . get_output_dataset ( ) . point_data . scalars . range == ( 127.5 , 127.5 ) ) #NEWLINE# assert ( coll . get_output_dataset ( ) is n . get_output_dataset ( ) ) #NEWLINE# assert ( 'disabled' not in o . name ) #NEWLINE# #UNINDENT# check ( coll ) #NEWLINE# f = BytesIO ( ) #NEWLINE# f . name = abspath ( 'test.mv2' ) #NEWLINE# script . save_visualization ( f ) #NEWLINE# f . seek ( 0 ) #NEWLINE# engine = script . engine #NEWLINE# engine . close_scene ( s ) #NEWLINE# script . load_visualization ( f ) #NEWLINE# s = engine . current_scene #NEWLINE# coll = s . children [ 0 ] . children [ 0 ] #NEWLINE# check ( coll ) #NEWLINE# source = s . children . pop ( ) #NEWLINE# s . children . append ( check ) #NEWLINE# coll = s . children [ 0 ] . children [ 0 ] #NEWLINE# check ( coll ) #NEWLINE# source1 = copy . deepcopy ( source ) #NEWLINE# s . children [ 0 ] = source1 #NEWLINE# coll = s . children [ 0 ] . children [ 0 ] #NEWLINE# check ( coll )