Пример #1
0
 def _smoothCurve(self, rawPointsArray):
     # Convert numpy array to vtkPoints
     rawPoints = vtk.vtkPoints()
     for rawPoint in rawPointsArray:
         rawPoints.InsertNextPoint(rawPoint)
     # Interpolate
     rawPolyData = vtk.vtkPolyData()
     rawPolyData.SetPoints(rawPoints)
     curveGenerator = slicer.vtkCurveGenerator()
     curveGenerator.SetInputData(rawPolyData)
     curveGenerator.SetCurveTypeToKochanekSpline()
     curveGenerator.CurveIsClosedOn()
     curveGenerator.Update()
     smoothedPolyData = curveGenerator.GetOutput()
     smoothedPoints = smoothedPolyData.GetPoints()
     # Export to numpy array
     numberOfPoints = smoothedPoints.GetNumberOfPoints()
     import numpy as np
     smoothedPointsArray = np.zeros([numberOfPoints, 3])
     for pointIndex in range(numberOfPoints):
         smoothedPointsArray[pointIndex] = smoothedPoints.GetPoint(
             pointIndex)
     return smoothedPointsArray
 def __init__(self, scriptedEffect):
     self.scriptedEffect = scriptedEffect
     self.radius = 1.0
     self.curveGenerator = slicer.vtkCurveGenerator()