def test_multi_block_data_range(): volume = pyvista.Wavelet() a = volume.slice_along_axis(5, 'x') with pytest.raises(ValueError): a.get_data_range('foo') mi, ma = a.get_data_range(volume.active_scalars_name) assert mi is not None assert ma is not None # Test on a nested MultiBlock b = volume.slice_along_axis(5, 'y') slices = pyvista.MultiBlock([a, b]) with pytest.raises(ValueError): slices.get_data_range('foo') mi, ma = slices.get_data_range(volume.active_scalars_name) assert mi is not None assert ma is not None
def test_find_closest_cell(): mesh = pyvista.Wavelet() node = np.array([0, 0.2, 0.2]) with pytest.raises(ValueError): mesh.find_closest_cell([1, 2]) with pytest.raises(TypeError): # allow Sequence but not Iterable mesh.find_closest_cell({1, 2, 3}) # array but bad size with pytest.raises(ValueError): mesh.find_closest_cell(np.empty(4)) index = mesh.find_closest_cell(node) assert isinstance(index, int)
def test_wavelet(): mesh = pyvista.Wavelet() assert mesh.n_points assert mesh.n_cells
stitle='Elevation - interpolated', **dargs) p.link_views() p.camera_position = [(-1.67, -5.10, 2.06), (0.0, 0.0, 0.0), (0.00, 0.37, 0.93)] p.show() ############################################################################### # The cylider mesh above is a great example dataset for this as it has a wide # spread between the vertices (points are only at the top and bottom of the # cylinder) which means high surface are of the mesh has to be interpolated. # # However, most meshes don't have such a wide spread and the effects of # color interpolating are harder to notice. Let's take a look at a wavelet # example and try to figure out how the ``interpolate_before_map`` option # affects its rendering. wavelet = pv.Wavelet().clip('x') # Common display argument to make sure all else is constant dargs = dict(scalars='RTData', cmap='rainbow', show_edges=True) p = pv.Plotter(shape=(1, 2)) p.add_mesh(wavelet, interpolate_before_map=False, stitle='RTData - not interpolated', **dargs) p.subplot(0, 1) p.add_mesh(wavelet, interpolate_before_map=True, stitle='RTData - interpolated', **dargs) p.link_views()
A spline widget can be enabled and disabled by the :func:`pyvista.WidgetHelper.add_spline_widget` and :func:`pyvista.WidgetHelper.clear_spline_widgets` methods respectively. This widget allows users to interactively create a poly line (spline) through a scene and use that spline. A common task with splines is to slice a volumetric dataset using an irregular path. To do this, we have added a convenient helper method which leverages the :func:`pyvista.DataSetFilters.slice_along_line` filter named :func:`pyvista.WidgetHelper.add_mesh_slice_spline`. """ import pyvista as pv import numpy as np ############################################################################## mesh = pv.Wavelet() # initial spline to seed the example points = np.array([[-8.64208925, -7.34294559, -9.13803458], [-8.25601497, -2.54814702, 0.93860914], [-0.30179377, -3.21555997, -4.19999019], [3.24099167, 2.05814768, 3.39041509], [4.39935227, 4.18804542, 8.96391132]]) p = pv.Plotter() p.add_mesh(mesh.outline(), color='black') p.add_mesh_slice_spline(mesh, initial_points=points, n_handles=5) p.camera_position = [(30, -42, 30), (0.0, 0.0, 0.0), (-0.09, 0.53, 0.84)] p.show()