<s> """<STR_LIT>""" <EOL> from os . path import abspath <EOL> from io import BytesIO <EOL> import copy <EOL> import numpy <EOL> from common import TestCase , get_example_data <EOL> class TestContour ( TestCase ) : <EOL> def check ( self ) : <EOL> """<STR_LIT>""" <EOL> script = self . script <EOL> e = script . engine <EOL> scene = e . current_scene <EOL> src = scene . children [ <NUM_LIT:0> ] <EOL> mm = src . children [ <NUM_LIT:0> ] <EOL> cgp1 = mm . children [ <NUM_LIT:1> ] <EOL> assert cgp1 . grid_plane . position == <NUM_LIT:15> <EOL> cgp2 = mm . children [ <NUM_LIT:2> ] <EOL> assert cgp2 . contour . filled_contours == True <EOL> assert cgp2 . grid_plane . axis == '<STR_LIT:y>' <EOL> assert cgp2 . grid_plane . position == <NUM_LIT:15> <EOL> iso = mm . children [ <NUM_LIT:3> ] <EOL> ctr = iso . contour . contours <EOL> assert iso . compute_normals == True <EOL> assert ctr == [ <NUM_LIT> ] <EOL> rng = iso . actor . mapper . input . point_data . scalars . range <EOL> assert rng [ <NUM_LIT:0> ] == <NUM_LIT> <EOL> assert rng [ <NUM_LIT:1> ] == <NUM_LIT> <EOL> cp = mm . children [ <NUM_LIT:4> ] <EOL> ip = cp . implicit_plane <EOL> assert abs ( numpy . sum ( ip . normal - ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) ) < <NUM_LIT> <EOL> assert abs ( numpy . sum ( ip . origin - ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> ) ) ) < <NUM_LIT> <EOL> assert ip . widget . enabled == False <EOL> def test ( self ) : <EOL> self . main ( ) <EOL> def do ( self ) : <EOL> script = self . script <EOL> from mayavi . sources . vtk_file_reader import VTKFileReader <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . iso_surface import IsoSurface <EOL> from mayavi . modules . contour_grid_plane import ContourGridPlane <EOL> from mayavi . modules . scalar_cut_plane import ScalarCutPlane <EOL> s = self . new_scene ( ) <EOL> r = VTKFileReader ( ) <EOL> r . initialize ( get_example_data ( '<STR_LIT>' ) ) <EOL> script . add_source ( r ) <EOL> o = Outline ( ) <EOL> script . add_module ( o ) <EOL> cgp1 = ContourGridPlane ( ) <EOL> script . add_module ( cgp1 ) <EOL> cgp1 . grid_plane . position = <NUM_LIT:15> <EOL> cgp2 = ContourGridPlane ( ) <EOL> cgp2 . contour . filled_contours = True <EOL> cgp2 . grid_plane . axis = '<STR_LIT:y>' <EOL> cgp2 . grid_plane . position = <NUM_LIT:15> <EOL> script . add_module ( cgp2 ) <EOL> iso = IsoSurface ( compute_normals = True ) <EOL> script . add_module ( iso ) <EOL> iso . contour . contours = [ <NUM_LIT> ] <EOL> cp = ScalarCutPlane ( ) <EOL> script . add_module ( cp ) <EOL> ip = cp . implicit_plane <EOL> ip . normal = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> <EOL> ip . origin = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> <EOL> ip . widget . enabled = False <EOL> s . scene . isometric_view ( ) <EOL> self . check ( ) <EOL> ctr = cgp2 . contour <EOL> cgp2 . contour = ctr . __class__ ( ) <EOL> cgp2 . contour = ctr <EOL> cgp2 . actor = cgp2 . actor . __class__ ( ) <EOL> iso . contour = iso . contour . __class__ ( ) <EOL> iso . contour . contours = [ <NUM_LIT> ] <EOL> iso . actor = iso . actor . __class__ ( ) <EOL> iso . normals = iso . normals . __class__ ( ) <EOL> ip = cp . implicit_plane <EOL> cp . implicit_plane = cp . implicit_plane . __class__ ( ) <EOL> cp . implicit_plane = ip <EOL> ip . widget . enabled = False <EOL> cp . contour = cp . contour . __class__ ( ) <EOL> cp . cutter = cp . cutter . __class__ ( ) <EOL> cp . actor = cp . actor . __class__ ( ) <EOL> s . render ( ) <EOL> self . check ( ) <EOL> f = BytesIO ( ) <EOL> f . name = abspath ( '<STR_LIT>' ) <EOL> script . save_visualization ( f ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> engine = script . engine <EOL> engine . close_scene ( s ) <EOL> script . load_visualization ( f ) <EOL> s = engine . current_scene <EOL> self . check ( ) <EOL> source = s . children . pop ( ) <EOL> s . children . append ( source ) <EOL> cp = source . children [ <NUM_LIT:0> ] . children [ - <NUM_LIT:1> ] <EOL> cp . implicit_plane . widget . enabled = False <EOL> self . check ( ) <EOL> source1 = copy . deepcopy ( source ) <EOL> s . children [ <NUM_LIT:0> ] = source1 <EOL> cp = source1 . children [ <NUM_LIT:0> ] . children [ - <NUM_LIT:1> ] <EOL> cp . implicit_plane . widget . enabled = False <EOL> self . check ( ) <EOL> def do_profile ( self ) : <EOL> script = self . script <EOL> from mayavi . sources . vtk_file_reader import VTKFileReader <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . iso_surface import IsoSurface <EOL> from mayavi . modules . contour_grid_plane import ContourGridPlane <EOL> from mayavi . modules . scalar_cut_plane import ScalarCutPlane <EOL> s = self . new_scene ( ) <EOL> r = VTKFileReader ( ) <EOL> r . initialize ( get_example_data ( '<STR_LIT>' ) ) <EOL> script . add_source ( r ) <EOL> o = Outline ( ) <EOL> script . add_module ( o ) <EOL> cgp1 = ContourGridPlane ( ) <EOL> script . add_module ( cgp1 ) <EOL> cgp1 . grid_plane . position = <NUM_LIT:15> <EOL> cgp2 = ContourGridPlane ( ) <EOL> cgp2 . contour . filled_contours = True <EOL> cgp2 . grid_plane . axis = '<STR_LIT:y>' <EOL> cgp2 . grid_plane . position = <NUM_LIT:15> <EOL> script . add_module ( cgp2 ) <EOL> iso = IsoSurface ( compute_normals = True ) <EOL> script . add_module ( iso ) <EOL> iso . contour . contours = [ <NUM_LIT> ] <EOL> cp = ScalarCutPlane ( ) <EOL> script . add_module ( cp ) <EOL> ip = cp . implicit_plane <EOL> ip . normal = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> <EOL> ip . origin = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> <EOL> ip . widget . enabled = False <EOL> s . scene . isometric_view ( ) <EOL> s . render ( ) <EOL> engine = script . engine <EOL> engine . close_scene ( s ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> t = TestContour ( ) <EOL> t . test ( ) </s>
