我想删除立方体的黑色部分,只留下橙色。 但是我不知道怎么做。 我的代码在下面。
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
reader = vtk.vtkBMPReader()
reader.SetFilePrefix("C:/Users/tia chop/Documents/cttrung/")
reader.SetFilePattern("%s%d.bmp")
reader.SetFileNameSliceOffset(0)
#reader.SetFileNameSliceSpacing(1)
#reader.GetDataScalarType()
reader.SetDataSpacing(400,400,400)
reader.SetDataExtent(0,399,0,399,0,399)
reader.Update()
colors = vtk.vtkNamedColors()
colors.SetColor("BkgColor", [51, 77, 102, 255])
volumeMapper = vtk.vtkGPUVolumeRayCastMapper()
volumeMapper.SetInputConnection(reader.GetOutputPort())
volumeColor = vtk.vtkColorTransferFunction()
volumeColor.AddRGBPoint(500, 1.0, 0.5, 0.3)
volumeColor.AddRGBPoint(1000, 1.0, 0.5, 0.3)
volumeColor.AddRGBPoint(1150, 1.0, 1.0, 0.9)
volumeScalarOpacity = vtk.vtkPiecewiseFunction()
volumeScalarOpacity.AddPoint(0, 0.00)
volumeScalarOpacity.AddPoint(500, 0.1)
volumeScalarOpacity.AddPoint(1500, 0.15)
volumeScalarOpacity.AddPoint(2150, .9)
volumeGradientOpacity = vtk.vtkPiecewiseFunction()
volumeGradientOpacity.AddPoint(10, 0.0)
volumeGradientOpacity.AddPoint(100, 0.5)
volumeGradientOpacity.AddPoint(200, 1.0)
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(volumeColor)
volumeProperty.SetScalarOpacity(volumeScalarOpacity)
volumeProperty.SetInterpolationTypeToLinear()
volumeProperty.ShadeOn()
volumeProperty.SetAmbient(0.4)
volumeProperty.SetDiffuse(0.6)
volumeProperty.SetSpecular(0.2)
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)
self.ren.AddViewProp(volume)