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 24 import imagedata_utils
25 25 from project import Project
26 26 import constants as const
27   -import converters
28 27  
29 28 from vtk.util import numpy_support
30 29  
... ... @@ -56,19 +55,19 @@ def to_vtk(n_array, spacing, slice_number, orientation):
56 55 image = vtk.vtkImageData()
57 56 image.SetOrigin(0, 0, 0)
58 57 image.SetSpacing(spacing)
59   - image.SetNumberOfScalarComponents(1)
60 58 image.SetDimensions(dx, dy, dz)
61 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 64 image.GetCellData().SetScalars(v_image)
66 65 image.GetPointData().SetScalars(v_image)
67   - image.Update()
  66 + # image.Update()
68 67  
69 68 image_copy = vtk.vtkImageData()
70 69 image_copy.DeepCopy(image)
71   - image_copy.Update()
  70 + # image_copy.Update()
72 71  
73 72 return image_copy
74 73  
... ... @@ -270,7 +269,7 @@ class CursorCircle(CursorBase):
270 269 z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf]
271 270  
272 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 273 self.spacing, 0, self.orientation)
275 274 circle_ci = self._set_colour(circle_i, self.colour)
276 275  
... ... @@ -344,7 +343,7 @@ class CursorRectangle(CursorBase):
344 343 z = math.floor(r/sz)
345 344  
346 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 347 rectangle_ci = self._set_colour(rectangle_i, self.colour)
349 348  
350 349 if self.mapper is None:
... ...