def Execute(self): if self.Surface == None: self.PrintError('Error: No input surface.') if self.PolyBall == None: self.PrintError('Error: No input polyball.') evaluationArray = vtk.vtkDoubleArray() evaluationArray.SetName(self.EvaluationArrayName) evaluationArray.SetNumberOfComponents(1) evaluationArray.SetNumberOfTuples(self.Surface.GetNumberOfPoints()) polyball = None if self.Type == "polyball": polyball = vtkvmtk.vtkvmtkPolyBall() elif self.Type == "tubes": polyball = vtkvmtk.vtkvmtkPolyBallLine() polyball.SetInputData(self.PolyBall) polyball.SetPolyBallRadiusArrayName(self.RadiusArrayName) for i in range(self.Surface.GetNumberOfPoints()): point = self.Surface.GetPoint(i) value = polyball.EvaluateFunction(point) evaluationArray.SetValue(i, value) self.Surface.GetPointData().AddArray(evaluationArray)
def MaskWithPatch(id, t, c, r, maskArray, centerlines, voronoi): patch = ExtractSingleLine(centerlines, id) tubeFunction = vtkvmtk.vtkvmtkPolyBallLine() tubeFunction.SetInput(patch) tubeFunction.SetPolyBallRadiusArrayName(radiusArrayName) lastSphere = vtk.vtkSphere() lastSphere.SetRadius(r * 1.5) lastSphere.SetCenter(c) for i in range(voronoi.GetNumberOfPoints()): point = [0.0, 0.0, 0.0] voronoiVector = [0.0, 0.0, 0.0] voronoi.GetPoint(i, point) voronoiVector = [point[j] - c[j] for j in range(3)] voronoiVectorDot = vtk.vtkMath.Dot(voronoiVector, t) tubevalue = tubeFunction.EvaluateFunction(point) spherevalue = lastSphere.EvaluateFunction(point) if (spherevalue < 0.0) & (voronoiVectorDot < 0.0): continue elif (tubevalue <= 0.0): maskArray.SetTuple1(i, 1)
def Execute(self): if self.Surface == None: self.PrintError("Error: No input surface.") if self.PolyBall == None: self.PrintError("Error: No input polyball.") evaluationArray = vtk.vtkDoubleArray() evaluationArray.SetName(self.EvaluationArrayName) evaluationArray.SetNumberOfComponents(1) evaluationArray.SetNumberOfTuples(self.Surface.GetNumberOfPoints()) polyball = None if self.Type == "polyball": polyball = vtkvmtk.vtkvmtkPolyBall() elif self.Type == "tubes": polyball = vtkvmtk.vtkvmtkPolyBallLine() polyball.SetInputData(self.PolyBall) polyball.SetPolyBallRadiusArrayName(self.RadiusArrayName) for i in xrange(self.Surface.GetNumberOfPoints()): point = self.Surface.GetPoint(i) value = polyball.EvaluateFunction(point) evaluationArray.SetValue(i, value) self.Surface.GetPointData().AddArray(evaluationArray)
def MaskWithPatch(id,t,c,r,maskArray,centerlines,voronoi): patch = ExtractPatch(id,centerlines) tubeFunction = vtkvmtk.vtkvmtkPolyBallLine() tubeFunction.SetInput(patch) tubeFunction.SetPolyBallRadiusArrayName(radiusArrayName) lastSphere = vtk.vtkSphere() lastSphere.SetRadius(r*1.5) lastSphere.SetCenter(c) for i in range(voronoi.GetNumberOfPoints()): point = [0.0,0.0,0.0] voronoiVector = [0.0,0.0,0.0] voronoi.GetPoint(i,point) voronoiVector[0] = point[0]-c[0] voronoiVector[1] = point[1]-c[1] voronoiVector[2] = point[2]-c[2] voronoiVectorDot = vtk.vtkMath.Dot(voronoiVector,t) tubevalue = tubeFunction.EvaluateFunction(point) spherevalue = lastSphere.EvaluateFunction(point) if (spherevalue<0.0) & (voronoiVectorDot<0.0): continue elif (tubevalue<=0.0): maskArray.SetTuple1(i,1)
def BuildPolyBall(self): #if we have no values return if self.SpheresRadii.GetNumberOfTuples() == 0: return #interpolate the radius array self.InterpolateRadius() if self.PolyBallType == 1: self.PolyBall = vtkvmtk.vtkvmtkPolyBallLine2() else: self.PolyBall = vtkvmtk.vtkvmtkPolyBallLine() self.PolyBall.SetInputData(self.Centerlines) self.PolyBall.SetUseRadiusInformation(1) self.PolyBall.SetPolyBallRadiusArrayName("InterpolatedRadius")
def BuildPolyBall(self): #if we have no values return if self.SpheresRadii.GetNumberOfTuples() == 0: return #interpolate the radius array self.InterpolateRadius() if self.PolyBallType==1: self.PolyBall = vtkvmtk.vtkvmtkPolyBallLine2() else: self.PolyBall = vtkvmtk.vtkvmtkPolyBallLine() self.PolyBall.SetInputData(self.Centerlines) self.PolyBall.SetUseRadiusInformation(1) self.PolyBall.SetPolyBallRadiusArrayName("InterpolatedRadius")