示例#1
0
    def test_add_elements(self):
        viewer = IntegrableViewer()

        # Mesh
        mesh = viewer.mesh(x=[-1, 1, 0],
                           y=[0, 0, 1],
                           z=[0, 0, 0],
                           indices=[[0, 1, 2]])
        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.blocks(x=[-1, 1, 0],
                               y=[0, 0, 1],
                               z=[0, 0, 0],
                               values=[0, 1, 2])
        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.points(x=[-1, 1, 0],
                               y=[0, 0, 1],
                               z=[0, 0, 0],
                               values=[0, 1, 2])
        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.lines(x=[-1, 1, 0], y=[0, 0, 1], z=[0, 0, 0])
        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.tubes(x=[-1, 1, 0], y=[0, 0, 1], z=[0, 0, 0])
        assert type(tubes) is TubeGL
        assert viewer.last_id == tubes.id
        assert viewer.last_drawable is tubes
        assert len(viewer.get_all_drawables()) == 5
示例#2
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
示例#3
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