Commit a8e514b4bf7059f66b8665fcfae51263b2e41144

Authored by Thiago Franco de Moraes
1 parent 5b7747ae
Exists in vtk6

cursor was not displayed correctly

Showing 1 changed file with 8 additions and 9 deletions   Show diff stats
invesalius/data/cursor_actors.py
@@ -24,7 +24,6 @@ import vtk @@ -24,7 +24,6 @@ import vtk
24 import imagedata_utils 24 import imagedata_utils
25 from project import Project 25 from project import Project
26 import constants as const 26 import constants as const
27 -import converters  
28 27
29 from vtk.util import numpy_support 28 from vtk.util import numpy_support
30 29
@@ -56,19 +55,19 @@ def to_vtk(n_array, spacing, slice_number, orientation): @@ -56,19 +55,19 @@ def to_vtk(n_array, spacing, slice_number, orientation):
56 image = vtk.vtkImageData() 55 image = vtk.vtkImageData()
57 image.SetOrigin(0, 0, 0) 56 image.SetOrigin(0, 0, 0)
58 image.SetSpacing(spacing) 57 image.SetSpacing(spacing)
59 - image.SetNumberOfScalarComponents(1)  
60 image.SetDimensions(dx, dy, dz) 58 image.SetDimensions(dx, dy, dz)
61 image.SetExtent(extent) 59 image.SetExtent(extent)
62 - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype))  
63 - image.AllocateScalars()  
64 - image.Update() 60 + # image.SetNumberOfScalarComponents(1)
  61 + # image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype))
  62 + image.AllocateScalars(numpy_support.get_vtk_array_type(n_array.dtype), 1)
  63 + # image.Update()
65 image.GetCellData().SetScalars(v_image) 64 image.GetCellData().SetScalars(v_image)
66 image.GetPointData().SetScalars(v_image) 65 image.GetPointData().SetScalars(v_image)
67 - image.Update() 66 + # image.Update()
68 67
69 image_copy = vtk.vtkImageData() 68 image_copy = vtk.vtkImageData()
70 image_copy.DeepCopy(image) 69 image_copy.DeepCopy(image)
71 - image_copy.Update() 70 + # image_copy.Update()
72 71
73 return image_copy 72 return image_copy
74 73
@@ -270,7 +269,7 @@ class CursorCircle(CursorBase): @@ -270,7 +269,7 @@ class CursorCircle(CursorBase):
270 z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf] 269 z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf]
271 270
272 circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2 271 circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2
273 - circle_i = converters.to_vtk(circle_m.astype('uint8'), 272 + circle_i = to_vtk(circle_m.astype('uint8'),
274 self.spacing, 0, self.orientation) 273 self.spacing, 0, self.orientation)
275 circle_ci = self._set_colour(circle_i, self.colour) 274 circle_ci = self._set_colour(circle_i, self.colour)
276 275
@@ -344,7 +343,7 @@ class CursorRectangle(CursorBase): @@ -344,7 +343,7 @@ class CursorRectangle(CursorBase):
344 z = math.floor(r/sz) 343 z = math.floor(r/sz)
345 344
346 rectangle_m = numpy.ones((z, y, x), dtype='uint8') 345 rectangle_m = numpy.ones((z, y, x), dtype='uint8')
347 - rectangle_i = converters.to_vtk(rectangle_m, self.spacing, 0, self.orientation) 346 + rectangle_i = to_vtk(rectangle_m, self.spacing, 0, self.orientation)
348 rectangle_ci = self._set_colour(rectangle_i, self.colour) 347 rectangle_ci = self._set_colour(rectangle_i, self.colour)
349 348
350 if self.mapper is None: 349 if self.mapper is None: