VTK_DATA_ROOT = vtkGetDataRoot() if (catch.catch(globals(),"""channel = open("fullHead.tri", "w")""") == 0): channel.close() file.delete("-force", "fullHead.tri") file.delete("-force", "fullHead.lim") # reader reads slices v16 = vtk.vtkVolume16Reader() v16.SetDataDimensions(64,64) v16.SetDataByteOrderToLittleEndian() v16.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter") v16.SetDataSpacing(3.2,3.2,1.5) v16.SetImageRange(30,50) v16.SetDataMask(0x7fff) # write isosurface to file mcubes = vtk.vtkSliceCubes() mcubes.SetReader(v16) mcubes.SetValue(1150) mcubes.SetFileName("fullHead.tri") mcubes.SetLimitsFileName("fullHead.lim") mcubes.Update() # read from file reader = vtk.vtkMCubesReader() reader.SetFileName("fullHead.tri") reader.SetLimitsFileName("fullHead.lim") mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(reader.GetOutputPort()) head = vtk.vtkActor() head.SetMapper(mapper) head.GetProperty().SetColor(raw_sienna) # Create the RenderWindow, Renderer and Interactor
# try: channel = open("fullHead.tri", "wb") channel.close() # reader reads slices v16 = vtk.vtkVolume16Reader() v16.SetDataDimensions(64, 64) v16.SetDataByteOrderToLittleEndian() v16.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter") v16.SetDataSpacing(3.2, 3.2, 1.5) v16.SetImageRange(30, 50) v16.SetDataMask(0x7fff) # write isosurface to file mcubes = vtk.vtkSliceCubes() mcubes.SetReader(v16) mcubes.SetValue(1150) mcubes.SetFileName("fullHead.tri") mcubes.SetLimitsFileName("fullHead.lim") mcubes.Update() # read from file reader = vtk.vtkMCubesReader() reader.SetFileName("fullHead.tri") reader.SetLimitsFileName("fullHead.lim") mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(reader.GetOutputPort()) head = vtk.vtkActor() head.SetMapper(mapper) head.GetProperty().SetColor(GetRGBColor('raw_sienna'))
reader.SetFilePattern('%sslice_%04d.pgm') # print("setting image range") reader.SetImageRange(0, z_height * 2 - 1) # print("setting data spacing") reader.SetDataSpacing(1, 1, 1) # print("setting data dimensions") reader.SetDataDimensions(2 * w // binSize, 2 * w // binSize) # print("update") reader.SetFilePrefix(sliceDir) # print("running vtkSliceCubes") sc = vtk.vtkSliceCubes() sc.SetReader(reader) sc.SetFileName(isoDir + 'iso.tri') sc.SetLimitsFileName(isoDir + 'iso.lim') sc.SetValue(isoValue) sc.Update() # read from file # print("creating cube reader") mcReader = vtk.vtkMCubesReader() mcReader.SetFileName(isoDir + 'iso.tri') # print("creating limits file") mcReader.SetLimitsFileName(isoDir + 'iso.lim')