Commit b0b508db019f378d81cf207026c7422ca6fa992f
1 parent
0d3c6a41
Exists in
master
and in
67 other branches
Applying smooth to surface
Showing
2 changed files
with
30 additions
and
8 deletions
Show diff stats
invesalius/data/surface.py
| @@ -496,6 +496,32 @@ class SurfaceManager(): | @@ -496,6 +496,32 @@ class SurfaceManager(): | ||
| 496 | clean.PointMergingOn() | 496 | clean.PointMergingOn() |
| 497 | polydata = clean.GetOutput() | 497 | polydata = clean.GetOutput() |
| 498 | 498 | ||
| 499 | + smoother = vtk.vtkWindowedSincPolyDataFilter() | ||
| 500 | + smoother.SetInput(polydata) | ||
| 501 | + smoother.SetNumberOfIterations(smooth_iterations) | ||
| 502 | + smoother.SetFeatureAngle(120) | ||
| 503 | + smoother.BoundarySmoothingOn() | ||
| 504 | + smoother.SetPassBand(0.1) | ||
| 505 | + #smoother.FeatureEdgeSmoothingOn() | ||
| 506 | + #smoother.NonManifoldSmoothingOn() | ||
| 507 | + #smoother.NormalizeCoordinatesOn() | ||
| 508 | + smoother.Update() | ||
| 509 | + polydata = smoother.GetOutput() | ||
| 510 | + | ||
| 511 | + print "Normals" | ||
| 512 | + normals = vtk.vtkPolyDataNormals() | ||
| 513 | + normals.SetInput(polydata) | ||
| 514 | + normals.SetFeatureAngle(80) | ||
| 515 | + normals.AutoOrientNormalsOn() | ||
| 516 | + polydata = normals.GetOutput() | ||
| 517 | + #decimation = vtk.vtkDecimatePro() | ||
| 518 | + #decimation.SetInput(polydata) | ||
| 519 | + #decimation.SetTargetReduction(0.3) | ||
| 520 | + #decimation.PreserveTopologyOn() | ||
| 521 | + #decimation.SplittingOff() | ||
| 522 | + #decimation.BoundaryVertexDeletionOff() | ||
| 523 | + #polydata = decimation.GetOutput() | ||
| 524 | + | ||
| 499 | # Improve performance | 525 | # Improve performance |
| 500 | stripper = vtk.vtkStripper() | 526 | stripper = vtk.vtkStripper() |
| 501 | stripper.SetInput(polydata) | 527 | stripper.SetInput(polydata) |
invesalius/data/surface_process.py
| @@ -71,12 +71,11 @@ class SurfaceProcess(multiprocessing.Process): | @@ -71,12 +71,11 @@ class SurfaceProcess(multiprocessing.Process): | ||
| 71 | mcubes.SetInput(image) | 71 | mcubes.SetInput(image) |
| 72 | mcubes.SetValue(0, self.min_value) | 72 | mcubes.SetValue(0, self.min_value) |
| 73 | mcubes.SetValue(1, self.max_value) | 73 | mcubes.SetValue(1, self.max_value) |
| 74 | - mcubes.ComputeScalarsOn() | ||
| 75 | - mcubes.ComputeGradientsOn() | ||
| 76 | - mcubes.ComputeNormalsOn() | 74 | + mcubes.ComputeScalarsOff() |
| 75 | + mcubes.ComputeGradientsOff() | ||
| 76 | + mcubes.ComputeNormalsOff() | ||
| 77 | polydata = mcubes.GetOutput() | 77 | polydata = mcubes.GetOutput() |
| 78 | 78 | ||
| 79 | - | ||
| 80 | triangle = vtk.vtkTriangleFilter() | 79 | triangle = vtk.vtkTriangleFilter() |
| 81 | triangle.SetInput(polydata) | 80 | triangle.SetInput(polydata) |
| 82 | triangle.Update() | 81 | triangle.Update() |
| @@ -93,7 +92,7 @@ class SurfaceProcess(multiprocessing.Process): | @@ -93,7 +92,7 @@ class SurfaceProcess(multiprocessing.Process): | ||
| 93 | decimation = vtk.vtkDecimatePro() | 92 | decimation = vtk.vtkDecimatePro() |
| 94 | decimation.SetInput(polydata) | 93 | decimation.SetInput(polydata) |
| 95 | decimation.SetTargetReduction(0.3) | 94 | decimation.SetTargetReduction(0.3) |
| 96 | - decimation.PreserveTopologyOn() | 95 | + #decimation.PreserveTopologyOn() |
| 97 | decimation.SplittingOff() | 96 | decimation.SplittingOff() |
| 98 | decimation.BoundaryVertexDeletionOff() | 97 | decimation.BoundaryVertexDeletionOff() |
| 99 | polydata = decimation.GetOutput() | 98 | polydata = decimation.GetOutput() |
| @@ -133,8 +132,5 @@ class SurfaceProcess(multiprocessing.Process): | @@ -133,8 +132,5 @@ class SurfaceProcess(multiprocessing.Process): | ||
| 133 | writer.SetInput(polydata) | 132 | writer.SetInput(polydata) |
| 134 | writer.SetFileName(filename) | 133 | writer.SetFileName(filename) |
| 135 | writer.Write() | 134 | writer.Write() |
| 136 | - print filename | ||
| 137 | - | ||
| 138 | - time.sleep(1) | ||
| 139 | 135 | ||
| 140 | self.q_out.put(filename) | 136 | self.q_out.put(filename) |