def test_multi_renderers(): plotter = pyvista.Plotter(shape=(2, 2), off_screen=OFF_SCREEN) loc = (0, 0) plotter.add_text('Render Window 0', loc=loc, font_size=30) sphere = pyvista.Sphere() plotter.add_mesh(sphere, loc=loc, scalars=sphere.points[:, 2]) plotter.add_scalar_bar('Z', vertical=True) loc = (0, 1) plotter.add_text('Render Window 1', loc=loc, font_size=30) plotter.add_mesh(pyvista.Cube(), loc=loc, show_edges=True) loc = (1, 0) plotter.add_text('Render Window 2', loc=loc, font_size=30) plotter.add_mesh(pyvista.Arrow(), color='y', loc=loc, show_edges=True) plotter.subplot(1, 1) plotter.add_text('Render Window 3', loc=loc, font_size=30) plotter.add_mesh(pyvista.Cone(), color='g', loc=loc, show_edges=True, backface_culling=True) plotter.add_bounding_box(render_lines_as_tubes=True, line_width=5) plotter.show_bounds(all_edges=True) plotter.update_bounds_axes() plotter.show()
def test_multiplotter(qtbot, plotting): mp = MultiPlotter( nrows=1, ncols=2, window_size=(300, 300), show=False, title='Test', off_screen=False, ) qtbot.addWidget(mp._window) mp[0, 0].add_mesh(pyvista.Cone()) mp[0, 1].add_mesh(pyvista.Box()) assert not mp._window.isVisible() with qtbot.wait_exposed(mp._window): mp.show() assert mp._window.isVisible() for p in mp._plotters: assert not p._closed with qtbot.wait_signals([mp._window.signal_close], timeout=1000): mp.close() for p in mp._plotters: assert p._closed # cover default show=True mp = MultiPlotter(off_screen=False, menu_bar=False, toolbar=False) qtbot.addWidget(mp._window) with qtbot.wait_exposed(mp._window): assert mp._window.isVisible() mp.close()
def test_multi_renderers(): plotter = pyvista.Plotter(shape=(2, 2)) plotter.subplot(0, 0) plotter.add_text('Render Window 0', font_size=30) sphere = pyvista.Sphere() plotter.add_mesh(sphere, scalars=sphere.points[:, 2]) plotter.add_scalar_bar('Z', vertical=True) plotter.subplot(0, 1) plotter.add_text('Render Window 1', font_size=30) plotter.add_mesh(pyvista.Cube(), show_edges=True) plotter.subplot(1, 0) plotter.add_text('Render Window 2', font_size=30) plotter.add_mesh(pyvista.Arrow(), color='y', show_edges=True) plotter.subplot(1, 1) plotter.add_text('Render Window 3', position=(0., 0.), font_size=30, viewport=True) plotter.add_mesh(pyvista.Cone(), color='g', show_edges=True, culling=True) plotter.add_bounding_box(render_lines_as_tubes=True, line_width=5) plotter.show_bounds(all_edges=True) plotter.update_bounds_axes() plotter.show(before_close_callback=verify_cache_image)
def test_subplot_groups(): plotter = pyvista.Plotter(shape=(3, 3), groups=[(1, [1, 2]), (np.s_[:], 0)]) plotter.subplot(0, 0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(0, 1) plotter.add_mesh(pyvista.Cube()) plotter.subplot(0, 2) plotter.add_mesh(pyvista.Arrow()) plotter.subplot(1, 1) plotter.add_mesh(pyvista.Cylinder()) plotter.subplot(2, 1) plotter.add_mesh(pyvista.Cone()) plotter.subplot(2, 2) plotter.add_mesh(pyvista.Box()) # Test group overlap with pytest.raises(AssertionError): # Partial overlap pyvista.Plotter(shape=(3, 3), groups=[([1, 2], [0, 1]), ([0, 1], [1, 2])]) with pytest.raises(AssertionError): # Full overlap (inner) pyvista.Plotter(shape=(4, 4), groups=[(np.s_[:], np.s_[:]), ([1, 2], [1, 2])]) with pytest.raises(AssertionError): # Full overlap (outer) pyvista.Plotter(shape=(4, 4), groups=[(1, [1, 2]), ([0, 3], np.s_[:])])
def _create_testing_scene(empty_scene, show=False, off_screen=False): if empty_scene: plotter = pyvista.BackgroundPlotter(show=show, off_screen=off_screen) else: plotter = pyvista.BackgroundPlotter(shape=(2, 2), border=True, border_width=10, border_color='grey', show=show, off_screen=off_screen) plotter.set_background('black', top='blue') plotter.subplot(0, 0) cone = pyvista.Cone(resolution=4) actor = plotter.add_mesh(cone) plotter.remove_actor(actor) plotter.add_text('Actor is removed') plotter.subplot(0, 1) plotter.add_mesh(pyvista.Box(), color='green', opacity=0.8) plotter.subplot(1, 0) cylinder = pyvista.Cylinder(resolution=6) plotter.add_mesh(cylinder, smooth_shading=True) plotter.show_bounds() plotter.subplot(1, 1) sphere = pyvista.Sphere(phi_resolution=6, theta_resolution=6) plotter.add_mesh(sphere) plotter.enable_cell_picking() return plotter
def test_implicit_distance(): surface = pyvista.Cone(direction=(0,0,-1), height=3.0, radius=1, resolution=50, ) xx = yy = zz = 1 - np.linspace(0, 51, 11) * 2 / 50 dataset = pyvista.RectilinearGrid(xx, yy, zz) res = dataset.compute_implicit_distance(surface) assert "implicit_distance" in res.point_arrays dataset.compute_implicit_distance(surface, inplace=True) assert "implicit_distance" in dataset.point_arrays
def test_clip_surface(): surface = pyvista.Cone(direction=(0,0,-1), height=3.0, radius=1, resolution=50, ) xx = yy = zz = 1 - np.linspace(0, 51, 51) * 2 / 50 dataset = pyvista.RectilinearGrid(xx, yy, zz) clipped = dataset.clip_surface(surface, invert=False) assert clipped.n_points < dataset.n_points clipped = dataset.clip_surface(surface, invert=False, compute_distance=True) assert clipped.n_points < dataset.n_points assert 'implicit_distance' in clipped.array_names
def test_multi_renderers(): plotter = pyvista.Plotter(shape=(2, 2), off_screen=OFF_SCREEN) loc = (0, 0) plotter.add_text('Render Window 0', loc=loc, font_size=30) sphere = pyvista.Sphere() plotter.add_mesh(sphere, loc=loc, scalars=sphere.points[:, 2]) plotter.add_scalar_bar('Z', vertical=True) loc = (0, 1) plotter.add_text('Render Window 1', loc=loc, font_size=30) plotter.add_mesh(pyvista.Cube(), loc=loc, show_edges=True) loc = (1, 0) plotter.add_text('Render Window 2', loc=loc, font_size=30) plotter.add_mesh(pyvista.Arrow(), color='y', loc=loc, show_edges=True) plotter.subplot(1, 1) plotter.add_text('Render Window 3', loc=loc, font_size=30) plotter.add_mesh(pyvista.Cone(), color='g', loc=loc, show_edges=True, backface_culling=True) plotter.add_bounding_box(render_lines_as_tubes=True, line_width=5) plotter.show_bounds(all_edges=True) plotter.update_bounds_axes() plotter.show() # Test subplot indices (2 rows by 1 column) plotter = pyvista.Plotter(shape=(2, 1), off_screen=OFF_SCREEN) # First row plotter.subplot(0,0) plotter.add_mesh(pyvista.Sphere()) # Second row plotter.subplot(1,0) plotter.add_mesh(pyvista.Cube()) plotter.show() # Test subplot indices (1 row by 2 columns) plotter = pyvista.Plotter(shape=(1, 2), off_screen=OFF_SCREEN) # First column plotter.subplot(0,0) plotter.add_mesh(pyvista.Sphere()) # Second column plotter.subplot(0,1) plotter.add_mesh(pyvista.Cube()) plotter.show() with pytest.raises(IndexError): # Test bad indices plotter = pyvista.Plotter(shape=(1, 2), off_screen=OFF_SCREEN) plotter.subplot(0,0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(1,0) plotter.add_mesh(pyvista.Cube()) plotter.show()
def test_clip_surface(): surface = pyvista.Cone( direction=(0, 0, -1), height=3.0, radius=1, resolution=50, ) xx = yy = zz = 1 - np.linspace(0, 51, 51) * 2 / 50 dataset = pyvista.RectilinearGrid(xx, yy, zz) clipped = dataset.clip_surface(surface, invert=False) assert clipped.n_points < dataset.n_points
def next_cubes(self): ''' create cubes within the mesh from the face centers of the first cube''' hi = 12 ang = np.arctan(1/(np.sqrt(2)/2)) ang = float(90 - np.degrees(ang)) create_cone = pv.Cone(center=face_center[0] + [0,0,hi/2], direction = [0.0,0.0,-1.0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone2 = pv.Cone(center=face_center[1] + [0,0,hi/2], direction = [-1.0,-1.0,0.0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone5 = pv.Cone(center=face_center[5] + [0,0,-hi/2], direction = [0,0,1], height = hi, radius=None, resolution= 100, angle = ang, capping=False) clipped = mesh.clip_surface(create_cone, invert=True) clipped5 = mesh.clip_surface(create_cone5, invert=True) cone_intersection5 = np.array(clipped5.points) #nearest_cone = min(cone_intersection5) print("Bottom Intersection:",cone_intersection5) #cone_center = create_cone.cell_centers() #cone_center_points = np.array(cone_center.points) self.plotter.add_mesh(create_cone, color="y", opacity=0.6) self.plotter.add_mesh(clipped, show_edges=True, color="r", opacity=0.6) self.plotter.add_mesh(create_cone2, show_edges=True, color="y", opacity=0.6) self.plotter.add_mesh(create_cone5, show_edges=True, color="y", opacity=0.6) self.plotter.add_mesh(clipped5, show_edges=True, color="r", opacity=0.6)
def test_clip_surface(): surface = pyvista.Cone(direction=(0,0,-1), height=3.0, radius=1, resolution=50, ) xx = yy = zz = 1 - np.linspace(0, 51, 11) * 2 / 50 dataset = pyvista.RectilinearGrid(xx, yy, zz) clipped = dataset.clip_surface(surface, invert=False) assert isinstance(clipped, pyvista.UnstructuredGrid) clipped = dataset.clip_surface(surface, invert=False, compute_distance=True) assert isinstance(clipped, pyvista.UnstructuredGrid) assert 'implicit_distance' in clipped.array_names clipped = dataset.clip_surface(surface.cast_to_unstructured_grid(),) assert isinstance(clipped, pyvista.UnstructuredGrid) assert 'implicit_distance' in clipped.array_names
def test_multi_renderers_subplot_ind_1x3(): # Test subplot 3 on bottom, 1 on top plotter = pyvista.Plotter(shape='1|3') # First column plotter.subplot(0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(1) plotter.add_mesh(pyvista.Cube()) plotter.subplot(2) plotter.add_mesh(pyvista.Cylinder()) plotter.subplot(3) plotter.add_mesh(pyvista.Cone()) plotter.show(before_close_callback=verify_cache_image)
def test_where_is(): plotter = pyvista.Plotter(shape=(2, 2)) plotter.subplot(0, 0) plotter.add_mesh(pyvista.Box(), name='box') plotter.subplot(0, 1) plotter.add_mesh(pyvista.Sphere(), name='sphere') plotter.subplot(1, 0) plotter.add_mesh(pyvista.Box(), name='box') plotter.subplot(1, 1) plotter.add_mesh(pyvista.Cone(), name='cone') places = plotter.where_is('box') assert isinstance(places, list) for loc in places: assert isinstance(loc, tuple)
def max_cube(self): """ add a maximally inscribed cube within the opened mesh """ global max_c1, max_c2 # reset plotter self.reset_plotter() # project cones to from centroid to find maximally inscribed cube ranges = mesh.bounds h = (abs(ranges[4]) + abs(ranges[5]))/3 ang = np.arctan(0.5/(np.sqrt(2)/2)) ang = float(90 - np.degrees(ang)) max_c1 = pv.Cone(center=Vol_centroid+[0,0,h/2], direction=[0.0, 0.0, -1.0], height=h, radius=None, capping=False, angle=ang, resolution=100) max_c2 = pv.Cone(center=Vol_centroid-[0,0,h/2], direction=[0.0, 0.0, 1.0], height=h, radius=None, capping=False, angle=ang, resolution=100) #self.plotter.add_mesh(max_c1,color="r", opacity=0.2) #self.plotter.add_mesh(max_c2,color="r", opacity=0.2) # show centroid self.plotter.add_mesh(pv.PolyData(Vol_centroid), color='r', point_size=20.0, render_points_as_spheres=True) # find the nearest possible max cube vertex top = self.nearest_pt(max_c1, Vol_centroid) bottom = self.nearest_pt(max_c2, Vol_centroid) if top[0] < bottom[0]: p = top[1] V = top[2] else: p = bottom[1] V = bottom[2] # create and show max cube self.create_cube(V[p,:], Vol_centroid) self.plotter.add_mesh(max_cube, show_edges=True, color="b", opacity=0.6) #self.plotter.add_mesh(cell_center, color="r", point_size=8.0, render_points_as_spheres=True) # re-assign V as points of mesh V = np.array(mesh.points)
def test_subplot_groups(): plotter = pyvista.Plotter(shape=(3,3), groups=[(1,[1,2]),(np.s_[:],0)]) plotter.subplot(0, 0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(0, 1) plotter.add_mesh(pyvista.Cube()) plotter.subplot(0, 2) plotter.add_mesh(pyvista.Arrow()) plotter.subplot(1, 1) plotter.add_mesh(pyvista.Cylinder()) plotter.subplot(2, 1) plotter.add_mesh(pyvista.Cone()) plotter.subplot(2, 2) plotter.add_mesh(pyvista.Box()) plotter.show(before_close_callback=verify_cache_image)
def test_multi_block_list_index(ant, sphere, uniform, airplane, globe): multi = multi_from_datasets(ant, sphere, uniform, airplane, globe) # Now check everything indices = [0, 3, 4] sub = multi[indices] assert len(sub) == len(indices) for i, j in enumerate(indices): assert id(sub[i]) == id(multi[j]) assert sub.get_block_name(i) == multi.get_block_name(j) # check list of key names multi = MultiBlock() multi["foo"] = pyvista.Sphere() multi["goo"] = pyvista.Box() multi["soo"] = pyvista.Cone() indices = ["goo", "foo"] sub = multi[indices] assert len(sub) == len(indices) assert isinstance(sub["foo"], PolyData)
def test_multi_block_list_index(): multi = pyvista.MultiBlock() # Add examples multi.append(ex.load_ant()) multi.append(ex.load_sphere()) multi.append(ex.load_uniform()) multi.append(ex.load_airplane()) multi.append(ex.load_globe()) # Now check everything indices = [0, 3, 4] sub = multi[indices] assert len(sub) == len(indices) for i, j in enumerate(indices): assert id(sub[i]) == id(multi[j]) assert sub.get_block_name(i) == multi.get_block_name(j) # check list of key names multi = pyvista.MultiBlock() multi["foo"] = pyvista.Sphere() multi["goo"] = pyvista.Box() multi["soo"] = pyvista.Cone() indices = ["goo", "foo"] sub = multi[indices] assert len(sub) == len(indices) assert isinstance(sub["foo"], pyvista.PolyData)
Note that we first demonstrate how the clipping is performed by computing an implicit distance and thresholding the mesh. This thresholding is one approach to clip by a surface, and preserve the original geometry of the given mesh, but many folks leverage the ``clip_surface`` filter to triangulate/tessellate the mesh geometries along the clip. """ # sphinx_gallery_thumbnail_number = 4 import pyvista as pv from pyvista import examples import numpy as np ############################################################################### surface = pv.Cone(direction=(0, 0, -1), height=3.0, radius=1, resolution=50, capping=False) # Make a gridded dataset n = 51 xx = yy = zz = 1 - np.linspace(0, n, n) * 2 / (n - 1) dataset = pv.RectilinearGrid(xx, yy, zz) # Preview the problem p = pv.Plotter() p.add_mesh(surface, color='w', label='Surface') p.add_mesh(dataset, color='gold', show_edges=True, opacity=0.75,
def test_cone(): cone = pyvista.Cone() assert np.any(cone.points) assert np.any(cone.faces)
plotter.add_text("Render Window 0", font_size=15) plotter.add_mesh(examples.load_globe()) plotter.subplot(0, 1) plotter.add_text("Render Window 1", font_size=15) plotter.add_mesh( pv.Cube(), show_edges=True, color="tan", ) plotter.subplot(1, 0) plotter.add_text("Render Window 2", font_size=15) sphere = pv.Sphere() plotter.add_mesh(sphere, scalars=sphere.points[:, 2]) plotter.add_scalar_bar("Z") # plotter.add_axes() plotter.add_axes(interactive=True) plotter.subplot(1, 1) plotter.add_text("Render Window 3", font_size=15) plotter.add_mesh( pv.Cone(), color="g", show_edges=True, ) plotter.show_bounds(all_edges=True) # Display the window plotter.show(screenshot="multi_renderers.png")
import pyvista pyvista.Cone().plot()
def test_multi_renderers(): plotter = pyvista.Plotter(shape=(2, 2), off_screen=OFF_SCREEN) plotter.subplot(0, 0) plotter.add_text('Render Window 0', font_size=30) sphere = pyvista.Sphere() plotter.add_mesh(sphere, scalars=sphere.points[:, 2]) plotter.add_scalar_bar('Z', vertical=True) plotter.subplot(0, 1) plotter.add_text('Render Window 1', font_size=30) plotter.add_mesh(pyvista.Cube(), show_edges=True) plotter.subplot(1, 0) plotter.add_text('Render Window 2', font_size=30) plotter.add_mesh(pyvista.Arrow(), color='y', show_edges=True) plotter.subplot(1, 1) plotter.add_text('Render Window 3', position=(0., 0.), font_size=30, viewport=True) plotter.add_mesh(pyvista.Cone(), color='g', show_edges=True, culling=True) plotter.add_bounding_box(render_lines_as_tubes=True, line_width=5) plotter.show_bounds(all_edges=True) plotter.update_bounds_axes() plotter.show() # Test subplot indices (2 rows by 1 column) plotter = pyvista.Plotter(shape=(2, 1), off_screen=OFF_SCREEN) # First row plotter.subplot(0, 0) plotter.add_mesh(pyvista.Sphere()) # Second row plotter.subplot(1, 0) plotter.add_mesh(pyvista.Cube()) plotter.show() # Test subplot indices (1 row by 2 columns) plotter = pyvista.Plotter(shape=(1, 2), off_screen=OFF_SCREEN) # First column plotter.subplot(0, 0) plotter.add_mesh(pyvista.Sphere()) # Second column plotter.subplot(0, 1) plotter.add_mesh(pyvista.Cube()) plotter.show() with pytest.raises(IndexError): # Test bad indices plotter = pyvista.Plotter(shape=(1, 2), off_screen=OFF_SCREEN) plotter.subplot(0, 0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(1, 0) plotter.add_mesh(pyvista.Cube()) plotter.show() # Test subplot 3 on left, 1 on right plotter = pyvista.Plotter(shape='3|1', off_screen=OFF_SCREEN) # First column plotter.subplot(0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(1) plotter.add_mesh(pyvista.Cube()) plotter.subplot(2) plotter.add_mesh(pyvista.Cylinder()) plotter.subplot(3) plotter.add_mesh(pyvista.Cone()) plotter.show() # Test subplot 3 on bottom, 1 on top plotter = pyvista.Plotter(shape='1|3', off_screen=OFF_SCREEN) # First column plotter.subplot(0) plotter.add_mesh(pyvista.Sphere()) plotter.subplot(1) plotter.add_mesh(pyvista.Cube()) plotter.subplot(2) plotter.add_mesh(pyvista.Cylinder()) plotter.subplot(3) plotter.add_mesh(pyvista.Cone()) plotter.show()
""" import pyvista as pv ############################################################################### # This runs through several of the available geometric objects available in # VTK which PyVista provides simple convenience methods for generating. # # Let's run through creating a few geometric objects! cyl = pv.Cylinder() arrow = pv.Arrow() sphere = pv.Sphere() plane = pv.Plane() line = pv.Line() box = pv.Box() cone = pv.Cone() poly = pv.Polygon() disc = pv.Disc() ############################################################################### # Now let's plot them all in one window p = pv.Plotter(shape=(3, 3)) # Top row p.subplot(0, 0) p.add_mesh(cyl, color="tan", show_edges=True) p.subplot(0, 1) p.add_mesh(arrow, color="tan", show_edges=True) p.subplot(0, 2) p.add_mesh(sphere, color="tan", show_edges=True) # Middle row
def next_cubes(self): #change cones to c0 to c5 global create_cone hi = 12 ang = np.arctan(1/(np.sqrt(2)/2)) ang = float(90 - np.degrees(ang)) create_cone = pv.Cone(center=face_center[0] + [0,0,hi/2], direction = [0.0,0.0,-1.0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone2 = pv.Cone(center=face_center[1] + [-hi/2,-hi/2,0], direction = [1,1,0.0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone3 = pv.Cone(center=face_center[2] + [0,0,hi/2], direction = [0,0,-1], height = hi, radius=None, resolution= 100, angle = ang, capping=False) #create_cone3 = pv.Cone(center=face_center[2] + [hi/2,hi,0], direction = [-1,-1,0.0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone4 = pv.Cone(center=face_center[3] + [hi/4,hi/4,0], direction = [-1,-1,0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone5 = pv.Cone(center=face_center[4] + [0,hi/2,0], direction = [0,-1,0], height = hi, radius=None, resolution= 100, angle = ang, capping=False) create_cone6 = pv.Cone(center=face_center[5] + [0,0,-hi/2], direction = [0,0,1], height = hi, radius=None, resolution= 100, angle = ang, capping=False) #create_cone7 = pv.Cone(center=cell_center1[0] + [0,0,hi/2], direction = [0,0,-1], height = hi, radius=None, resolution= 100, angle = ang, capping=False) clipped = mesh.clip_surface(create_cone, invert=True) cone_intersections = np.array(clipped.points) #top = self.nearest_pt(create_cone, face_center[0] + [0,0,hi/2]) clipped6 = mesh.clip_surface(create_cone6, invert=True) cone_intersection6 = np.array(clipped6.points) #nearest_cone = min(cone_intersection6) #self.nearest_pt(create_cone, face_center[0]) print("Bottom Intersection:",cone_intersection6) #nearest_point = np.amin(cone_intersection6[0]) nearest_point = min(cone_intersections, key=min) nearest_point6 = min(cone_intersection6, key=min) x_Min = face_center[5][0] x_Max = nearest_point6[0] x = x_Max - x_Min y_Min = face_center[5][1] y_Max = nearest_point6[1] y = y_Max - y_Min z_Min = face_center[5][2] z_Max = nearest_point6[2] z = z_Max - z_Min x1 = nearest_point[0] - face_center[0][0] y1 = nearest_point[1] - face_center[0][1] z1 = nearest_point[2] - face_center[0][2] #new_array = np.array(x1,y1,z1) #smallest = np.amin(new_array) #cube_bounds = np.array(face_center[0], x_length1, face_center[1], y_length2, face_center[3], z_length3) print(nearest_point, "Closeest Value") #print(largest) #print(smallest) print(x_Max) print(x1, "x") print(y1, "y") print(z1, "z") #print(cube_bounds, "Cube Boundarys") #cone_center = create_cone.cell_centers() #cone_center_points = np.array(cone_center.points) self.plotter.add_mesh(create_cone, color="y", opacity=0.6) #self.plotter.add_mesh(top, show_edges=True, color="r", opacity=0.6) self.plotter.add_mesh(clipped, show_edges=True, color="r", opacity=0.6) #self.plotter.add_mesh(create_cone2, show_edges=True, color="y", opacity=0.6) #self.plotter.add_mesh(create_cone3, show_edges=True, color="y", opacity=0.6) #self.plotter.add_mesh(create_cone4, show_edges=True, color="y", opacity=0.6) #self.plotter.add_mesh(create_cone5, show_edges=True, color="y", opacity=0.6) self.plotter.add_mesh(create_cone6, show_edges=True, color="y", opacity=0.6) self.plotter.add_mesh(clipped6, show_edges=True, color="r", opacity=0.6) "Z is the Max point of the minium points calcualted in order to create cube within space" next_cube = pv.Cube(center = (x_Min,y_Min,face_center[0][2] + (abs(z1)/2)), x_length= abs(z1), y_length = abs(z1), z_length = abs(z1), bounds=None) next_cube6 = pv.Cube(center = (x_Min,y_Min,face_center[5][2] - (abs(z)/2)), x_length= abs(z), y_length= abs(z), z_length = abs(z), bounds=None) cell_center1 = next_cube.cell_centers() #create_cone7 = pv.Cone(center=cell_center1[0] + [0,0,hi/2], direction = [0,0,-1], height = hi, radius=None, resolution= 100, angle = ang, capping=False) # clipped7 = mesh.clip_surface(create_cone7, invert=True) #cone_intersection7 = np.array(clipped7.points) # nearest_point7 = min(cone_intersection7, key=min) #x7 = nearest_point7[0] - cell_center1[0][0] #y7 = nearest_point7[1] - cell_center1[0][1] #z7 = nearest_point7[2] - cell_center1[0][2] #next_cube7 = pv.Cube(center = (x_Min,y_Min,cell_center1[0][2] - (abs(x7)/2)), x_length= abs(x7), y_length= abs(x7), z_length = abs(x7), bounds=None) next_cube_center_top = np.array(cell_center1.points) cell_center6 = next_cube6.cell_centers() next_cube__center_bottom = np.array(cell_center6.points) print(next_cube__center_bottom) self.plotter.add_mesh(next_cube, show_edges=True, color = "b", opacity = 0.6) self.plotter.add_mesh(cell_center1, color="r", point_size=8.0, render_points_as_spheres=True) self.plotter.add_mesh(next_cube6, show_edges=True, color = "b", opacity = 0.6) self.plotter.add_mesh(cell_center6, color="r", point_size=8.0, render_points_as_spheres=True)
plotter.subplot(0, 1) plotter.add_text("Render Window 1", font_size=30) plotter.add_mesh(pv.Cube(), show_edges=True, color="tan") plotter.subplot(1, 0) plotter.add_text("Render Window 2", font_size=30) sphere = pv.Sphere() plotter.add_mesh(sphere, scalars=sphere.points[:, 2]) plotter.add_scalar_bar("Z") # plotter.add_axes() plotter.add_axes(interactive=True) plotter.subplot(1, 1) plotter.add_text("Render Window 3", font_size=30) plotter.add_mesh(pv.Cone(), color="g", show_edges=True) plotter.show_bounds(all_edges=True) # Display the window plotter.show() ############################################################################### plotter = pv.Plotter(shape=(1, 2)) # Note that the (0, 0) location is active by default # load and plot an airplane on the left half of the screen plotter.add_text("Airplane Example\n", font_size=30) plotter.add_mesh(examples.load_airplane(), show_edges=False) # load and plot the uniform data example on the right-hand side
def arrows_from_point_cloud(point_cloud): import pyvista as pv geom = pv.Cone(radius=0.25, resolution=18) arrows = point_cloud.glyph(orient="spins", scale=False, factor=1, geom=geom) return arrows