Commit 5b7747ae79177bf22d730fadf313ea4a0e8b7a04

Authored by Thiago Franco de Moraes
1 parent c06ff6da
Exists in vtk6

Showing the slices

.gitignore
... ... @@ -20,3 +20,7 @@ invesalius/reader/*.pyc
20 20 *.so
21 21 tags
22 22 *.c
  23 +
  24 +build
  25 +*.patch
  26 +*.tgz
... ...
invesalius/data/converters.py
... ... @@ -43,16 +43,16 @@ def to_vtk(n_array, spacing, slice_number, orientation):
43 43 image = vtk.vtkImageData()
44 44 image.SetOrigin(0, 0, 0)
45 45 image.SetSpacing(spacing)
46   - image.SetNumberOfScalarComponents(1)
47 46 image.SetDimensions(dx, dy, dz)
  47 + # SetNumberOfScalarComponents and SetScalrType were replaced by
  48 + # AllocateScalars
  49 + # image.SetNumberOfScalarComponents(1)
  50 + # image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype))
  51 + image.AllocateScalars(numpy_support.get_vtk_array_type(n_array.dtype), 1)
48 52 image.SetExtent(extent)
49   - image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype))
50   - image.AllocateScalars()
51 53 image.GetPointData().SetScalars(v_image)
52   - image.Update()
53 54  
54 55 image_copy = vtk.vtkImageData()
55 56 image_copy.DeepCopy(image)
56   - image_copy.Update()
57 57  
58 58 return image_copy
... ...
invesalius/data/cursor_actors.py
... ... @@ -24,6 +24,7 @@ import vtk
24 24 import imagedata_utils
25 25 from project import Project
26 26 import constants as const
  27 +import converters
27 28  
28 29 from vtk.util import numpy_support
29 30  
... ... @@ -224,7 +225,7 @@ class CursorBase(object):
224 225 img_colours_mask = vtk.vtkImageMapToColors()
225 226 img_colours_mask.SetLookupTable(lut_mask)
226 227 img_colours_mask.SetOutputFormatToRGBA()
227   - img_colours_mask.SetInput(imagedata)
  228 + img_colours_mask.SetInputData(imagedata)
228 229 img_colours_mask.Update()
229 230  
230 231 return img_colours_mask.GetOutput()
... ... @@ -269,17 +270,17 @@ class CursorCircle(CursorBase):
269 270 z,y,x = numpy.ogrid[zi:zf,yi:yf, xi:xf]
270 271  
271 272 circle_m = (z*sz)**2 + (y*sy)**2 + (x*sx)**2 <= r**2
272   - circle_i = to_vtk(circle_m.astype('uint8'),
  273 + circle_i = converters.to_vtk(circle_m.astype('uint8'),
273 274 self.spacing, 0, self.orientation)
274 275 circle_ci = self._set_colour(circle_i, self.colour)
275 276  
276 277 if self.mapper is None:
277   - self.actor.SetInput(circle_ci)
  278 + self.actor.SetInputData(circle_ci)
278 279 self.actor.InterpolateOff()
279 280 self.actor.PickableOff()
280 281 self.actor.SetDisplayExtent(circle_ci.GetExtent())
281 282 else:
282   - self.mapper.SetInput(circle_ci)
  283 + self.mapper.SetInputData(circle_ci)
283 284 self.mapper.BorderOn()
284 285  
285 286 self.mapper.SetOrientation(ORIENTATION[self.orientation])
... ... @@ -343,16 +344,16 @@ class CursorRectangle(CursorBase):
343 344 z = math.floor(r/sz)
344 345  
345 346 rectangle_m = numpy.ones((z, y, x), dtype='uint8')
346   - rectangle_i = to_vtk(rectangle_m, self.spacing, 0, self.orientation)
  347 + rectangle_i = converters.to_vtk(rectangle_m, self.spacing, 0, self.orientation)
347 348 rectangle_ci = self._set_colour(rectangle_i, self.colour)
348 349  
349 350 if self.mapper is None:
350   - self.actor.SetInput(rectangle_ci)
  351 + self.actor.SetInputData(rectangle_ci)
351 352 self.actor.InterpolateOff()
352 353 self.actor.PickableOff()
353 354 self.actor.SetDisplayExtent(rectangle_ci.GetExtent())
354 355 else:
355   - self.mapper.SetInput(rectangle_ci)
  356 + self.mapper.SetInputData(rectangle_ci)
356 357 self.mapper.BorderOn()
357 358 self.mapper.SetOrientation(ORIENTATION[self.orientation])
358 359  
... ...
invesalius/data/slice_.py
... ... @@ -964,18 +964,18 @@ class Slice(object):
964 964 img = self.buffer_slices[orientation].vtk_image
965 965 original_orientation = Project().original_orientation
966 966 cast = vtk.vtkImageCast()
967   - cast.SetInput(img)
  967 + cast.SetInputData(img)
968 968 cast.SetOutputScalarTypeToDouble()
969 969 cast.ClampOverflowOn()
970 970 cast.Update()
971 971  
972 972 #if (original_orientation == const.AXIAL):
973 973 flip = vtk.vtkImageFlip()
974   - flip.SetInput(cast.GetOutput())
  974 + flip.SetInputConnection(cast.GetOutputPort())
975 975 flip.SetFilteredAxis(1)
976 976 flip.FlipAboutOriginOn()
977 977 flip.Update()
978   - widget.SetInput(flip.GetOutput())
  978 + widget.SetInputConnection(flip.GetOutputPort())
979 979 #else:
980 980 #widget.SetInput(cast.GetOutput())
981 981  
... ... @@ -1044,7 +1044,7 @@ class Slice(object):
1044 1044 i += 1
1045 1045  
1046 1046 colorer = vtk.vtkImageMapToColors()
1047   - colorer.SetInput(image)
  1047 + colorer.SetInputData(image)
1048 1048 colorer.SetLookupTable(lut)
1049 1049 colorer.SetOutputFormatToRGB()
1050 1050 colorer.Update()
... ... @@ -1059,12 +1059,12 @@ class Slice(object):
1059 1059  
1060 1060 colorer = vtk.vtkImageMapToColors()
1061 1061 colorer.SetLookupTable(lut)
1062   - colorer.SetInput(image)
  1062 + colorer.SetInputData(image)
1063 1063 colorer.SetOutputFormatToRGB()
1064 1064 colorer.Update()
1065 1065 else:
1066 1066 colorer = vtk.vtkImageMapToWindowLevelColors()
1067   - colorer.SetInput(image)
  1067 + colorer.SetInputData(image)
1068 1068 colorer.SetWindow(self.window_width)
1069 1069 colorer.SetLevel(self.window_level)
1070 1070 colorer.SetOutputFormatToRGB()
... ... @@ -1148,7 +1148,7 @@ class Slice(object):
1148 1148 img_colours_bg = vtk.vtkImageMapToColors()
1149 1149 img_colours_bg.SetOutputFormatToRGB()
1150 1150 img_colours_bg.SetLookupTable(lut_bg)
1151   - img_colours_bg.SetInput(imagedata)
  1151 + img_colours_bg.SetInputData(imagedata)
1152 1152 img_colours_bg.Update()
1153 1153  
1154 1154 return img_colours_bg.GetOutput()
... ... @@ -1179,7 +1179,7 @@ class Slice(object):
1179 1179 img_colours_mask = vtk.vtkImageMapToColors()
1180 1180 img_colours_mask.SetLookupTable(lut_mask)
1181 1181 img_colours_mask.SetOutputFormatToRGBA()
1182   - img_colours_mask.SetInput(imagedata)
  1182 + img_colours_mask.SetInputData(imagedata)
1183 1183 img_colours_mask.Update()
1184 1184 # self.img_colours_mask = img_colours_mask
1185 1185  
... ... @@ -1211,7 +1211,7 @@ class Slice(object):
1211 1211 img_colours_mask = vtk.vtkImageMapToColors()
1212 1212 img_colours_mask.SetLookupTable(lut_mask)
1213 1213 img_colours_mask.SetOutputFormatToRGBA()
1214   - img_colours_mask.SetInput(imagedata)
  1214 + img_colours_mask.SetInputData(imagedata)
1215 1215 img_colours_mask.Update()
1216 1216 # self.img_colours_mask = img_colours_mask
1217 1217  
... ... @@ -1225,8 +1225,8 @@ class Slice(object):
1225 1225 blend_imagedata.SetBlendModeToNormal()
1226 1226 # blend_imagedata.SetOpacity(0, 1.0)
1227 1227 blend_imagedata.SetOpacity(1, 0.8)
1228   - blend_imagedata.SetInput(imagedata)
1229   - blend_imagedata.AddInput(mask)
  1228 + blend_imagedata.SetInputData(imagedata)
  1229 + blend_imagedata.AddInputData(mask)
1230 1230 blend_imagedata.Update()
1231 1231  
1232 1232 return blend_imagedata.GetOutput()
... ...
invesalius/data/slice_data.py
... ... @@ -55,7 +55,7 @@ class SliceData(object):
55 55  
56 56 def __create_line_actor(self, line):
57 57 line_mapper = vtk.vtkPolyDataMapper2D()
58   - line_mapper.SetInput(line.GetOutput())
  58 + line_mapper.SetInputConnection(line.GetOutputPort())
59 59  
60 60 line_actor = vtk.vtkActor2D()
61 61 line_actor.SetMapper(line_mapper)
... ...
invesalius/data/viewer_slice.py
... ... @@ -919,7 +919,7 @@ class Viewer(wx.Panel):
919 919 c.SetCoordinateSystemToWorld()
920 920  
921 921 cross_mapper = vtk.vtkPolyDataMapper()
922   - cross_mapper.SetInput(cross.GetOutput())
  922 + cross_mapper.SetInputConnection(cross.GetOutputPort())
923 923 #cross_mapper.SetTransformCoordinate(c)
924 924  
925 925 p = vtk.vtkProperty()
... ... @@ -1176,7 +1176,7 @@ class Viewer(wx.Panel):
1176 1176 border_size = self.mip_ctrls.border_spin.GetValue()
1177 1177 image = self.slice_.GetSlices(self.orientation, index,
1178 1178 self.number_slices, inverted, border_size)
1179   - self.slice_data.actor.SetInput(image)
  1179 + self.slice_data.actor.SetInputData(image)
1180 1180 for actor in self.actors_by_slice_number.get(self.slice_data.number, []):
1181 1181 self.slice_data.renderer.RemoveActor(actor)
1182 1182 for actor in self.actors_by_slice_number.get(index, []):
... ...
invesalius/reader/dicom_reader.py
... ... @@ -195,14 +195,14 @@ class LoadDicom:
195 195 window = 2000.0
196 196  
197 197 colorer = vtk.vtkImageMapToWindowLevelColors()
198   - colorer.SetInput(rvtk.GetOutput())
  198 + colorer.SetInputConnection(rvtk.GetOutputPort())
199 199 colorer.SetWindow(float(window))
200 200 colorer.SetLevel(float(level))
201 201 colorer.SetOutputFormatToRGB()
202 202 colorer.Update()
203 203  
204 204 resample = vtk.vtkImageResample()
205   - resample.SetInput(colorer.GetOutput())
  205 + resample.SetInputConnection(colorer.GetOutputPort())
206 206 resample.SetAxisMagnificationFactor ( 0, 0.25 )
207 207 resample.SetAxisMagnificationFactor ( 1, 0.25 )
208 208 resample.SetAxisMagnificationFactor ( 2, 1 )
... ... @@ -211,7 +211,7 @@ class LoadDicom:
211 211 thumbnail_path = tempfile.mktemp()
212 212  
213 213 write_png = vtk.vtkPNGWriter()
214   - write_png.SetInput(resample.GetOutput())
  214 + write_png.SetInputConnection(resample.GetOutputPort())
215 215 write_png.SetFileName(thumbnail_path)
216 216 write_png.Write()
217 217  
... ...