Commit 1e6f234c authored by Stephen Thompson's avatar Stephen Thompson

Merge branch '1-get-started' of...

Merge branch '1-get-started' of https://weisslab.cs.ucl.ac.uk/WEISS/SoftwareRepositories/SNAPPY/scikit-surgery-evaluation into 1-get-started
parents bfe5f9cf 7a39d0b6
Pipeline #3754 passed with stages
in 6 minutes and 29 seconds
......@@ -5,7 +5,6 @@ variables:
stages:
- build
- installer
- test
- deploy
......@@ -19,34 +18,6 @@ stages:
variables:
- $CI_COMMIT_MESSAGE =~ /\[skip[ _-]build?\]/i
.build-install-template: &build-install-template
script:
- tox -e installer
artifacts:
paths:
- dist/
expire_in: 1 week
# The win/mac/linux build stages inherit settings
# from build-install-template
build linux installer:
<<: *build-skip-template
<<: *build-install-template
tags:
- shared-linux
build mac installer:
<<: *build-skip-template
<<: *build-install-template
tags:
- shared-mac
build windows installer:
<<: *build-skip-template
<<: *build-install-template
tags:
- shared-win
build docs:
<<: *build-skip-template
script:
......
......@@ -26,7 +26,6 @@ def point_in_locator(point, point_locators, radius=1.0):
minumum_distance = inf
locator_index = -1
for index, locator in enumerate(point_locators):
distance = vtk.mutable(0.0)
if locator.FindClosestPointWithinRadius(radius, point, distance) == -1:
continue
......@@ -100,6 +99,7 @@ def populate_models(path_name, model_to_world=eye(4, 4)):
model.transform_filter.Update()
point_locator = vtk.vtkPointLocator()
point_locator.SetDataSet(model.source)
point_locator.Update()
locators.append(point_locator)
return models, locators
......@@ -4,44 +4,123 @@
import pytest
import vtk
from sksurgeryeval.ui.sksurgeryeval_demo import run_demo
from sksurgeryeval.algorithms.algorithms import point_in_locator, np2vtk, configure_tracker, populate_models
import numpy
from sksurgeryvtk.models.vtk_cylinder_model import VTKCylinderModel
from sksurgeryeval.ui.sksurgeryeval_demo import run_demo
from sksurgeryeval.algorithms.algorithms import \
point_in_locator, np2vtk, configure_tracker, populate_models
# Pytest style
def test_using_pytest_sksurgeryeval():
"""
Test that the app runs
"""
with pytest.raises(ValueError):
run_demo("empty", True)
def test_populate_models():
populate_models("data")
"""
Tests that populate models function reads data from
a directory and returns a list of polydata and pointlocators
"""
models, locators = populate_models("data")
point_in, _ = point_in_locator((570.0, 270.0, -1386.0),
locators, 3.0)
assert len(models) == 1
assert len(locators) == 1
assert point_in == 0
def test_point_in_locator():
"""
Tests that point locator can find the nearest point in a
bunch of polydata.
"""
locators = []
for x_ord in range(-5, 6, 5):
for y_ord in range(-5, 6, 5):
for z_ord in range(-5, 6, 5):
model = VTKCylinderModel(1.0, 0.5, (1.0, 1.0, 1.0), "name",
0.0, (1.0, 0.0, 0.0), 88,
True, 1.0)
locators=[]
for x in range (-2,2,1):
for y in range (-2,2,1):
for z in range (-2,2,1):
model = VTKCylinderModel(10, 5, (1.0, 1.0, 1.0), "name",
0.0, (1.0, 0.0, 0.0 ), 88,
True, 1.0)
transform_vector = (1.0, 0.0, 0.0, float(x), 0.0, 1.0, 0.0, float(y), 0.0, 0.0, 1.0, float(z), 0.0, 0.0, 0.0, 1.0)
transform_vector = (1.0, 0.0, 0.0, float(x_ord),
0.0, 1.0, 0.0, float(y_ord),
0.0, 0.0, 1.0, float(z_ord),
0.0, 0.0, 0.0, 1.0)
transform = vtk.vtkTransform()
transform.SetMatrix(transform_vector)
# print(transform)
model.transform_filter.SetInputData(model.source)
model.transform_filter.SetTransform(transform)
model.mapper.Update()
locator = vtk.vtkPointLocator()
transform_filter = vtk.vtkTransformPolyDataFilter()
transform_filter.SetTransform(transform)
source_new = vtk.vtkPolyData()
transform_filter.SetInputData(model.source)
transform_filter.SetOutput(source_new)
transform_filter.Update()
locator.SetDataSet(model.source)
locator = vtk.vtkPointLocator()
locator.SetDataSet(source_new)
locator.Update()
locators.append(locator)
point_in, distance = point_in_locator ( (0.1,0.0,0.0), locators, 1.0 )
print (point_in, distance)
point_in, distance = point_in_locator((0.0, 0.0, 0.0), locators, 7.0)
assert point_in == 13
numpy.testing.assert_almost_equal(distance, 0.5, 6)
def test_np2vtk_valid():
"""
Tests np2vtk for a valid matrix.
"""
np_mat = numpy.eye(4, 4)
np_mat[0, 3] = -1.7
np_mat[3, 1] = 2.3
vtk_mat = np2vtk(np_mat)
for i in range(4):
for j in range(4):
assert (vtk_mat.GetElement(i, j) == np_mat[i, j])
def test_np2vtk_invalid():
"""
Tests np2vtk throws value error for invalid matrix
"""
np_mat = numpy.eye(3, 3)
with pytest.raises(ValueError):
_ = np2vtk(np_mat)
def test_config_tracker_invalid():
"""
Tests that configure_tracker throws a KeyError when invalid
"""
config = {}
with pytest.raises(KeyError):
configure_tracker(config)
def test_config_tracker_dummy():
"""
Tests that configure_tracker for ndi, using dummy
"""
config = {"tracker type" : "dummy"}
try:
configure_tracker(config)
except ValueError:
pass
def test_config_tracker_aruco():
"""
Tests that configure_tracker for ndi, using dummy
"""
config = {
"tracker type" : "aruco",
"video source" : "data/aruco_tag.avi"
}
configure_tracker(config)
......@@ -20,17 +20,13 @@ commands = coverage erase
basepython=python3.6
deps=pylint
{[testenv]deps}
commands=pylint --rcfile=tests/pylintrc sksurgeryeval
commands=pylint --rcfile=tests/pylintrc sksurgeryeval tests
[testenv:docs]
basepython=python3.6
changedir = doc
commands = sphinx-build -M html . build
[testenv:installer]
basepython=python3.6
commands=pyinstaller --onefile sksurgeryeval.py --noconfirm --windowed
[testenv:pip3]
basepython=python3.6
changedir=pip_test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment