Exemplo n.º 1
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        # Read the multi-block plot3d file.
        r = PLOT3DReader()
        r.reader.set(has_byte_count=True, multi_grid=True,
                     byte_order='little_endian')
        r.initialize(get_example_data('tiny.xyz'),
                     get_example_data('tiny.q'),
                     configure=False)
        e.add_source(r)
        # Add the filter.
        f = SelectOutput()
        e.add_filter(f)

        # Create an outline for the data.
        o = Outline()
        e.add_module(o)
        o.render()
        self.o=o
        self.r=r
        self.e=e
        self.scene = e.current_scene
        return
Exemplo n.º 2
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e = e

        # Read the multi-block plot3d file.
        r = PLOT3DReader()
        r.reader.trait_set(has_byte_count=True,
                           multi_grid=True,
                           byte_order='little_endian')
        r.initialize(get_example_data('tiny.xyz'),
                     get_example_data('tiny.q'),
                     configure=False)
        e.add_source(r)
        # Add the filter.
        f = SelectOutput()
        e.add_filter(f)

        # Create an outline for the data.
        o = Outline()
        e.add_module(o)
        o.render()
        self.o = o
        self.r = r
        self.e = e
        self.scene = e.current_scene
        return
    def test_multipe_readers(self):
        "Test if reader conflict is resolved"
        # Testing two files with same extensions but have to be read
        # by different readers
        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PLOT3DReader')

        reader = registry.get_file_reader(get_example_data('thio3xx.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PolyDataReader')
Exemplo n.º 4
0
    def test_multipe_readers(self):
        "Test if reader conflict is resolved"
        # Testing two files with same extensions but have to be read
        # by different readers
        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PLOT3DReader')

        reader = registry.get_file_reader(get_example_data('thio3xx.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PolyDataReader')
    def test_no_valid_reader(self):
        """Test that if there is no reader which can read the file with
        assurity, the registry returns the last one of the readers
        which dont have a can_read_test and claim to read the file with
        the given extension"""
        open_dummy = SourceMetadata(
            id="DummyFile",
            class_name="mayavi.tests.test_registry.DummyReader",
            menu_name="&PLOT3D file",
            tooltip="Open a PLOT3D data data",
            desc="Open a PLOT3D data data",
            help="Open a PLOT3D data data",
            extensions=['xyz'],
            wildcard='PLOT3D files (*.xyz)|*.xyz',
            can_read_test='mayavi.tests.test_registry:DummyReader.check_read',
            output_info=PipelineInfo(datasets=['structured_grid'],
                                     attribute_types=['any'],
                                     attributes=['any']))
        registry.sources.append(open_dummy)

        # Remove the poly data reader.
        for index, src in enumerate(registry.sources[:]):
            if src.id == 'PolyDataFile':
                poly = src
                registry.sources.remove(src)
                break

        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PLOT3DReader')

        # Add back the poly data reader.
        registry.sources.insert(index, poly)
        registry.sources.remove(open_dummy)
Exemplo n.º 6
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        # Read a VTK (old style) data file.
        r = VTKXMLFileReader()
        r.initialize(get_example_data('pyramid_ug.vtu'))
        e.add_source(r)

        # Create the filters.
        # CellDerivatives
        cd = tvtk.CellDerivatives()
        ud = UserDefined(filter=cd)
        e.add_filter(ud)
        ctp = CellToPointData()
        ctp.filter.pass_cell_data = False
        e.add_filter(ctp)
        evn = ExtractVectorNorm()
        e.add_filter(evn)
        evc = ExtractVectorComponents(component='y-component')
        o = Optional(filter=evc)
        e.add_filter(o)
        e.add_module(ScalarCutPlane())
        self.scene = e.current_scene
        s = self.scene
        return
Exemplo n.º 7
0
 def test_volume_works_with_probe(self):
     src = mlab.pipeline.open(get_example_data('pyramid_ug.vtu'))
     idp = mlab.pipeline.image_data_probe(src)
     with patch('pyface.api.error') as m:
         vol = mlab.pipeline.volume(idp)
     self.assertEqual(m.call_count, 0)
     self.assertEqual(np.allclose(vol.volume.center, (3.0, 3.0, 1.5)), True)
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        # Read a VTK (old style) data file.
        r = VTKXMLFileReader()
        r.initialize(get_example_data('pyramid_ug.vtu'))
        e.add_source(r)

        # Create the filters.
        # CellDerivatives
        cd = tvtk.CellDerivatives()
        ud = UserDefined(filter=cd)
        e.add_filter(ud)
        ctp = CellToPointData()
        ctp.filter.pass_cell_data = False
        e.add_filter(ctp)
        evn = ExtractVectorNorm()
        e.add_filter(evn)
        evc = ExtractVectorComponents(component='y-component')
        o = Optional(filter=evc)
        e.add_filter(o)
        e.add_module(ScalarCutPlane())
        self.scene = e.current_scene
        s = self.scene
        return
Exemplo n.º 9
0
    def test_no_valid_reader(self):
        """Test that if there is no reader which can read the file with
        assurity, the registry returns the last one of the readers
        which dont have a can_read_test and claim to read the file with
        the given extension"""
        open_dummy = SourceMetadata(
                id            = "DummyFile",
                class_name    = "mayavi.tests.test_registry.DummyReader",
                menu_name     = "&PLOT3D file",
                tooltip       = "Open a PLOT3D data data",
                desc        = "Open a PLOT3D data data",
                help        = "Open a PLOT3D data data",
                extensions = ['xyz'],
                wildcard = 'PLOT3D files (*.xyz)|*.xyz',
                can_read_test = 'mayavi.tests.test_registry:DummyReader.check_read',
                output_info = PipelineInfo(datasets=['structured_grid'],
                    attribute_types=['any'],
                    attributes=['any'])
                )
        registry.sources.append(open_dummy)

        # Remove the poly data reader.
        for index, src in enumerate(registry.sources[:]):
            if src.id == 'PolyDataFile':
                poly = src
                registry.sources.remove(src)
                break

        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PLOT3DReader')

        # Add back the poly data reader.
        registry.sources.insert(index, poly)
        registry.sources.remove(open_dummy)
Exemplo n.º 10
0
 def test_ipw_works_with_image_data_probe(self):
     src = mlab.pipeline.open(get_example_data('pyramid_ug.vtu'))
     idp = mlab.pipeline.image_data_probe(src)
     with patch('pyface.api.error') as m:
         ipw = mlab.pipeline.image_plane_widget(idp)
     self.assertEqual(m.call_count, 0)
     self.assertEqual(numpy.allclose(ipw.ipw.center, (0.0, 3.0, 1.5)),True)
Exemplo n.º 11
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e = e

        r = VTKXMLFileReader()
        r.initialize(get_example_data('pyramid_ug.vtu'))
        e.add_source(r)
        r.point_scalars_name = 'temperature'
        o = Outline()
        e.add_module(o)
        c = Contour()
        e.add_filter(c)
        n = PolyDataNormals()
        e.add_filter(n)
        aa = SetActiveAttribute()
        e.add_filter(aa)
        aa.point_scalars_name = 'pressure'
        s = Surface()
        e.add_module(s)
        self.scene = e.current_scene
        return
Exemplo n.º 12
0
 def test_test_backend(self):
     """Test if setting the backend to 'test' works."""
     mlab.options.backend = 'test'
     mlab.test_contour3d()
     mlab.clf()
     mlab.pipeline.open(get_example_data('cube.vti'))
     mlab.clf()
 def test_ipw_works_with_image_data_probe(self):
     src = mlab.pipeline.open(get_example_data('pyramid_ug.vtu'))
     idp = mlab.pipeline.image_data_probe(src)
     with patch('pyface.api.error') as m:
         ipw = mlab.pipeline.image_plane_widget(idp)
     self.assertEqual(m.call_count, 0)
     self.assertEqual(numpy.allclose(ipw.ipw.center, (0.0, 3.0, 1.5)),True)
Exemplo n.º 14
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        r = VTKXMLFileReader()
        r.initialize(get_example_data('pyramid_ug.vtu'))
        e.add_source(r)
        r.point_scalars_name = 'temperature'
        o = Outline()
        e.add_module(o)
        c = Contour()
        e.add_filter(c)
        n = PolyDataNormals()
        e.add_filter(n)
        aa = SetActiveAttribute()
        e.add_filter(aa)
        aa.point_scalars_name = 'pressure'
        s = Surface()
        e.add_module(s)
        self.scene = e.current_scene
        return
Exemplo n.º 15
0
 def test_test_backend(self):
     """Test if setting the backend to 'test' works."""
     mlab.options.backend = 'test'
     mlab.test_contour3d()
     mlab.clf()
     mlab.pipeline.open(get_example_data('cube.vti'))
     mlab.clf()
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a Exodus data file.
     r = UnstructuredGridReader()
     r.initialize(get_example_data('disk_out_ref.ex2'))
     self.e.add_source(r)
Exemplo n.º 17
0
 def test_volume_works_with_probe(self):
     src = mlab.pipeline.open(get_example_data('pyramid_ug.vtu'))
     idp = mlab.pipeline.image_data_probe(src)
     with patch('pyface.api.error') as m:
         vol = mlab.pipeline.volume(idp)
     self.assertEqual(m.call_count, 0)
     self.assertEqual(
         np.allclose(vol.volume.center, (3.0, 3.0, 1.5)),True
     )
Exemplo n.º 18
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a OBJ data file.
     r = PolyDataReader()
     r.initialize(get_example_data('shuttle.obj'))
     self.e.add_source(r)
     self.bounds = (-7.65, 7.04, -4.68, 4.68, -1.35, 4.16)
Exemplo n.º 19
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a BYU data file.
     r = PolyDataReader()
     r.initialize(get_example_data('cow.g'))
     self.e.add_source(r)
     self.bounds = (-4.445, 5.998, -3.608, 2.760, -1.690, 1.690)
Exemplo n.º 20
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a SLC data file.
     r = PolyDataReader()
     r.initialize(get_example_data('nut.slc'))
     self.e.add_source(r)
     self.bounds = (0.0, 67.0, 0.0, 40.0, 0.0, 58.0)
Exemplo n.º 21
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a Facet data file.
     r = PolyDataReader()
     r.initialize(get_example_data('clown.facet'))
     self.e.add_source(r)
     self.bounds = (-0.5, 0.69, -0.49, 0.49, -1.09, 0.5)
Exemplo n.º 22
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a PDB data file.
     r = PolyDataReader()
     r.initialize(get_example_data('caffeine.pdb'))
     self.e.add_source(r)
     self.bounds = (3.10, 10.78, -2.39, 4.03, -10.60, -6.31)
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a Gambit data file.
     r = UnstructuredGridReader()
     r.initialize(get_example_data('prism.neu'))
     self.e.add_source(r)
     self.bounds = (-1.0, 1.0, -1.0, 1.0, 0.0, 1.0)
Exemplo n.º 24
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a Exodus data file.
        r = UnstructuredGridReader()
        r.initialize(get_example_data('disk_out_ref.ex2'))
        self.e.add_source(r)
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a AVSUCD data file.
     r = UnstructuredGridReader()
     r.initialize(get_example_data('cellsnd.ascii.inp'))
     self.e.add_source(r)
     self.bounds = (-2.0, 2.0, -2.0, 2.0, 0.0, 0.0)
Exemplo n.º 26
0
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a STL data file.
     r = PolyDataReader()
     r.initialize(get_example_data('humanoid_tri.stla'))
     self.e.add_source(r)
     self.bounds = (0.60, 3.47, -3.96, 3.95, 3.05, 17.39)
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a DEM Image file.
     r = ImageReader()
     r.initialize(get_example_data('example.dem'))
     self.e.add_source(r)
     self.bounds = (557945.0, 567725.0, 5107991.5, 5121971.5, 682.0, 682.0)
 def setup_reader(self):
     """"Setup the reader in here.  This is called after the engine
     has been created and started.  The engine is available as
     self.e.  This method is called by setUp().
     """
     # Read a Meta Image file.
     r = ImageReader()
     r.initialize(get_example_data('foot.mha'))
     self.e.add_source(r)
     self.bounds = (0.0, 255.0, 0.0, 255.0, 0.0, 0.0)
Exemplo n.º 29
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a PDB data file.
        r = PolyDataReader()
        r.initialize(get_example_data('caffeine.pdb'))
        self.e.add_source(r)
        self.bounds = (3.10, 10.78, -2.39, 4.03, -10.60, -6.31)
Exemplo n.º 30
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a STL data file.
        r = PolyDataReader()
        r.initialize(get_example_data('humanoid_tri.stla'))
        self.e.add_source(r)
        self.bounds =  (0.60, 3.47, -3.96, 3.95, 3.05, 17.39)
Exemplo n.º 31
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a Facet data file.
        r = PolyDataReader()
        r.initialize(get_example_data('clown.facet'))
        self.e.add_source(r)
        self.bounds = (-0.5, 0.69, -0.49, 0.49, -1.09, 0.5)
Exemplo n.º 32
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a SLC data file.
        r = PolyDataReader()
        r.initialize(get_example_data('nut.slc'))
        self.e.add_source(r)
        self.bounds =  (0.0, 67.0, 0.0, 40.0, 0.0, 58.0)
Exemplo n.º 33
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a BYU data file.
        r = PolyDataReader()
        r.initialize(get_example_data('cow.g'))
        self.e.add_source(r)
        self.bounds = (-4.445, 5.998, -3.608, 2.760, -1.690, 1.690)
Exemplo n.º 34
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
         # Read a Meta Image file.
        r = ImageReader()
        r.initialize(get_example_data('foot.mha'))
        self.e.add_source(r)
        self.bounds =(0.0, 255.0, 0.0, 255.0, 0.0, 0.0)
Exemplo n.º 35
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
         # Read a DEM Image file.
        r = ImageReader()
        r.initialize(get_example_data('example.dem'))
        self.e.add_source(r)
        self.bounds =(557945.0, 567725.0, 5107991.5, 5121971.5, 682.0, 682.0)
Exemplo n.º 36
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a AVSUCD data file.
        r = UnstructuredGridReader()
        r.initialize(get_example_data('cellsnd.ascii.inp'))
        self.e.add_source(r)
        self.bounds =(-2.0, 2.0, -2.0, 2.0, 0.0, 0.0)
Exemplo n.º 37
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a OBJ data file.
        r = PolyDataReader()
        r.initialize(get_example_data('shuttle.obj'))
        self.e.add_source(r)
        self.bounds = (-7.65, 7.04, -4.68, 4.68, -1.35, 4.16)
Exemplo n.º 38
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a Gambit data file.
        r = UnstructuredGridReader()
        r.initialize(get_example_data('prism.neu'))
        self.e.add_source(r)
        self.bounds = (-1.0, 1.0, -1.0, 1.0, 0.0, 1.0)
    def test_slice_unstructured_grid(self):
        # Given
        src = mlab.pipeline.open(get_example_data('uGridEx.vtk'))
        eg = mlab.pipeline.extract_unstructured_grid(src)
        eg.filter.trait_set(cell_clipping=True, cell_maximum=2)

        # When
        sug = mlab.pipeline.slice_unstructured_grid(eg)

        # Then
        assert_allclose(sug.actor.actor.bounds, (1.0, 2.0, 0.0, 1.0, 0.0, 1.0))
Exemplo n.º 40
0
    def setup_reader(self):

        """"Setup the reader in here.  This is called after the engine
        has been created and started.  The engine is available as
        self.e.  This method is called by setUp().
        """
        # Read a Particle data file.
        r = PolyDataReader()
        r.initialize(get_example_data('Particles.raw'))
        self.e.add_source(r)
        r.reader.set(data_byte_order='big_endian', data_type='float', file_type='binary')
        self.bounds = (817.33, 826.09, 545.02, 571.02, 1443.48, 1511.18)
Exemplo n.º 41
0
    def test_multiple_valid_readers(self):
        """Test if the fixture works fine if there are multiple readers
        capable of reading the file properly"""
        # Inserting a dummy reader into the registry also capable of
        # reading files with extension 'xyz'
        open_dummy = SourceMetadata(
                id            = "DummyFile",
                class_name    = "mayavi.tests.test_registry.DummyReader",
                menu_name     = "&PLOT3D file",
                tooltip       = "Open a PLOT3D data data",
                desc        = "Open a PLOT3D data data",
                help        = "Open a PLOT3D data data",
                extensions = ['xyz'],
                wildcard = 'PLOT3D files (*.xyz)|*.xyz',
                can_read_test = 'mayavi.tests.test_registry:DummyReader.check_read',
                output_info = PipelineInfo(datasets=['structured_grid'],
                    attribute_types=['any'],
                    attributes=['any'])
                )
        registry.sources.append(open_dummy)
        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'PLOT3DReader')

        # Removing existing readers for .xyz extensions to check if the Dummy
        # reader now reads it.
        remove = []
        for index, src in enumerate(registry.sources[:]):
            if 'xyz' in src.extensions and src.id != 'DummyFile':
                remove.append((index, src))
                registry.sources.remove(src)

        reader = registry.get_file_reader(get_example_data('tiny.xyz'))
        callable = reader.get_callable()
        self.assertEqual(callable.__name__, 'DummyReader')

        for index, src in remove:
            registry.sources.insert(index, src)
        registry.sources.remove(open_dummy)
Exemplo n.º 42
0
def make_mb_dataset():
    fpath = get_example_data('pyramid_ug.vtu')
    r = tvtk.XMLUnstructuredGridReader(file_name=fpath)
    r.update()
    ug0 = r.output
    ug1 = tvtk.UnstructuredGrid()
    ug1.deep_copy(ug0)
    pts = ug1.points.to_array()
    pts[:, 0] += 10.0
    ug1.points = pts
    mb = tvtk.MultiBlockDataSet()
    mb.set_block(0, ug0)
    mb.set_block(1, ug1)
    return mb
Exemplo n.º 43
0
    def test_slice_unstructured_grid(self):
        v = tvtk.Version()
        if v.vtk_major_version < 6 and v.vtk_minor_version < 10:
            raise unittest.SkipTest('Broken on Travis with VTK-5.8?')
        # Given
        src = mlab.pipeline.open(get_example_data('uGridEx.vtk'))
        eg = mlab.pipeline.extract_unstructured_grid(src)
        eg.filter.set(cell_clipping=True, cell_maximum=2)

        # When
        sug = mlab.pipeline.slice_unstructured_grid(eg)

        # Then
        assert_allclose(sug.actor.actor.bounds, (1.0, 2.0, 0.0, 1.0, 0.0, 1.0))
def make_mb_dataset():
    fpath = get_example_data('pyramid_ug.vtu')
    r = tvtk.XMLUnstructuredGridReader(file_name=fpath)
    r.update()
    ug0 = r.output
    ug1 = tvtk.UnstructuredGrid()
    ug1.deep_copy(ug0)
    pts = ug1.points.to_array()
    pts[:, 0] += 10.0
    ug1.points = pts
    mb = tvtk.MultiBlockDataSet()
    mb.set_block(0, ug0)
    mb.set_block(1, ug1)
    return mb
Exemplo n.º 45
0
 def test_test_backend_clf(self):
     """Test if setting the backend to 'test' works."""
     mlab.options.backend = 'test'
     mlab.test_contour3d()
     e = mlab.get_engine()
     self.assertEqual(len(e.scenes), 1)
     self.assertEqual(len(e.scenes[0].children), 1)
     mlab.clf()
     self.assertEqual(len(e.scenes), 1)
     self.assertEqual(len(e.scenes[0].children), 0)
     mlab.pipeline.open(get_example_data('cube.vti'))
     mlab.clf()
     self.assertEqual(len(e.scenes), 1)
     self.assertEqual(len(e.scenes[0].children), 0)
Exemplo n.º 46
0
    def test_slice_unstructured_grid(self):
        v = tvtk.Version()
        if v.vtk_major_version < 6 and v.vtk_minor_version < 10:
            raise unittest.SkipTest('Broken on Travis with VTK-5.8?')
        # Given
        src = mlab.pipeline.open(get_example_data('uGridEx.vtk'))
        eg = mlab.pipeline.extract_unstructured_grid(src)
        eg.filter.trait_set(cell_clipping=True, cell_maximum=2)

        # When
        sug = mlab.pipeline.slice_unstructured_grid(eg)

        # Then
        assert_allclose(sug.actor.actor.bounds, (1.0, 2.0, 0.0, 1.0, 0.0, 1.0))
    def setUp(self):

        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        # e = Engine()
        e.start()
        e.new_scene()
        self.e = e

        # Read a VTK XML data file.
        r = VTKXMLFileReader()
        r.initialize(get_example_data("cube.vti"))
        e.add_source(r)

        # Create an outline for the data.
        o = Outline()
        e.add_module(o)

        # Create one ContourGridPlane normal to the 'x' axis.
        cgp1 = ContourGridPlane()
        e.add_module(cgp1)
        # Set the position to the middle of the data.
        cgp1.grid_plane.position = 1

        # Another with filled contours normal to 'y' axis.
        cgp2 = ContourGridPlane()
        cgp2.contour.filled_contours = True
        # Set the axis and position to the middle of the data.
        cgp2.grid_plane.axis = "y"
        cgp2.grid_plane.position = 1
        e.add_module(cgp2)

        # An interactive scalar cut plane.
        cp = ScalarCutPlane()
        e.add_module(cp)
        ip = cp.implicit_plane
        ip.normal = 0, 0, 1
        ip.origin = 0.5, 0.5, 1.0
        # Since this is running offscreen this seems necessary.
        ip.widget.origin = 0.5, 0.5, 1.0
        ip.widget.enabled = False
        self.scene = e.current_scene
        self.cgp2 = cgp2
        self.cp = cp
        return
    def setUp(self):

        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        # Read a VTK XML data file.
        r = VTKXMLFileReader()
        r.initialize(get_example_data('cube.vti'))
        e.add_source(r)

        # Create an outline for the data.
        o = Outline()
        e.add_module(o)

        # Create one ContourGridPlane normal to the 'x' axis.
        cgp1 = ContourGridPlane()
        e.add_module(cgp1)
        # Set the position to the middle of the data.
        cgp1.grid_plane.position = 1

        # Another with filled contours normal to 'y' axis.
        cgp2 = ContourGridPlane()
        cgp2.contour.filled_contours = True
        # Set the axis and position to the middle of the data.
        cgp2.grid_plane.axis = 'y'
        cgp2.grid_plane.position = 1
        e.add_module(cgp2)

        # An interactive scalar cut plane.
        cp = ScalarCutPlane()
        e.add_module(cp)
        ip = cp.implicit_plane
        ip.normal = 0,0,1
        ip.origin = 0.5, 0.5, 1.0
        # Since this is running offscreen this seems necessary.
        ip.widget.origin = 0.5, 0.5, 1.0
        ip.widget.enabled = False
        self.scene = e.current_scene
        self.cgp2=cgp2
        self.cp=cp
        return
Exemplo n.º 49
0
    def setUp(self):

        self.root = tempfile.mkdtemp()
        abc1 = os.path.join(self.root, "abc_1.vti")
        abc2 = os.path.join(self.root, "abc_2.vti")
        def1 = os.path.join(self.root, "def_1.vti")
        def2 = os.path.join(self.root, "def_2.vti")
        xyz1 = os.path.join(self.root, "xyz_1.vti")
        cube = get_example_data("cube.vti")
        self.abc1, self.abc2 = abc1, abc2
        self.def1, self.def2 = def1, def2
        self.xyz1 = xyz1
        self.cube = cube
        for i in (abc1, abc2, def1, def2, xyz1):
            shutil.copy(cube, i)

        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        # e = Engine()
        e.start()
        e.new_scene()
        self.engine = e
    def setUp(self):

        self.root = tempfile.mkdtemp()
        abc1 = os.path.join(self.root, 'abc_1.vti')
        abc2 = os.path.join(self.root, 'abc_2.vti')
        def1 = os.path.join(self.root, 'def_1.vti')
        def2 = os.path.join(self.root, 'def_2.vti')
        xyz1 = os.path.join(self.root, 'xyz_1.vti')
        cube = get_example_data('cube.vti')
        self.abc1, self.abc2 = abc1, abc2
        self.def1, self.def2 = def1, def2
        self.xyz1 = xyz1
        self.cube = cube
        for i in (abc1, abc2, def1, def2, xyz1):
            shutil.copy(cube, i)

        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.engine = e
Exemplo n.º 51
0
    def setUp(self):
        """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        e.new_scene()
        self.e=e

        # Read a VTK (old style) data file.
        r = VTKXMLFileReader()
        r.initialize(get_example_data('pyramid_ug.vtu'))
        e.add_source(r)

        # Create the filters.
        idp = ImageDataProbe()
        idp.rescale_scalars = True
        e.add_filter(idp)
        cgp = ContourGridPlane(enable_contours=False)
        e.add_module(cgp)
        cgp.grid_plane.axis = 'z'
        cgp.grid_plane.position = 1
        self.scene = e.current_scene
        return
Exemplo n.º 52
0
 def test_unique_reader(self):
     "Check if a file with a unique reader in Mayavi2 can be read"
     e = self.e
     reader = e.open(get_example_data('prism.neu'))
     self.assertNotEqual(reader, None)
 def test_field_file(self):
     self.src.initialize(get_example_data('fieldfile.vtk'))
     self.check(18, 3)
 def test_unstructured_grid_file(self):
     self.src.initialize(get_example_data('uGridEx.vtk'))
     self.check(27, 12)
Exemplo n.º 55
0
 def test_field_file(self):
     self.src.initialize(get_example_data('fieldfile.vtk'))
     self.check(18, 3)
Exemplo n.º 56
0
 def test_unstructured_grid_file(self):
     self.src.initialize(get_example_data('uGridEx.vtk'))
     self.check(27, 12)
Exemplo n.º 57
0
 def test_structured_grid_file(self):
     self.src.initialize(get_example_data('SampleStructGrid.vtk'))
     self.check(24000, 21489)