...
 
Commits (7)
{
"image" :
{
"source" : "data/noisy_logo.avi",
"loop" : true,
"logo" : false,
"blank" : false
},
"tracker config" :
{
"tracker type" : "aruco",
"debug" : false
},
"models" : [
{
"name" : "tip",
"port handle" : 0,
"load" : false,
"filename" : "n/a",
"source" : "cylinder",
"colour" : [1.0, 0.0, 0.0],
"height" : 50.0,
"radius" : 10.0,
"angle" : 90.0,
"orientation" : [0.0, 0.0, 1.0],
"offset" : [0.0, 0.0, 100.0],
"grab points" : true
},
{
"name" : "section_1",
"port handle" : 1,
"load" : false,
"filename" : "n/a",
"source" : "cylinder",
"colour" : [1.0, 0.0, 0.0],
"height" : 50.0,
"radius" : 6.0,
"angle" : 0.0,
"orientation" : [0.0, 0.0, 1.0],
"offset" : [1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 100.0,
0.0, 0.0, 0.0, 1.0]
},
{
"name" : "section_2",
"port handle" : 2,
"load" : false,
"filename" : "n/a",
"source" : "cylinder",
"colour" : [1.0, 0.0, 0.0],
"height" : 50.0,
"radius" : 6.0,
"resolution" : 10,
"orientation" : [0.0, 0.0, 1.0]
},
{
"name" : "anatomy_0",
"port handle" : -1,
"load" : "true",
"filename" : "data/example.vtp",
"model to world" : "data/example_mtw.4x4"
}
],
"camera" : {
"origin" : [0.0, 0.0, 0.0],
"normal" : [0.0, 0.0, 1.0],
"bounding box" : [0.0, 640.0, 0.0, 480.0, -100.0, 0.0]
}
}
......@@ -9,7 +9,8 @@ from sksurgerycore.transforms.transform_manager import TransformManager
from sksurgeryvtk.models.vtk_cylinder_model import VTKCylinderModel
from sksurgerytrackervisualisation.shapes.cone import VTKConeModel
from sksurgerytrackervisualisation.shapes.sphere import VTKSphereModel
from sksurgerytrackervisualisation.shapes.vtk_point_model import VTKPointCloud
from sksurgerytrackervisualisation.shapes.dynamic_point_cloud import \
VTKPointCloud
def np2vtk(mat):
......
......@@ -5,7 +5,7 @@ Class to represent a point cloud via a vtkPolyData, with the
ability to dynamically add points
"""
from numpy import hstack, ones, int64, arange, ascontiguousarray
from numpy import hstack, ones, int64, arange, ascontiguousarray, warnings
from vtk import (vtkPoints, vtkCellArray, vtkPolyData, vtkPolyDataMapper,
VTK_ID_TYPE)
from vtk.util import numpy_support
......@@ -41,14 +41,13 @@ class VTKPointCloud(vbm.VTKBaseModel):
number_of_points = self._vtk_points.GetNumberOfPoints()
if number_of_points == 0:
return
cells = hstack((ones((number_of_points, 1), dtype=int64),
arange(number_of_points).reshape(-1, 1)))
cells = ascontiguousarray(cells, dtype=int64)
cell_array = numpy_support.numpy_to_vtk(
num_array=cells, deep=True, array_type=VTK_ID_TYPE)
with warnings.catch_warnings(): #see issue #8
warnings.simplefilter("ignore", FutureWarning)
cell_array = numpy_support.numpy_to_vtk(
num_array=cells, deep=True, array_type=VTK_ID_TYPE)
vtk_cells = vtkCellArray()
......@@ -69,6 +68,5 @@ class VTKPointCloud(vbm.VTKBaseModel):
:param: A 3 tuple representing the point coordinate
"""
self._vtk_points.InsertNextPoint(point)
self._update_actor()
......@@ -208,7 +208,7 @@ def test_key_press_event(setup_qt):
}
overlay = OverlayApp(configuration)
overlay.vtk_overlay_window.SetKeySym("p")
overlay.vtk_overlay_window.SetKeySym("g")
overlay.vtk_overlay_window.KeyPressEvent()
overlay.vtk_overlay_window.SetKeySym("x")
......
......@@ -4,10 +4,11 @@
from sksurgerytrackervisualisation.shapes.cone import VTKConeModel
from sksurgerytrackervisualisation.shapes.sphere import VTKSphereModel
from sksurgerytrackervisualisation.shapes.dynamic_point_cloud import \
VTKPointCloud
# Pytest style
def test_cone():
"""
Tests cone model
......@@ -23,3 +24,13 @@ def test_sphere():
"""
_ = VTKSphereModel(radius=1.0, colour=(1.0, 1.0, 1.0),
name="spere")
def test_point_cloud():
"""
Tests for the point cloud.
"""
cloud = VTKPointCloud(colour=(0.0, 0.2, 0.3))
cloud.add_point((1.0, 1.0, 1.0))