def InterpolatePatchCenterlines(patchCenterlines, parentCenterlines, additionalPoint, lower, version): if additionalPoint is not None: additionalPointIds = [] for i in range(parentCenterlines.GetNumberOfCells()): line = ExtractSingleLine(parentCenterlines, i) additionalPointIds.append(line.FindPoint(additionalPoint)) else: additionalPointIds = [ "" for i in range(parentCenterlines.GetNumberOfCells()) ] interpolatedLines = vtk.vtkPolyData() interpolatedPoints = vtk.vtkPoints() interpolatedCellArray = vtk.vtkCellArray() pointsInserted = 0 interpolatedCellArray.Initialize() for i in range(parentCenterlines.GetNumberOfCells()): startingCell = vtk.vtkGenericCell() endingCell = vtk.vtkGenericCell() numberOfInterpolationPoints = parentCenterlines.GetCell( i).GetNumberOfPoints() patchCenterlines.GetCell(0, startingCell) patchCenterlines.GetCell(i + 1, endingCell) if version: splinePoints = InterpolateSpline(startingCell, endingCell, additionalPoint) else: splinePoints = InterpolateTwoCells(startingCell, endingCell, \ numberOfInterpolationPoints, \ additionalPointIds[i], additionalPoint, lower) interpolatedCellArray.InsertNextCell(splinePoints.GetNumberOfPoints()) for j in range(splinePoints.GetNumberOfPoints()): interpolatedPoints.InsertNextPoint(splinePoints.GetPoint(j)) interpolatedCellArray.InsertCellPoint(pointsInserted + j) pointsInserted += splinePoints.GetNumberOfPoints() interpolatedLines.SetPoints(interpolatedPoints) interpolatedLines.SetLines(interpolatedCellArray) attributeFilter = vtkvmtk.vtkvmtkCenterlineAttributesFilter() attributeFilter.SetInput(interpolatedLines) attributeFilter.SetAbscissasArrayName(AbscissasArrayName) attributeFilter.SetParallelTransportNormalsArrayName( parallelTransportNormalsArrayName) attributeFilter.Update() attributeInterpolatedLines = attributeFilter.GetOutput() return attributeInterpolatedLines
def InterpolatePatchCenterlines(patchCenterlines, parentCenterlines): additionalPoint = [-1.0, -1.0, -1.0] additionalPointIds = [] if (useAdditionalInterpolationPoint == 1): additionalPoint = divergingPoints.GetPoint(0) line1 = ExtractSingleLine(parentCenterlines, 0) line2 = ExtractSingleLine(parentCenterlines, 1) additionalPointIds.append(line1.FindPoint(additionalPoint)) additionalPointIds.append(line2.FindPoint(additionalPoint)) else: for i in range(parentCenterlines.GetNumberOfCells()): additionalPoint = clippingPoints.GetPoint(0) line1 = ExtractSingleLine(parentCenterlines, 0) additionalPointIds.append(line1.FindPoint(additionalPoint)) interpolatedLines = vtk.vtkPolyData() interpolatedPoints = vtk.vtkPoints() interpolatedCellArray = vtk.vtkCellArray() pointsInserted = 0 interpolatedCellArray.Initialize() for i in range(parentCenterlines.GetNumberOfCells()): startingCell = vtk.vtkGenericCell() endingCell = vtk.vtkGenericCell() numberOfInterpolationPoints = parentCenterlines.GetCell( i).GetNumberOfPoints() patchCenterlines.GetCell(0, startingCell) patchCenterlines.GetCell(i + 1, endingCell) splinePoints = InterpolateTwoCells(startingCell, endingCell, numberOfInterpolationPoints, additionalPointIds[i], additionalPoint) interpolatedCellArray.InsertNextCell(splinePoints.GetNumberOfPoints()) for j in range(splinePoints.GetNumberOfPoints()): interpolatedPoints.InsertNextPoint(splinePoints.GetPoint(j)) interpolatedCellArray.InsertCellPoint(pointsInserted + j) pointsInserted += splinePoints.GetNumberOfPoints() interpolatedLines.SetPoints(interpolatedPoints) interpolatedLines.SetLines(interpolatedCellArray) attributeFilter = vtkvmtk.vtkvmtkCenterlineAttributesFilter() attributeFilter.SetInputData(interpolatedLines) attributeFilter.SetAbscissasArrayName(abscissasArrayName) attributeFilter.SetParallelTransportNormalsArrayName( parallelTransportNormalsArrayName) attributeFilter.Update() attributeInterpolatedLines = attributeFilter.GetOutput() return attributeInterpolatedLines
def InterpolatePatchCenterlines(patchCenterlines, parentCenterlines): additionalPoint = [-1.0, -1.0, -1.0] additionalPointIds = [] if useAdditionalInterpolationPoint == 1: additionalPoint = divergingPoints.GetPoint(0) line1 = ExtractSingleLine(parentCenterlines, 0) line2 = ExtractSingleLine(parentCenterlines, 1) additionalPointIds.append(line1.FindPoint(additionalPoint)) additionalPointIds.append(line2.FindPoint(additionalPoint)) else: for i in range(parentCenterlines.GetNumberOfCells()): additionalPoint = clippingPoints.GetPoint(0) line1 = ExtractSingleLine(parentCenterlines, 0) additionalPointIds.append(line1.FindPoint(additionalPoint)) interpolatedLines = vtk.vtkPolyData() interpolatedPoints = vtk.vtkPoints() interpolatedCellArray = vtk.vtkCellArray() pointsInserted = 0 interpolatedCellArray.Initialize() for i in range(parentCenterlines.GetNumberOfCells()): startingCell = vtk.vtkGenericCell() endingCell = vtk.vtkGenericCell() numberOfInterpolationPoints = parentCenterlines.GetCell(i).GetNumberOfPoints() patchCenterlines.GetCell(0, startingCell) patchCenterlines.GetCell(i + 1, endingCell) splinePoints = InterpolateTwoCells( startingCell, endingCell, numberOfInterpolationPoints, additionalPointIds[i], additionalPoint ) interpolatedCellArray.InsertNextCell(splinePoints.GetNumberOfPoints()) for j in range(splinePoints.GetNumberOfPoints()): interpolatedPoints.InsertNextPoint(splinePoints.GetPoint(j)) interpolatedCellArray.InsertCellPoint(pointsInserted + j) pointsInserted += splinePoints.GetNumberOfPoints() interpolatedLines.SetPoints(interpolatedPoints) interpolatedLines.SetLines(interpolatedCellArray) attributeFilter = vtkvmtk.vtkvmtkCenterlineAttributesFilter() attributeFilter.SetInput(interpolatedLines) attributeFilter.SetAbscissasArrayName(abscissasArrayName) attributeFilter.SetParallelTransportNormalsArrayName(parallelTransportNormalsArrayName) attributeFilter.Update() attributeInterpolatedLines = attributeFilter.GetOutput() return attributeInterpolatedLines
def Execute(self): if self.Centerlines == None: self.PrintError('Error: No input centerlines.') centerlineAttributes = vtkvmtk.vtkvmtkCenterlineAttributesFilter() centerlineAttributes.SetInputData(self.Centerlines) centerlineAttributes.SetAbscissasArrayName(self.AbscissasArrayName) centerlineAttributes.SetParallelTransportNormalsArrayName(self.NormalsArrayName) centerlineAttributes.Update() self.Centerlines = centerlineAttributes.GetOutput()