Commit 36496681901d50a8dc0886a5ed74da040f8cf0c5

Authored by tfmoraes
1 parent 92f6a9bf

Testing with quadric decimation

Showing 1 changed file with 27 additions and 0 deletions   Show diff stats
invesalius/data/surface_process.py
@@ -76,6 +76,19 @@ class SurfaceProcess(multiprocessing.Process): @@ -76,6 +76,19 @@ class SurfaceProcess(multiprocessing.Process):
76 mcubes.ComputeNormalsOn() 76 mcubes.ComputeNormalsOn()
77 polydata = mcubes.GetOutput() 77 polydata = mcubes.GetOutput()
78 78
  79 +
  80 + triangle = vtk.vtkTriangleFilter()
  81 + triangle.SetInput(polydata)
  82 + triangle.Update()
  83 + polydata = triangle.GetOutput()
  84 +
  85 + bounds = polydata.GetBounds()
  86 + origin = ((bounds[1] + bounds[0]) / 2.0, (bounds[3] + bounds[2])/2.0,
  87 + (bounds[5] + bounds[4]) / 2.0)
  88 +
  89 + print "Bounds is", bounds
  90 + print "origin is", origin
  91 +
79 #print "Decimating" 92 #print "Decimating"
80 #if self.decimate_reduction: 93 #if self.decimate_reduction:
81 #decimation = vtk.vtkDecimatePro() 94 #decimation = vtk.vtkDecimatePro()
@@ -85,6 +98,20 @@ class SurfaceProcess(multiprocessing.Process): @@ -85,6 +98,20 @@ class SurfaceProcess(multiprocessing.Process):
85 #decimation.SplittingOff() 98 #decimation.SplittingOff()
86 #polydata = decimation.GetOutput() 99 #polydata = decimation.GetOutput()
87 100
  101 + decimation = vtk.vtkQuadricClustering()
  102 + decimation.SetInput(polydata)
  103 + decimation.AutoAdjustNumberOfDivisionsOff()
  104 + decimation.SetDivisionOrigin(0, 0, 0)
  105 + decimation.SetDivisionSpacing(self.spacing)
  106 + decimation.SetFeaturePointsAngle(80)
  107 + decimation.UseFeaturePointsOn()
  108 + decimation.UseFeatureEdgesOn()
  109 + decimation.CopyCellDataOn()
  110 +
  111 + print "Division", decimation.GetNumberOfDivisions()
  112 +
  113 + polydata = decimation.GetOutput()
  114 +
88 #if self.smooth_iterations and self.smooth_relaxation_factor: 115 #if self.smooth_iterations and self.smooth_relaxation_factor:
89 #print "Smoothing" 116 #print "Smoothing"
90 #smoother = vtk.vtkWindowedSincPolyDataFilter() 117 #smoother = vtk.vtkWindowedSincPolyDataFilter()