#!/usr/bin/env python import pathlib from blastsight.view.viewer import Viewer """ In this demo, a mesh and a block set will be dynamically sliced by yourself, by clicking in two parts of the screen. """ viewer = Viewer() title = viewer.windowTitle() viewer.setWindowTitle(f'{title} - Click two points in the screen.') mesh_path = f'{pathlib.Path(__file__).parent.parent}/test_files/caseron.off' block_path = f'{pathlib.Path(__file__).parent.parent}/test_files/rainbow.csv' mesh = viewer.load_mesh(mesh_path, color=[0.0, 0.8, 0.6], alpha=0.2) blocks = viewer.load_blocks(block_path, alpha=0.1) original_size = blocks.block_size def slice_elements(description: dict) -> None: """ The method slice_elements reacts to viewer.signal_slice_description, and receives a description of the slice, so you can do whatever you want with that information. :param description: Description of the cross-section :return: None
#!/usr/bin/env python import pathlib from blastsight.view.viewer import Viewer """ In this demo, we'll show how you can measure mesh distances from the viewer. """ v = Viewer() title = v.windowTitle() v.setWindowTitle(f'{title} - Click two points of a mesh.') path = f'{pathlib.Path(__file__).parent.parent}/test_files/caseron.off' mesh = v.load_mesh(path, color=[0.0, 0.3, 1.0]) phantom_tube = v.tubes(vertices=[mesh.center, mesh.center], color=[1.0, 0.8, 0.0], visible=False) def update_info(d: dict): print(f'Distance dictionary: {d}') distance = d.get('distance') v.setWindowTitle(f'{title} - Distance: {distance}') points = [d.get('point_a'), d.get('point_b')] if distance is None: phantom_tube.is_visible = False else: