Commit 48a7630298d3f734e83776175152fd7a938e5ede
1 parent
2fa9bf61
Exists in
vtk6
saving project
Showing
1 changed file
with
12 additions
and
15 deletions
Show diff stats
invesalius/data/polydata_utils.py
| @@ -36,7 +36,7 @@ def ApplyDecimationFilter(polydata, reduction_factor): | @@ -36,7 +36,7 @@ def ApplyDecimationFilter(polydata, reduction_factor): | ||
| 36 | # Important: vtkQuadricDecimation presented better results than | 36 | # Important: vtkQuadricDecimation presented better results than |
| 37 | # vtkDecimatePro | 37 | # vtkDecimatePro |
| 38 | decimation = vtk.vtkQuadricDecimation() | 38 | decimation = vtk.vtkQuadricDecimation() |
| 39 | - decimation.SetInput(polydata) | 39 | + decimation.SetInputData(polydata) |
| 40 | decimation.SetTargetReduction(reduction_factor) | 40 | decimation.SetTargetReduction(reduction_factor) |
| 41 | decimation.GetOutput().ReleaseDataFlagOn() | 41 | decimation.GetOutput().ReleaseDataFlagOn() |
| 42 | decimation.AddObserver("ProgressEvent", lambda obj, evt: | 42 | decimation.AddObserver("ProgressEvent", lambda obj, evt: |
| @@ -48,7 +48,7 @@ def ApplySmoothFilter(polydata, iterations, relaxation_factor): | @@ -48,7 +48,7 @@ def ApplySmoothFilter(polydata, iterations, relaxation_factor): | ||
| 48 | Smooth given vtkPolyData surface, based on iteration and relaxation_factor. | 48 | Smooth given vtkPolyData surface, based on iteration and relaxation_factor. |
| 49 | """ | 49 | """ |
| 50 | smoother = vtk.vtkSmoothPolyDataFilter() | 50 | smoother = vtk.vtkSmoothPolyDataFilter() |
| 51 | - smoother.SetInput(polydata) | 51 | + smoother.SetInputData(polydata) |
| 52 | smoother.SetNumberOfIterations(iterations) | 52 | smoother.SetNumberOfIterations(iterations) |
| 53 | smoother.SetFeatureAngle(80) | 53 | smoother.SetFeatureAngle(80) |
| 54 | smoother.SetRelaxationFactor(relaxation_factor) | 54 | smoother.SetRelaxationFactor(relaxation_factor) |
| @@ -69,7 +69,7 @@ def FillSurfaceHole(polydata): | @@ -69,7 +69,7 @@ def FillSurfaceHole(polydata): | ||
| 69 | # Filter used to detect and fill holes. Only fill | 69 | # Filter used to detect and fill holes. Only fill |
| 70 | print "Filling polydata" | 70 | print "Filling polydata" |
| 71 | filled_polydata = vtk.vtkFillHolesFilter() | 71 | filled_polydata = vtk.vtkFillHolesFilter() |
| 72 | - filled_polydata.SetInput(polydata) | 72 | + filled_polydata.SetInputData(polydata) |
| 73 | filled_polydata.SetHoleSize(500) | 73 | filled_polydata.SetHoleSize(500) |
| 74 | return filled_polydata.GetOutput() | 74 | return filled_polydata.GetOutput() |
| 75 | 75 | ||
| @@ -79,7 +79,7 @@ def CalculateSurfaceVolume(polydata): | @@ -79,7 +79,7 @@ def CalculateSurfaceVolume(polydata): | ||
| 79 | """ | 79 | """ |
| 80 | # Filter used to calculate volume and area from a polydata | 80 | # Filter used to calculate volume and area from a polydata |
| 81 | measured_polydata = vtk.vtkMassProperties() | 81 | measured_polydata = vtk.vtkMassProperties() |
| 82 | - measured_polydata.SetInput(polydata) | 82 | + measured_polydata.SetInputData(polydata) |
| 83 | return measured_polydata.GetVolume() | 83 | return measured_polydata.GetVolume() |
| 84 | 84 | ||
| 85 | def CalculateSurfaceArea(polydata): | 85 | def CalculateSurfaceArea(polydata): |
| @@ -88,7 +88,7 @@ def CalculateSurfaceArea(polydata): | @@ -88,7 +88,7 @@ def CalculateSurfaceArea(polydata): | ||
| 88 | """ | 88 | """ |
| 89 | # Filter used to calculate volume and area from a polydata | 89 | # Filter used to calculate volume and area from a polydata |
| 90 | measured_polydata = vtk.vtkMassProperties() | 90 | measured_polydata = vtk.vtkMassProperties() |
| 91 | - measured_polydata.SetInput(polydata) | 91 | + measured_polydata.SetInputData(polydata) |
| 92 | return measured_polydata.GetSurfaceArea() | 92 | return measured_polydata.GetSurfaceArea() |
| 93 | 93 | ||
| 94 | def Merge(polydata_list): | 94 | def Merge(polydata_list): |
| @@ -96,11 +96,11 @@ def Merge(polydata_list): | @@ -96,11 +96,11 @@ def Merge(polydata_list): | ||
| 96 | 96 | ||
| 97 | for polydata in polydata_list: | 97 | for polydata in polydata_list: |
| 98 | triangle = vtk.vtkTriangleFilter() | 98 | triangle = vtk.vtkTriangleFilter() |
| 99 | - triangle.SetInput(polydata) | ||
| 100 | - append.AddInput(triangle.GetOutput()) | 99 | + triangle.SetInputData(polydata) |
| 100 | + append.AddInputData(triangle.GetOutput()) | ||
| 101 | 101 | ||
| 102 | clean = vtk.vtkCleanPolyData() | 102 | clean = vtk.vtkCleanPolyData() |
| 103 | - clean.SetInput(append.GetOutput()) | 103 | + clean.SetInputData(append.GetOutput()) |
| 104 | 104 | ||
| 105 | return append.GetOutput() | 105 | return append.GetOutput() |
| 106 | 106 | ||
| @@ -112,7 +112,7 @@ def Export(polydata, filename, bin=False): | @@ -112,7 +112,7 @@ def Export(polydata, filename, bin=False): | ||
| 112 | writer.SetDataModeToBinary() | 112 | writer.SetDataModeToBinary() |
| 113 | else: | 113 | else: |
| 114 | writer.SetDataModeToAscii() | 114 | writer.SetDataModeToAscii() |
| 115 | - writer.SetInput(polydata) | 115 | + writer.SetInputData(polydata) |
| 116 | writer.Write() | 116 | writer.Write() |
| 117 | 117 | ||
| 118 | def Import(filename): | 118 | def Import(filename): |
| @@ -130,7 +130,7 @@ def JoinSeedsParts(polydata, point_id_list): | @@ -130,7 +130,7 @@ def JoinSeedsParts(polydata, point_id_list): | ||
| 130 | from vtkPolyData. | 130 | from vtkPolyData. |
| 131 | """ | 131 | """ |
| 132 | conn = vtk.vtkPolyDataConnectivityFilter() | 132 | conn = vtk.vtkPolyDataConnectivityFilter() |
| 133 | - conn.SetInput(polydata) | 133 | + conn.SetInputData(polydata) |
| 134 | conn.SetExtractionModeToPointSeededRegions() | 134 | conn.SetExtractionModeToPointSeededRegions() |
| 135 | UpdateProgress = vu.ShowProgress(1 + len(point_id_list)) | 135 | UpdateProgress = vu.ShowProgress(1 + len(point_id_list)) |
| 136 | pos = 1 | 136 | pos = 1 |
| @@ -145,7 +145,6 @@ def JoinSeedsParts(polydata, point_id_list): | @@ -145,7 +145,6 @@ def JoinSeedsParts(polydata, point_id_list): | ||
| 145 | 145 | ||
| 146 | result = vtk.vtkPolyData() | 146 | result = vtk.vtkPolyData() |
| 147 | result.DeepCopy(conn.GetOutput()) | 147 | result.DeepCopy(conn.GetOutput()) |
| 148 | - result.Update() | ||
| 149 | return result | 148 | return result |
| 150 | 149 | ||
| 151 | def SelectLargestPart(polydata): | 150 | def SelectLargestPart(polydata): |
| @@ -153,7 +152,7 @@ def SelectLargestPart(polydata): | @@ -153,7 +152,7 @@ def SelectLargestPart(polydata): | ||
| 153 | """ | 152 | """ |
| 154 | UpdateProgress = vu.ShowProgress(1) | 153 | UpdateProgress = vu.ShowProgress(1) |
| 155 | conn = vtk.vtkPolyDataConnectivityFilter() | 154 | conn = vtk.vtkPolyDataConnectivityFilter() |
| 156 | - conn.SetInput(polydata) | 155 | + conn.SetInputData(polydata) |
| 157 | conn.SetExtractionModeToLargestRegion() | 156 | conn.SetExtractionModeToLargestRegion() |
| 158 | conn.AddObserver("ProgressEvent", lambda obj, evt: | 157 | conn.AddObserver("ProgressEvent", lambda obj, evt: |
| 159 | UpdateProgress(conn, "Getting largest part...")) | 158 | UpdateProgress(conn, "Getting largest part...")) |
| @@ -161,14 +160,13 @@ def SelectLargestPart(polydata): | @@ -161,14 +160,13 @@ def SelectLargestPart(polydata): | ||
| 161 | 160 | ||
| 162 | result = vtk.vtkPolyData() | 161 | result = vtk.vtkPolyData() |
| 163 | result.DeepCopy(conn.GetOutput()) | 162 | result.DeepCopy(conn.GetOutput()) |
| 164 | - result.Update() | ||
| 165 | return result | 163 | return result |
| 166 | 164 | ||
| 167 | def SplitDisconectedParts(polydata): | 165 | def SplitDisconectedParts(polydata): |
| 168 | """ | 166 | """ |
| 169 | """ | 167 | """ |
| 170 | conn = vtk.vtkPolyDataConnectivityFilter() | 168 | conn = vtk.vtkPolyDataConnectivityFilter() |
| 171 | - conn.SetInput(polydata) | 169 | + conn.SetInputData(polydata) |
| 172 | conn.SetExtractionModeToAllRegions() | 170 | conn.SetExtractionModeToAllRegions() |
| 173 | conn.Update() | 171 | conn.Update() |
| 174 | 172 | ||
| @@ -191,7 +189,6 @@ def SplitDisconectedParts(polydata): | @@ -191,7 +189,6 @@ def SplitDisconectedParts(polydata): | ||
| 191 | 189 | ||
| 192 | p = vtk.vtkPolyData() | 190 | p = vtk.vtkPolyData() |
| 193 | p.DeepCopy(conn.GetOutput()) | 191 | p.DeepCopy(conn.GetOutput()) |
| 194 | - p.Update() | ||
| 195 | 192 | ||
| 196 | polydata_collection.append(p) | 193 | polydata_collection.append(p) |
| 197 | if progress: | 194 | if progress: |