def test_clear(self): viewer = IntegrableViewer() viewer.load_mesh(path=f'{TEST_FILES_FOLDER_PATH}/caseron.off') viewer.load_blocks(path=f'{TEST_FILES_FOLDER_PATH}/mini.csv') viewer.load_points(path=f'{TEST_FILES_FOLDER_PATH}/mini.csv') assert viewer.drawable_collection.size() == 3 viewer.clear() assert viewer.drawable_collection.size() == 0
def test_export(self): viewer = IntegrableViewer() mesh = viewer.load_mesh(path=f'{TEST_FILES_FOLDER_PATH}/caseron.off') blocks = viewer.load_blocks(path=f'{TEST_FILES_FOLDER_PATH}/mini.csv') viewer.export_element( f'{TEST_FILES_FOLDER_PATH}/caseron_model_export.h5m', mesh.id) viewer.export_element( f'{TEST_FILES_FOLDER_PATH}/mini_model_export_blocks.h5p', blocks.id) viewer.export_element( f'{TEST_FILES_FOLDER_PATH}/mini_model_export_points.h5p', blocks.id) viewer.export_element( f'{TEST_FILES_FOLDER_PATH}/mini_model_export_lines.h5p', blocks.id) viewer.export_element( f'{TEST_FILES_FOLDER_PATH}/mini_model_export_tubes.h5p', blocks.id) # Failure deliberate viewer.export_element('a.asdf', -1) # Cleanup os.remove(f'{TEST_FILES_FOLDER_PATH}/caseron_model_export.h5m') os.remove(f'{TEST_FILES_FOLDER_PATH}/mini_model_export_blocks.h5p') os.remove(f'{TEST_FILES_FOLDER_PATH}/mini_model_export_points.h5p') os.remove(f'{TEST_FILES_FOLDER_PATH}/mini_model_export_lines.h5p') os.remove(f'{TEST_FILES_FOLDER_PATH}/mini_model_export_tubes.h5p') with pytest.raises(Exception): os.remove('a.asdf')
def test_slice_meshes(self): viewer = IntegrableViewer() mesh = viewer.load_mesh(f'{TEST_FILES_FOLDER_PATH}/caseron.dxf') mesh.hide() origin = mesh.center normal = [0.0, 0.6, 0.8] slices = viewer.slice_meshes(origin, normal, include_hidden=False) assert len(slices) == 0 slices = viewer.slice_meshes(origin, normal, include_hidden=True) assert len(slices) > 0
def test_add_wrong_elements(self): viewer = IntegrableViewer() assert viewer.mesh() is None assert viewer.blocks() is None assert viewer.points() is None assert viewer.lines() is None assert viewer.tubes() is None assert viewer.load_mesh('') is None assert viewer.load_blocks('') is None assert viewer.load_points('') is None assert viewer.load_lines('') is None assert viewer.load_tubes('') is None assert len(viewer.get_all_drawables()) == 0
def test_load_elements(self): viewer = IntegrableViewer() # Mesh mesh = viewer.load_mesh(f'{TEST_FILES_FOLDER_PATH}/caseron.dxf') assert type(mesh) is MeshGL assert viewer.last_id == mesh.id assert viewer.last_drawable is mesh assert len(viewer.get_all_drawables()) == 1 # Blocks blocks = viewer.load_blocks(f'{TEST_FILES_FOLDER_PATH}/mini.csv') assert type(blocks) is BlockGL assert viewer.last_id == blocks.id assert viewer.last_drawable is blocks assert len(viewer.get_all_drawables()) == 2 # Points points = viewer.load_points(f'{TEST_FILES_FOLDER_PATH}/mini.csv') assert type(points) is PointGL assert viewer.last_id == points.id assert viewer.last_drawable is points assert len(viewer.get_all_drawables()) == 3 # Lines lines = viewer.load_lines(f'{TEST_FILES_FOLDER_PATH}/mini.csv') assert type(lines) is LineGL assert viewer.last_id == lines.id assert viewer.last_drawable is lines assert len(viewer.get_all_drawables()) == 4 # Tubes tubes = viewer.load_tubes(f'{TEST_FILES_FOLDER_PATH}/mini.csv') assert type(tubes) is TubeGL assert viewer.last_id == tubes.id assert viewer.last_drawable is tubes assert len(viewer.get_all_drawables()) == 5