diff --git a/invesalius/data/surface.py b/invesalius/data/surface.py index 138d943..56cd6c4 100644 --- a/invesalius/data/surface.py +++ b/invesalius/data/surface.py @@ -42,6 +42,8 @@ try: except ImportError: import data.ca_smoothing as ca_smoothing +# TODO: Verificar ReleaseDataFlagOn and SetSource + class Surface(): """ Represent both vtkPolyData and associated properties. @@ -240,12 +242,12 @@ class SurfaceManager(): name=None, colour=None, transparency=None, volume=None): normals = vtk.vtkPolyDataNormals() - normals.SetInput(polydata) + normals.SetInputData(polydata) normals.SetFeatureAngle(80) normals.AutoOrientNormalsOn() mapper = vtk.vtkPolyDataMapper() - mapper.SetInput(normals.GetOutput()) + mapper.SetInputData(normals.GetOutput()) mapper.ScalarVisibilityOff() mapper.ImmediateModeRenderingOn() # improve performance @@ -289,11 +291,11 @@ class SurfaceManager(): # The following lines have to be here, otherwise all volumes disappear if not volume: triangle_filter = vtk.vtkTriangleFilter() - triangle_filter.SetInput(polydata) + triangle_filter.SetInputData(polydata) triangle_filter.Update() measured_polydata = vtk.vtkMassProperties() - measured_polydata.SetInput(triangle_filter.GetOutput()) + measured_polydata.SetInputData(triangle_filter.GetOutput()) volume = measured_polydata.GetVolume() surface.volume = volume print ">>>>", surface.volume @@ -338,19 +340,19 @@ class SurfaceManager(): surface = surface_dict[key] # Map polygonal data (vtkPolyData) to graphics primitives. normals = vtk.vtkPolyDataNormals() - normals.SetInput(surface.polydata) + normals.SetInputData(surface.polydata) normals.SetFeatureAngle(80) normals.AutoOrientNormalsOn() - normals.GetOutput().ReleaseDataFlagOn() + # normals.GetOutput().ReleaseDataFlagOn() # Improve performance stripper = vtk.vtkStripper() - stripper.SetInput(normals.GetOutput()) + stripper.SetInputData(normals.GetOutput()) stripper.PassThroughCellIdsOn() stripper.PassThroughPointIdsOn() mapper = vtk.vtkPolyDataMapper() - mapper.SetInput(stripper.GetOutput()) + mapper.SetInputData(stripper.GetOutput()) mapper.ScalarVisibilityOff() mapper.ImmediateModeRenderingOn() # improve performance @@ -490,30 +492,30 @@ class SurfaceManager(): break polydata_append = vtk.vtkAppendPolyData() - polydata_append.ReleaseDataFlagOn() + # polydata_append.ReleaseDataFlagOn() t = n_pieces while t: filename_polydata = q_out.get() reader = vtk.vtkXMLPolyDataReader() reader.SetFileName(filename_polydata) - reader.ReleaseDataFlagOn() + # reader.ReleaseDataFlagOn() reader.Update() - reader.GetOutput().ReleaseDataFlagOn() + # reader.GetOutput().ReleaseDataFlagOn() polydata = reader.GetOutput() - polydata.SetSource(None) + # polydata.SetSource(None) - polydata_append.AddInput(polydata) + polydata_append.AddInputData(polydata) del reader del polydata t -= 1 polydata_append.Update() - polydata_append.GetOutput().ReleaseDataFlagOn() + # polydata_append.GetOutput().ReleaseDataFlagOn() polydata = polydata_append.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del polydata_append if algorithm == 'ca_smoothing': @@ -521,31 +523,31 @@ class SurfaceManager(): normals_ref = weakref.ref(normals) normals_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(normals_ref(), _("Creating 3D surface..."))) - normals.SetInput(polydata) - normals.ReleaseDataFlagOn() + normals.SetInputData(polydata) + # normals.ReleaseDataFlagOn() #normals.SetFeatureAngle(80) #normals.AutoOrientNormalsOn() normals.ComputeCellNormalsOn() - normals.GetOutput().ReleaseDataFlagOn() + # normals.GetOutput().ReleaseDataFlagOn() normals.Update() del polydata polydata = normals.GetOutput() - polydata.SetSource(None) + # polydata.SetSource(None) del normals clean = vtk.vtkCleanPolyData() - clean.ReleaseDataFlagOn() - clean.GetOutput().ReleaseDataFlagOn() + # clean.ReleaseDataFlagOn() + # clean.GetOutput().ReleaseDataFlagOn() clean_ref = weakref.ref(clean) clean_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(clean_ref(), _("Creating 3D surface..."))) - clean.SetInput(polydata) + clean.SetInputData(polydata) clean.PointMergingOn() clean.Update() del polydata polydata = clean.GetOutput() - polydata.SetSource(None) + # polydata.SetSource(None) del clean try: @@ -556,7 +558,7 @@ class SurfaceManager(): options['max distance'], options['min weight'], options['steps']) - polydata.SetSource(None) + # polydata.SetSource(None) polydata.DebugOn() else: @@ -565,7 +567,7 @@ class SurfaceManager(): smoother_ref = weakref.ref(smoother) smoother_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(smoother_ref(), _("Creating 3D surface..."))) - smoother.SetInput(polydata) + smoother.SetInputData(polydata) smoother.SetNumberOfIterations(smooth_iterations) smoother.SetRelaxationFactor(smooth_relaxation_factor) smoother.SetFeatureAngle(80) @@ -575,21 +577,21 @@ class SurfaceManager(): smoother.FeatureEdgeSmoothingOn() #smoother.NormalizeCoordinatesOn() #smoother.NonManifoldSmoothingOn() - smoother.ReleaseDataFlagOn() - smoother.GetOutput().ReleaseDataFlagOn() + # smoother.ReleaseDataFlagOn() + # smoother.GetOutput().ReleaseDataFlagOn() smoother.Update() del polydata polydata = smoother.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del smoother if decimate_reduction: print "Decimating", decimate_reduction decimation = vtk.vtkQuadricDecimation() - decimation.ReleaseDataFlagOn() - decimation.SetInput(polydata) + # decimation.ReleaseDataFlagOn() + decimation.SetInputData(polydata) decimation.SetTargetReduction(decimate_reduction) decimation_ref = weakref.ref(decimation) decimation_ref().AddObserver("ProgressEvent", lambda obj,evt: @@ -597,31 +599,31 @@ class SurfaceManager(): #decimation.PreserveTopologyOn() #decimation.SplittingOff() #decimation.BoundaryVertexDeletionOff() - decimation.GetOutput().ReleaseDataFlagOn() + # decimation.GetOutput().ReleaseDataFlagOn() decimation.Update() del polydata polydata = decimation.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del decimation to_measure = polydata #to_measure.Register(None) - to_measure.SetSource(None) + # to_measure.SetSource(None) if keep_largest: conn = vtk.vtkPolyDataConnectivityFilter() - conn.SetInput(polydata) + conn.SetInputData(polydata) conn.SetExtractionModeToLargestRegion() conn_ref = weakref.ref(conn) conn_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(conn_ref(), _("Creating 3D surface..."))) conn.Update() - conn.GetOutput().ReleaseDataFlagOn() + # conn.GetOutput().ReleaseDataFlagOn() del polydata polydata = conn.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del conn #Filter used to detect and fill holes. Only fill boundary edges holes. @@ -629,59 +631,59 @@ class SurfaceManager(): #polydata_utils.FillSurfaceHole, we need to review this. if fill_holes: filled_polydata = vtk.vtkFillHolesFilter() - filled_polydata.ReleaseDataFlagOn() - filled_polydata.SetInput(polydata) + # filled_polydata.ReleaseDataFlagOn() + filled_polydata.SetInputData(polydata) filled_polydata.SetHoleSize(300) filled_polydata_ref = weakref.ref(filled_polydata) filled_polydata_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(filled_polydata_ref(), _("Creating 3D surface..."))) filled_polydata.Update() - filled_polydata.GetOutput().ReleaseDataFlagOn() + # filled_polydata.GetOutput().ReleaseDataFlagOn() del polydata polydata = filled_polydata.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) polydata.DebugOn() del filled_polydata normals = vtk.vtkPolyDataNormals() - normals.ReleaseDataFlagOn() + # normals.ReleaseDataFlagOn() normals_ref = weakref.ref(normals) normals_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(normals_ref(), _("Creating 3D surface..."))) - normals.SetInput(polydata) + normals.SetInputData(polydata) normals.SetFeatureAngle(80) normals.AutoOrientNormalsOn() - normals.GetOutput().ReleaseDataFlagOn() + # normals.GetOutput().ReleaseDataFlagOn() normals.Update() del polydata polydata = normals.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del normals # Improve performance stripper = vtk.vtkStripper() - stripper.ReleaseDataFlagOn() + # stripper.ReleaseDataFlagOn() stripper_ref = weakref.ref(stripper) stripper_ref().AddObserver("ProgressEvent", lambda obj,evt: UpdateProgress(stripper_ref(), _("Creating 3D surface..."))) - stripper.SetInput(polydata) + stripper.SetInputData(polydata) stripper.PassThroughCellIdsOn() stripper.PassThroughPointIdsOn() - stripper.GetOutput().ReleaseDataFlagOn() + # stripper.GetOutput().ReleaseDataFlagOn() stripper.Update() del polydata polydata = stripper.GetOutput() #polydata.Register(None) - polydata.SetSource(None) + # polydata.SetSource(None) del stripper # Map polygonal data (vtkPolyData) to graphics primitives. mapper = vtk.vtkPolyDataMapper() - mapper.SetInput(polydata) + mapper.SetInputData(polydata) mapper.ScalarVisibilityOff() - mapper.ReleaseDataFlagOn() + # mapper.ReleaseDataFlagOn() mapper.ImmediateModeRenderingOn() # improve performance # Represent an object (geometry & properties) in the rendered scene @@ -720,8 +722,8 @@ class SurfaceManager(): # The following lines have to be here, otherwise all volumes disappear measured_polydata = vtk.vtkMassProperties() - measured_polydata.ReleaseDataFlagOn() - measured_polydata.SetInput(to_measure) + # measured_polydata.ReleaseDataFlagOn() + measured_polydata.SetInputData(to_measure) volume = float(measured_polydata.GetVolume()) surface.volume = volume self.last_surface_index = surface.index @@ -858,14 +860,14 @@ class SurfaceManager(): if filetype in (const.FILETYPE_STL, const.FILETYPE_PLY): # Invert normals normals = vtk.vtkPolyDataNormals() - normals.SetInput(polydata) + normals.SetInputData(polydata) normals.SetFeatureAngle(80) normals.AutoOrientNormalsOn() - normals.GetOutput().ReleaseDataFlagOn() + # normals.GetOutput().ReleaseDataFlagOn() normals.UpdateInformation() polydata = normals.GetOutput() filename = filename.encode(wx.GetDefaultPyEncoding()) writer.SetFileName(filename) - writer.SetInput(polydata) + writer.SetInputData(polydata) writer.Write() diff --git a/invesalius/data/surface_process.py b/invesalius/data/surface_process.py index 6b1909f..63a1378 100644 --- a/invesalius/data/surface_process.py +++ b/invesalius/data/surface_process.py @@ -26,7 +26,7 @@ def ResampleImage3D(imagedata, value): resolution = (height/(extent[1]-extent[0])+1)*spacing[1] resample = vtk.vtkImageResample() - resample.SetInput(imagedata) + resample.SetInputData(imagedata) resample.SetAxisMagnificationFactor(0, resolution) resample.SetAxisMagnificationFactor(1, resolution) @@ -106,7 +106,7 @@ class SurfaceProcess(multiprocessing.Process): "AXIAL") gauss = vtk.vtkImageGaussianSmooth() - gauss.SetInput(image) + gauss.SetInputData(image) gauss.SetRadiusFactor(0.3) gauss.ReleaseDataFlagOn() gauss.Update() @@ -125,7 +125,7 @@ class SurfaceProcess(multiprocessing.Process): image = ResampleImage3D(image, self.imagedata_resolution) flip = vtk.vtkImageFlip() - flip.SetInput(image) + flip.SetInputData(image) flip.SetFilteredAxis(1) flip.FlipAboutOriginOn() flip.ReleaseDataFlagOn() @@ -148,7 +148,7 @@ class SurfaceProcess(multiprocessing.Process): #if self.mode == "CONTOUR": #print "Contour" contour = vtk.vtkContourFilter() - contour.SetInput(image) + contour.SetInputData(image) #contour.SetInput(flip.GetOutput()) if self.from_binary: contour.SetValue(0, 127) # initial threshold @@ -202,7 +202,7 @@ class SurfaceProcess(multiprocessing.Process): filename = tempfile.mktemp(suffix='_%s.vtp' % (self.pid)) writer = vtk.vtkXMLPolyDataWriter() - writer.SetInput(polydata) + writer.SetInputData(polydata) writer.SetFileName(filename) writer.Write() -- libgit2 0.21.2