private static byte[] MipPixelDataFromVtkSlab(vtkImageData slabImageData) { #if true // Do our own MIP, albeit slowly int[] sliceDimensions = slabImageData.GetDimensions(); int sliceDataSize = sliceDimensions[0] * sliceDimensions[1]; IntPtr slabDataPtr = slabImageData.GetScalarPointer(); byte[] pixelData = MemoryManager.Allocate <byte>(sliceDataSize * sizeof(short)); // Init with first slice Marshal.Copy(slabDataPtr, pixelData, 0, sliceDataSize * sizeof(short)); // Walk through other slices, finding maximum unsafe { short *psSlab = (short *)slabDataPtr; fixed(byte *pbFrame = pixelData) { short *psFrame = (short *)pbFrame; for (int sliceIndex = 1; sliceIndex < sliceDimensions[2]; sliceIndex++) { for (int i = 0; i < sliceDataSize - 1; ++i) { int slabIndex = sliceIndex * sliceDataSize + i; if (psSlab[slabIndex] > psFrame[i]) { psFrame[i] = psSlab[slabIndex]; } } } } } return(pixelData); #else // Ideally we'd use VTK to do the MIP (MinIP, Average...) vtkVolumeRayCastMIPFunction mip = new vtkVolumeRayCastMIPFunction(); vtkVolumeRayCastMapper mapper = new vtkVolumeRayCastMapper(); mapper.SetVolumeRayCastFunction(mip); mapper.SetInput(slabImageData); //TODO: Need to figure out how to use mapper to output vtkImageData vtkImageAlgorithm algo = new vtkImageAlgorithm(); algo.SetInput(mapper.GetOutputDataObject(0)); using (vtkExecutive exec = mapper.GetExecutive()) { VtkHelper.RegisterVtkErrorEvents(exec); exec.Update(); // Note: These report no output port, must have to do something else to get mapper to give us data //return exec.GetOutputData(0); return(mapper.GetOutputDataObject(0)); } #endif }
private static byte[] CreatePixelDataFromVtkSlice(vtkImageData sliceImageData) { int[] sliceDimensions = sliceImageData.GetDimensions(); int sliceDataSize = sliceDimensions[0] * sliceDimensions[1]; IntPtr sliceDataPtr = sliceImageData.GetScalarPointer(); byte[] pixelData = MemoryManager.Allocate <byte>(sliceDataSize * sizeof(short)); Marshal.Copy(sliceDataPtr, pixelData, 0, sliceDataSize * sizeof(short)); return(pixelData); }
public short[] GetAllScalar() { int[] dimensions = _imageData.GetDimensions(); short[] ret = new short[dimensions[0] * dimensions[1] * dimensions[2]]; //return (short)imageData.GetScalarComponentAsDouble(x, y, z, 0); IntPtr abc1 = _imageData.GetArrayPointer(_vtkDataArray1, ConvertIntPtr(0, 0, 0)); Marshal.Copy(abc1, ret, 0, ret.Length); return(ret); }
/// <summary> /// Application Constructor /// </summary> public Form1() { InitializeComponent(); //Initialize the loading graphic System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream stream = ass.GetManifestResourceStream(ass.GetName().Name + ".logo.png"); //Read in the logo as a stream System.Drawing.Image img = Image.FromStream(stream); //Convert the System.Drawing.Image to Kitware.VTK.ImageData vtkImageData idata = vtkImageData.FromImage(img); logoActor = vtkImageActor.New(); logoActor.SetInput(idata); logoRenderer = vtkRenderer.New(); logoRenderer.AddActor(logoActor); //Look at the center of the logo instead of the default bottom right corner logoActor.SetOrigin((idata.GetDimensions()[0] / 2), (idata.GetDimensions()[1] / 2), 0); vtkCamera cam = logoRenderer.GetActiveCamera(); cam.SetFocalPoint(logoActor.GetCenter()[0], logoActor.GetCenter()[1], logoActor.GetCenter()[2]); cam.SetPosition(logoActor.GetCenter()[0], logoActor.GetCenter()[1], 900); }
private void GreedyTerrainDecimation() { // Create an image vtkImageData image = vtkImageData.New(); image.SetDimensions(3, 3, 1); image.SetNumberOfScalarComponents(1); image.SetScalarTypeToUnsignedChar(); int[] dims = image.GetDimensions(); unsafe { for (int i = 0; i < dims[0]; i++) { for (int j = 0; j < dims[1]; j++) { byte *ptr = (byte *)image.GetScalarPointer(i, j, 0); * ptr = (byte)vtkMath.Round(vtkMath.Random(0, 1)); } } } vtkGreedyTerrainDecimation decimation = vtkGreedyTerrainDecimation.New(); decimation.SetInputConnection(image.GetProducerPort()); decimation.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(decimation.GetOutputPort()); // actor vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetInterpolationToFlat(); actor.GetProperty().EdgeVisibilityOn(); actor.GetProperty().SetEdgeColor(1, 0, 0); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.2, 0.3, 0.4); // add our actor to the renderer renderer.AddActor(actor); }
void CreateVectorField(ref vtkImageData image) { // Specify the size of the image data image.SetDimensions(3, 3, 3); image.SetNumberOfScalarComponents(3); image.SetScalarTypeToFloat(); image.AllocateScalars(); image.SetSpacing(10.0, 10.0, 10.0); int[] dims = image.GetDimensions(); float[] pixel = new float[] { 0.0f, 0.0f, 0.0f }; IntPtr pPixel; // Zero the vectors for (int z = 0; z < dims[2]; z++) { for (int y = 0; y < dims[1]; y++) { for (int x = 0; x < dims[0]; x++) { pPixel = image.GetScalarPointer(x, y, 0); Marshal.Copy(pixel, 0, pPixel, 3); } } } // Set two of the pixels to non zero values pixel[0] = 8.0f; pixel[1] = 8.0f; pixel[2] = -8.0f; pPixel = image.GetScalarPointer(0, 2, 0); Marshal.Copy(pixel, 0, pPixel, 3); pixel[0] = 8.0f; pixel[1] = -8.0f; pixel[2] = 8.0f; pPixel = image.GetScalarPointer(2, 0, 2); Marshal.Copy(pixel, 0, pPixel, 3); }
private static byte[] ReadVtkImageData(vtkImageData imageData) { // get the pointer to the image data var pData = imageData.GetScalarPointer(); if (pData.Equals(IntPtr.Zero)) { return(null); } // get number of pixels in data var dataDimensions = imageData.GetDimensions(); var dataCount = dataDimensions[0] * dataDimensions[1] * dataDimensions[2]; // compute byte length of data var dataLength = dataCount * imageData.GetScalarSize(); // copy data to managed buffer var pixelData = MemoryManager.Allocate <byte>(dataLength); Marshal.Copy(pData, pixelData, 0, dataLength); return(pixelData); }
private static byte[] SlabVtkImageData(vtkImageData slabData, Action <IntPtr, byte[], int, int, int, bool> slabAggregator, int bitsPerVoxel, bool signed) { // get the pointer to the image data var pData = slabData.GetScalarPointer(); if (pData.Equals(IntPtr.Zero)) { return(null); } // get number of subsamples and pixels per subsample var dataDimensions = slabData.GetDimensions(); var subsamplePixels = dataDimensions[0] * dataDimensions[1]; var subsamples = dataDimensions[2]; // compute byte length of slabbed output data var dataLength = subsamplePixels * slabData.GetScalarSize(); // slab data to managed buffer var pixelData = MemoryManager.Allocate <byte>(dataLength); slabAggregator.Invoke(pData, pixelData, subsamples, subsamplePixels, bitsPerVoxel / 8, signed); return(pixelData); }
void CreateVectorField(ref vtkImageData image) { // Specify the size of the image data image.SetDimensions(3, 3, 3); image.SetNumberOfScalarComponents(3); image.SetScalarTypeToFloat(); image.AllocateScalars(); image.SetSpacing(10.0, 10.0, 10.0); int[] dims = image.GetDimensions(); float[] pixel = new float[] {0.0f, 0.0f, 0.0f}; IntPtr pPixel; // Zero the vectors for(int z = 0; z < dims[2]; z++) { for(int y = 0; y < dims[1]; y++) { for(int x = 0; x < dims[0]; x++) { pPixel = image.GetScalarPointer(x, y, 0); Marshal.Copy(pixel, 0, pPixel, 3); } } } // Set two of the pixels to non zero values pixel[0] = 8.0f; pixel[1] = 8.0f; pixel[2] = -8.0f; pPixel = image.GetScalarPointer(0, 2, 0); Marshal.Copy(pixel, 0, pPixel, 3); pixel[0] = 8.0f; pixel[1] = -8.0f; pixel[2] = 8.0f; pPixel = image.GetScalarPointer(2, 0, 2); Marshal.Copy(pixel, 0, pPixel, 3); }
private static byte[] MipPixelDataFromVtkSlab(vtkImageData slabImageData) { VtkHelper.StaticInitializationHack(); #if true // Do our own MIP, albeit slowly int[] sliceDimensions = slabImageData.GetDimensions(); int sliceDataSize = sliceDimensions[0] * sliceDimensions[1]; IntPtr slabDataPtr = slabImageData.GetScalarPointer(); byte[] pixelData = MemoryManager.Allocate<byte>(sliceDataSize * sizeof(short)); // Init with first slice Marshal.Copy(slabDataPtr, pixelData, 0, sliceDataSize * sizeof(short)); // Walk through other slices, finding maximum unsafe { short* psSlab = (short*) slabDataPtr; fixed (byte* pbFrame = pixelData) { short* psFrame = (short*)pbFrame; for (int sliceIndex = 1; sliceIndex < sliceDimensions[2]; sliceIndex++) { for (int i = 0; i < sliceDataSize-1; ++i) { int slabIndex = sliceIndex * sliceDataSize + i; if (psSlab[slabIndex] > psFrame[i]) psFrame[i] = psSlab[slabIndex]; } } } } return pixelData; #else // Ideally we'd use VTK to do the MIP (MinIP, Average...) vtkVolumeRayCastMIPFunction mip = new vtkVolumeRayCastMIPFunction(); vtkVolumeRayCastMapper mapper = new vtkVolumeRayCastMapper(); mapper.SetVolumeRayCastFunction(mip); mapper.SetInput(slabImageData); //TODO: Need to figure out how to use mapper to output vtkImageData vtkImageAlgorithm algo = new vtkImageAlgorithm(); algo.SetInput(mapper.GetOutputDataObject(0)); using (vtkExecutive exec = mapper.GetExecutive()) { VtkHelper.RegisterVtkErrorEvents(exec); exec.Update(); // Note: These report no output port, must have to do something else to get mapper to give us data //return exec.GetOutputData(0); return mapper.GetOutputDataObject(0); } #endif }
private static byte[] CreatePixelDataFromVtkSlice(vtkImageData sliceImageData) { int[] sliceDimensions = sliceImageData.GetDimensions(); int sliceDataSize = sliceDimensions[0]*sliceDimensions[1]; IntPtr sliceDataPtr = sliceImageData.GetScalarPointer(); if (sliceDataPtr.Equals(IntPtr.Zero)) return null; byte[] pixelData = MemoryManager.Allocate<byte>(sliceDataSize*sizeof (short)); Marshal.Copy(sliceDataPtr, pixelData, 0, sliceDataSize*sizeof (short)); return pixelData; }
private static byte[] SlabVtkImageData(vtkImageData slabData, Action<IntPtr, byte[], int, int, int, bool> slabAggregator, int bitsPerVoxel, bool signed) { // get the pointer to the image data var pData = slabData.GetScalarPointer(); if (pData.Equals(IntPtr.Zero)) return null; // get number of subsamples and pixels per subsample var dataDimensions = slabData.GetDimensions(); var subsamplePixels = dataDimensions[0]*dataDimensions[1]; var subsamples = dataDimensions[2]; // compute byte length of slabbed output data var dataLength = subsamplePixels*slabData.GetScalarSize(); // slab data to managed buffer var pixelData = MemoryManager.Allocate<byte>(dataLength); slabAggregator.Invoke(pData, pixelData, subsamples, subsamplePixels, bitsPerVoxel/8, signed); return pixelData; }
private static byte[] ReadVtkImageData(vtkImageData imageData) { // get the pointer to the image data var pData = imageData.GetScalarPointer(); if (pData.Equals(IntPtr.Zero)) return null; // get number of pixels in data var dataDimensions = imageData.GetDimensions(); var dataCount = dataDimensions[0]*dataDimensions[1]*dataDimensions[2]; // compute byte length of data var dataLength = dataCount*imageData.GetScalarSize(); // copy data to managed buffer var pixelData = MemoryManager.Allocate<byte>(dataLength); Marshal.Copy(pData, pixelData, 0, dataLength); return pixelData; }
private void WriteVTI() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); string filePath = System.IO.Path.Combine(root, @"Data\test_vti.vti"); vtkImageData imageData = vtkImageData.New(); imageData.SetDimensions(3, 4, 5); imageData.SetNumberOfScalarComponents(1); imageData.SetScalarTypeToDouble(); int[] dims = imageData.GetDimensions(); // Fill every entry of the image data with "2.0" /* we can do this in unsafe mode which looks pretty similar to the c++ version * but then you must declare at the very top of your file the "preprocessor" directive * #define UNSAFE * * or whatever name you choose for the following preprocessor #if statement */ #if UNSAFE unsafe { for (int z = 0; z < dims[2]; z++) { for (int y = 0; y < dims[1]; y++) { for (int x = 0; x < dims[0]; x++) { double *pixel = (double *)imageData.GetScalarPointer(x, y, z).ToPointer(); // c++ version: // double* pixel = static_cast<double*>(imageData->GetScalarPointer(x,y,z)); pixel[0] = 2.0; } } } } #else /* or we can do it in managed mode */ int size = imageData.GetScalarSize(); IntPtr ptr = Marshal.AllocHGlobal(size); for (int z = 0; z < dims[2]; z++) { for (int y = 0; y < dims[1]; y++) { for (int x = 0; x < dims[0]; x++) { ptr = imageData.GetScalarPointer(x, y, z); Marshal.Copy(new double[] { 2.0 }, 0, ptr, 1); } } } Marshal.FreeHGlobal(ptr); #endif vtkXMLImageDataWriter writer = vtkXMLImageDataWriter.New(); writer.SetFileName(filePath); writer.SetInputConnection(imageData.GetProducerPort()); writer.Write(); // Read and display file for verification that it was written correctly vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); if (reader.CanReadFile(filePath) == 0) { MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK); return; } reader.SetFileName(filePath); reader.Update(); // Convert the image to a polydata vtkImageDataGeometryFilter imageDataGeometryFilter = vtkImageDataGeometryFilter.New(); imageDataGeometryFilter.SetInputConnection(reader.GetOutputPort()); imageDataGeometryFilter.Update(); vtkDataSetMapper mapper = vtkDataSetMapper.New(); mapper.SetInputConnection(imageDataGeometryFilter.GetOutputPort()); // actor vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.GetProperty().SetPointSize(4); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(0.2, 0.3, 0.4); // add our actor to the renderer renderer.AddActor(actor); }
//切片模式_绘制 private void DrawMode_Slice() { int[] xyz = m_ImageData.GetDimensions(); double[] sp = m_ImageData.GetSpacing(); double[] pos = new double[] { m_XPos, m_YPos, m_ZPos }; #region -------------------XOY切片(垂直Z轴)------------------- m_ImageResliceXOY = vtkImageReslice.New(); m_ImageResliceXOY.SetInput(m_ImageData); m_ImageResliceXOY.SetResliceAxesDirectionCosines( 1, 0, 0, 0, 1, 0, 0, 0, 1 ); m_ImageResliceXOY.InterpolateOn(); m_ImageResliceXOY.SetInterpolationModeToNearestNeighbor(); m_ImageResliceXOY.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceXOY.SetOutputDimensionality(2); m_ImageResliceXOY.Update(); m_TextureXOY = vtkTexture.New(); m_TextureXOY.InterpolateOff(); m_TextureXOY.SetInput(m_ImageResliceXOY.GetOutput()); m_TextureXOY.SetLookupTable(m_LookupTable); m_TextureXOY.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position---------- m_PlaneSourceXOY = vtkPlaneSource.New(); m_PlaneSourceXOY.SetXResolution(xyz[0]); m_PlaneSourceXOY.SetYResolution(xyz[1]); m_PlaneSourceXOY.SetOrigin(0, 0, 0); m_PlaneSourceXOY.SetPoint1((xyz[0] - 1) * sp[0], 0, 0); m_PlaneSourceXOY.SetPoint2(0, (xyz[1] - 1) * sp[1], 0); m_PlaneSourceXOY.Push(pos[2]); //---------------------pipeline-------------------- m_PlaneMapperXOY = vtkPolyDataMapper.New(); m_PlaneMapperXOY.SetInput(m_PlaneSourceXOY.GetOutput()); m_ActorXOY = vtkActor.New(); m_ActorXOY.SetMapper(m_PlaneMapperXOY); m_ActorXOY.SetTexture(m_TextureXOY); #endregion #region -------------------XOZ切片(垂直Y轴)------------------- m_ImageResliceXOZ = vtkImageReslice.New(); m_ImageResliceXOZ.SetInput(m_ImageData); m_ImageResliceXOZ.SetResliceAxesDirectionCosines( 1, 0, 0, 0, 0, -1, 0, 1, 0 ); m_ImageResliceXOZ.InterpolateOn(); m_ImageResliceXOZ.SetInterpolationModeToNearestNeighbor(); m_ImageResliceXOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceXOZ.SetOutputDimensionality(2); m_ImageResliceXOZ.Update(); m_TextureXOZ = vtkTexture.New(); m_TextureXOZ.SetInput(m_ImageResliceXOZ.GetOutput()); m_TextureXOZ.SetLookupTable(m_LookupTable); m_TextureXOZ.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position-------------------- m_PlaneSourceXOZ = vtkPlaneSource.New(); m_PlaneSourceXOZ.SetXResolution(xyz[0]); m_PlaneSourceXOZ.SetYResolution(xyz[2]); m_PlaneSourceXOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceXOZ.SetPoint1((xyz[0] - 1) * sp[0], 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceXOZ.SetPoint2(0, 0, 0); m_PlaneSourceXOZ.Push(pos[1]); //---------------------pipeline------------------------------ m_PlaneMapperXOZ = vtkPolyDataMapper.New(); m_PlaneMapperXOZ.SetInput(m_PlaneSourceXOZ.GetOutput()); m_ActorXOZ = vtkActor.New(); m_ActorXOZ.SetMapper(m_PlaneMapperXOZ); m_ActorXOZ.SetTexture(m_TextureXOZ); #endregion #region -------------------YOZ切片(垂直X轴)------------------- m_ImageResliceYOZ = vtkImageReslice.New(); m_ImageResliceYOZ.SetInput(m_ImageData); m_ImageResliceYOZ.SetResliceAxesDirectionCosines( 0, 0, -1, 0, 1, 0, 1, 0, 0 ); m_ImageResliceYOZ.InterpolateOn(); m_ImageResliceYOZ.SetInterpolationModeToNearestNeighbor(); m_ImageResliceYOZ.SetResliceAxesOrigin(pos[0], pos[1], pos[2]); m_ImageResliceYOZ.SetOutputDimensionality(2); m_ImageResliceYOZ.Update(); m_TextureYOZ = vtkTexture.New(); m_TextureYOZ.SetInput(m_ImageResliceYOZ.GetOutput()); m_TextureYOZ.SetLookupTable(m_LookupTable); m_TextureYOZ.MapColorScalarsThroughLookupTableOn(); //---------------------set plane position-------------------- m_PlaneSourceYOZ = vtkPlaneSource.New(); m_PlaneSourceYOZ.SetXResolution(xyz[2]); m_PlaneSourceYOZ.SetYResolution(xyz[1]); m_PlaneSourceYOZ.SetOrigin(0, 0, (xyz[2] - 1) * sp[2]); m_PlaneSourceYOZ.SetPoint1(0, 0, 0); m_PlaneSourceYOZ.SetPoint2(0, (xyz[1] - 1) * sp[1], (xyz[2] - 1) * sp[2]); m_PlaneSourceYOZ.Push(pos[0]); //---------------------pipeline------------------------------ m_PlaneMapperYOZ = vtkPolyDataMapper.New(); m_PlaneMapperYOZ.SetInput(m_PlaneSourceYOZ.GetOutput()); m_ActorYOZ = vtkActor.New(); m_ActorYOZ.SetMapper(m_PlaneMapperYOZ); m_ActorYOZ.SetTexture(m_TextureYOZ); #endregion m_Renderer.AddActor(m_ActorXOY); m_Renderer.AddActor(m_ActorXOZ); m_Renderer.AddActor(m_ActorYOZ); }
public cVolumeRendering3D(vtkImageData imageData, cPoint3D Pos) { baseInit(null); vtk_volume = vtkVolume.New(); // vtkFloatArray floatArray = vtkFloatArray.New(); //vtkCharArray charArray = vtkCharArray.New(); // vtkUnsignedShortArray UshortArray = vtkUnsignedShortArray.New(); vtkExtractVOI voi = vtkExtractVOI.New(); // vtkPiecewiseFunction opacityTransferFunction = vtkPiecewiseFunction.New(); vtkColorTransferFunction colorTransferFunction = vtkColorTransferFunction.New(); vtkVolumeProperty volumeProperty = vtkVolumeProperty.New(); // imageData.GetPointData().SetScalars(UshortArray); voi = vtkExtractVOI.New(); voi.SetInput(imageData); voi.SetVOI(0, imageData.GetDimensions()[0] - 1, 0, imageData.GetDimensions()[1] - 1, 0, imageData.GetDimensions()[2] - 1); voi.SetSampleRate(1, 1, 1); opacityTransferFunction = vtkPiecewiseFunction.New(); range = imageData.GetScalarRange(); opacityTransferFunction.AddPoint(100, 0.0); opacityTransferFunction.AddPoint(1000, 1); //opacityTransferFunction.AddPoint(range[0] + (range[1]-range[0])/2.0, 0.0); //opacityTransferFunction.AddPoint(range[1], 0.7); ////Scale the image between 0 and 1 using a lookup table //vtkLookupTable table = vtkLookupTable.New(); //table.SetValueRange(0,1); //table.SetSaturationRange(0,0); //table.SetRange(range[0], range[1]); //shoul here not be the minimum/maximum possible of "data"? //table.SetRampToLinear(); //table.Build(); //vtkImageMapToColors color = vtkImageMapToColors.New(); //color.SetLookupTable(table); //color.SetInputConnection(imageData.GetProducerPort()); vtkColorTransferFunction ColorTransferFunction = vtkColorTransferFunction.New(); ColorTransferFunction.AddRGBPoint(20.0, 0.0, 0.0, 1.0); ColorTransferFunction.AddRGBPoint(255.0, 1.0, 0.0, 0.0); //ColorTransferFunction.AddRGBPoint(1000.0, 0.8, 0.5, 0.0); //opacityTransferFunction.ClampingOff(); volumeProperty = vtkVolumeProperty.New(); volumeProperty.SetColor(colorTransferFunction); volumeProperty.SetScalarOpacity(opacityTransferFunction); volumeProperty.SetInterpolationTypeToLinear(); volumeProperty.ShadeOn(); volumeProperty.SetAmbient(0.6); volumeProperty.SetDiffuse(0.6); volumeProperty.SetSpecular(0.1); //volumeProperty.SetAmbient(0.1); //volumeProperty.SetDiffuse(0.9); //volumeProperty.SetSpecular(0.2); //volumeProperty.SetSpecularPower(10.0); //volumeProperty[band].SetScalarOpacityUnitDistance(0.8919); vtkVolumeTextureMapper3D volumeTextureMapper = vtkVolumeTextureMapper3D.New(); ////volumeTextureMapper.SetInputConnection(color.GetOutputPort()); volumeTextureMapper.SetInputConnection(voi.GetOutputPort()); //vtkVolumeRayCastCompositeFunction compositeFunction = vtkVolumeRayCastCompositeFunction.New(); //vtkVolumeRayCastMapper volumeMapper = vtkVolumeRayCastMapper.New(); //volumeMapper.SetVolumeRayCastFunction(compositeFunction); //volumeMapper.SetInputConnection(voi.GetOutputPort()); vtk_volume = vtkVolume.New(); vtk_volume.SetMapper(volumeTextureMapper); vtk_volume.SetProperty(volumeProperty); vtk_volume.PickableOff(); vtk_volume.SetPosition(Pos.X, Pos.Y, Pos.Z); }