def Execute(self): if self.Surface == None: self.PrintError('Error: No input surface.') if self.ConvertCellToPoint == 1: self.PrintLog('converting any cell data to point data') try: from vmtk import vmtksurfacecelldatatopointdata except ImportError: raise ImportError('unable to import vmtksurfacecelldatatopointdata module') surfaceCellToPoint = vmtksurfacecelldatatopointdata.vmtkSurfaceCellDataToPointData() surfaceCellToPoint.Surface = self.Surface surfaceCellToPoint.Execute() self.PrintLog('wrapping vtkPolyData object') surfWrapper = dsa.WrapDataObject(surfaceCellToPoint.Surface) else: self.PrintLog('wrapping vtkPolyData object') surfWrapper = dsa.WrapDataObject(self.Surface) self.PrintLog('converting cell data: ') for cellKey in surfWrapper.CellData.keys(): self.PrintLog(cellKey) self.ArrayDict['CellData'][cellKey] = np.array(surfWrapper.CellData.GetArray(cellKey)) self.PrintLog('converting points') self.ArrayDict['Points'] = np.array(surfWrapper.Points) self.PrintLog('converting point data: ') for pointKey in surfWrapper.PointData.keys(): self.PrintLog(pointKey) self.ArrayDict['PointData'][pointKey] = np.array(surfWrapper.PointData.GetArray(pointKey)) if not surfWrapper.PointData.keys(): self.ArrayDict['PointData'] = {} self.PrintLog('converting cell connectivity list') numberOfCells = surfWrapper.VTKObject.GetNumberOfCells() numberOfPointsPerCell = surfWrapper.VTKObject.GetCell(0).GetNumberOfPoints() cellArray = np.zeros(shape=(numberOfCells, numberOfPointsPerCell), dtype=np.int32) it = np.nditer(cellArray, flags=['multi_index'], op_flags=['readwrite']) # this is an efficient ndarray iterator method. the loop "for x in it" pulls an element out of # the cellArray iterator (it) and with the elipses syntax (x[...]) writes the point id. # this is equivalent to writing # for cellId in range(numberOfCells): # cell = surfWrapper.VTKObject.GetCell(cellId) # for point in range(numberOfPointsPerCell): # cellArray[cellId, point] = cell.GetPointId(point) for x in it: x[...] = surfWrapper.VTKObject.GetCell(it.multi_index[0]).GetPointId(it.multi_index[1]) self.ArrayDict['CellData']['CellPointIds'] = cellArray
def Execute(self): if self.Centerlines == None: self.PrintError('Error: No input centerlines.') if self.ConvertCellToPoint == 1: self.PrintLog('converting cell data to point data') try: from vmtk import vmtksurfacecelldatatopointdata except ImportError: raise ImportError( 'unable to import vmtksurfacecelldata to point data module' ) centerlinesCellToPoint = vmtksurfacecelldatatopointdata.vmtkSurfaceCellDataToPointData( ) centerlinesCellToPoint.Surface = self.Centerlines centerlinesCellToPoint.Execute() self.PrintLog('wrapping vtkPolyData object') clWrapper = dsa.WrapDataObject(centerlinesCellToPoint.Surface) else: self.PrintLog('wrapping vtkPolyData object') clWrapper = dsa.WrapDataObject(self.Centerlines) self.PrintLog('converting cell data: ') for cellKey in clWrapper.CellData.keys(): self.PrintLog(cellKey) self.ArrayDict['CellData'][cellKey] = np.array( clWrapper.CellData.GetArray(cellKey)) self.PrintLog('converting points') self.ArrayDict['Points'] = np.array(clWrapper.Points) self.PrintLog('converting point data: ') for pointKey in clWrapper.PointData.keys(): self.PrintLog(pointKey) self.ArrayDict['PointData'][pointKey] = np.array( clWrapper.PointData.GetArray(pointKey)) self.PrintLog('converting cell connectivity list') cellPointIdsList = [] numberOfCells = clWrapper.VTKObject.GetNumberOfCells() for cellId in range(numberOfCells): cell = clWrapper.VTKObject.GetCell(cellId) numberOfPointsPerCell = cell.GetNumberOfPoints() cellArray = np.zeros(shape=numberOfPointsPerCell, dtype=np.int32) for point in range(numberOfPointsPerCell): cellArray[point] = cell.GetPointId(point) cellPointIdsList.append(cellArray) self.ArrayDict['CellData']['CellPointIds'] = cellPointIdsList
def Execute(self): if self.Centerlines == None: self.PrintError('Error: No input centerlines.') if self.ConvertCellToPoint == 1: self.PrintLog('converting cell data to point data') try: from vmtk import vmtksurfacecelldatatopointdata except ImportError: raise ImportError('unable to import vmtksurfacecelldata to point data module') centerlinesCellToPoint = vmtksurfacecelldatatopointdata.vmtkSurfaceCellDataToPointData() centerlinesCellToPoint.Surface = self.Centerlines centerlinesCellToPoint.Execute() self.PrintLog('wrapping vtkPolyData object') clWrapper = dsa.WrapDataObject(centerlinesCellToPoint.Surface) else: self.PrintLog('wrapping vtkPolyData object') clWrapper = dsa.WrapDataObject(self.Centerlines) self.PrintLog('converting cell data: ') for cellKey in clWrapper.CellData.keys(): self.PrintLog(cellKey) self.ArrayDict['CellData'][cellKey] = np.array(clWrapper.CellData.GetArray(cellKey)) self.PrintLog('converting points') self.ArrayDict['Points'] = np.array(clWrapper.Points) self.PrintLog('converting point data: ') for pointKey in clWrapper.PointData.keys(): self.PrintLog(pointKey) self.ArrayDict['PointData'][pointKey] = np.array(clWrapper.PointData.GetArray(pointKey)) self.PrintLog('converting cell connectivity list') cellPointIdsList = [] numberOfCells = clWrapper.VTKObject.GetNumberOfCells() for cellId in range(numberOfCells): cell = clWrapper.VTKObject.GetCell(cellId) numberOfPointsPerCell = cell.GetNumberOfPoints() cellArray = np.zeros(shape=numberOfPointsPerCell, dtype=np.int32) for point in range(numberOfPointsPerCell): cellArray[point] = cell.GetPointId(point) cellPointIdsList.append(cellArray) self.ArrayDict['CellData']['CellPointIds'] = cellPointIdsList
def centerline_pointdata(aorta_centerline_branches): ctp = celltopoint.vmtkSurfaceCellDataToPointData() ctp.Surface = aorta_centerline_branches ctp.Execute() return ctp.Surface
def centerline_pointdata(aorta_centerline_branches): ctp = celltopoint.vmtkSurfaceCellDataToPointData() ctp.Surface = aorta_centerline_branches ctp.Execute() return ctp.Surface