Commit 0cd816e5 authored by Stephen Thompson's avatar Stephen Thompson

Issue #1 added 2 more patches, simplified main app

parent 35e6ad1c
......@@ -12,7 +12,8 @@
"bounding box" : [0.0, 640.0, 0.0, 480.0, -100.0, 0.0]
},
"models" : "data/",
"targets" : "data/patches",
"map" : "data/full",
"model to world" : "configuration/model_to_world.txt",
"logo" : false,
"search radius" : 10000
......
......@@ -76,24 +76,31 @@ def configure_tracker(config):
return tracker
def populate_models(path_name, model_to_world):
def populate_models(config):
"""
Loads vtk models from a directory and returns
a list of vtk actors and associated vtkPointLocators
:param: pathname: directory where models are
:param: configuration, should contain a target value
:param: model_to_world: 4x4 matrix, of dtype float32
:return: locators
:return: actors
:raises: KeyError if target not in config
"""
models = []
if "target" not in config:
raise KeyError("Config must contain target key")
path_name = config.get("target")
loader = VTKSurfaceModelDirectoryLoader(path_name)
models = loader.models
locators = []
model_to_world = _set_model_to_world(config)
transform = vtk.vtkTransform()
transform.SetMatrix(np2vtk(model_to_world))
......@@ -122,7 +129,7 @@ def populate_models(path_name, model_to_world):
return models, locators
def set_model_to_world(config):
def _set_model_to_world(config):
"""
Creates a 4x4 model to world matrix
:param: the configuration, if model to world is defined it will load, if
......
......@@ -5,8 +5,7 @@ from math import isnan
from sksurgeryutils.common_overlay_apps import OverlayBaseApp
from sksurgeryvtk.text.text_overlay import VTKCornerAnnotation
from sksurgeryeval.algorithms.algorithms import (
configure_tracker, populate_models, np2vtk, point_in_locator,
set_model_to_world)
configure_tracker, populate_models, np2vtk, point_in_locator)
from sksurgeryeval.algorithms.background_image import \
OverlayBackground
from sksurgeryeval.shapes.cone import VTKConeModel
......@@ -37,8 +36,7 @@ class OverlayApp(OverlayBaseApp):
if "tracker config" in config:
self._tracker = configure_tracker(config.get("tracker config"))
model_to_world = set_model_to_world(config)
models, self._locators = populate_models(config.get("models"), model_to_world)
models, self._locators = populate_models(config)
self._pointer = VTKConeModel(5.0, 2.5, (1.0, 1.0, 1.0), "pointer")
self.vtk_overlay_window.add_vtk_actor(self._pointer.actor)
......
......@@ -24,12 +24,13 @@ def test_populate_models():
Tests that populate models function reads data from
a directory and returns a list of polydata and pointlocators
"""
models, locators = populate_models("data", model_to_world=numpy.eye(4))
config = { "target" : "data/patches" }
models, locators = populate_models(config)
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
assert len(models) == 3
assert len(locators) == 3
assert point_in == 2
def test_point_in_locator():
......
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