Skip to content

Commit

Permalink
Issue #93 try a 2 stage decimation
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Mar 15, 2022
1 parent bee43a7 commit 7424cf7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sksurgerybard/algorithms/decimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ def decimate_actor(actor, target_vertices):
start_points = polydata.GetNumberOfPoints()
target_reduction = 1.0 - target_vertices/start_points

decimated = vtkPolyData()
#For big reductions let's try two stage, although I'm not
#sure this has any effect
if target_reduction > 0.9:
decimate = vtkDecimatePro()
decimate.SetInputData(polydata)
decimate.SetTargetReduction(0.9)
decimate.PreserveTopologyOn()
decimate.Update()
polydata.ShallowCopy(decimate.GetOutput())
start_points = polydata.GetNumberOfPoints()
target_reduction = 1.0 - target_vertices/start_points

decimate = vtkDecimatePro()
decimate.SetInputData(polydata)
decimate.SetTargetReduction(target_reduction)
decimate.PreserveTopologyOn()
decimate.Update()

decimated = vtkPolyData()
decimated.ShallowCopy(decimate.GetOutput())

actor.GetMapper().SetInputData(decimated)
Expand Down

0 comments on commit 7424cf7

Please sign in to comment.