示例#1
0
        public void VolumeRender(vtk.vtkImageData VoxelDatat)
        {
            VoxelData = VoxelDatat;
            renWin.AddRenderer(ren1);
            iren.SetRenderWindow(renWin);

            double[] inputRange = VoxelData.GetScalarRange();

            vtk.vtkPiecewiseFunction opacityTransferFunction = new vtk.vtkPiecewiseFunction();
            opacityTransferFunction.AddPoint(inputRange[0], 0);
            opacityTransferFunction.AddPoint(inputRange[1], 1);

            vtk.vtkColorTransferFunction colorTransferFunction = new vtk.vtkColorTransferFunction();
            colorTransferFunction.AddRGBPoint(inputRange[0], 1.0, 1.0, 1.0);
            colorTransferFunction.AddRGBPoint(inputRange[1], 1.0, 1.0, 1.0);

            volumeProperty.SetColor(colorTransferFunction);
            volumeProperty.SetScalarOpacity(opacityTransferFunction);
            volumeProperty.ShadeOff();
            volumeProperty.SetInterpolationTypeToLinear();

            volume.SetProperty(volumeProperty);

            setRAY();
            ren1.AddVolume(volume);
            ren1.ResetCamera();
            renWin.Render();
            addBusyObservers();
            iren.Initialize(); iren.Enable();
        }
示例#2
0
 public void setColorTransferFunction(vtk.vtkColorTransferFunction TransferFunction)
 {
     sColorsX.SetLookupTable(TransferFunction);
     sColorsY.SetLookupTable(TransferFunction);
     sColorsZ.SetLookupTable(TransferFunction);
     renWin.Render();
 }
示例#3
0
        public vtk.vtkColorTransferFunction getColorTransferFunction(bool enablealpha)
        {
            vtk.vtkColorTransferFunction TransferFunction = new vtk.vtkColorTransferFunction();
            double colorindex = 0; double alpha = 1; double per = 0;

            for (int i = 0; i < npoints; i++)
            {
                // Calulate color index and alpha from selected points
                per        = (double)pointsx[i] / (width - 1);
                colorindex = (1 - per) * inputRange[0] + per * inputRange[1];
                if (enablealpha)
                {
                    alpha = (double)pointsy[i] / height;
                }
                TransferFunction.AddRGBPoint(colorindex, alpha * colortable[pointsc[i], 0], alpha * colortable[pointsc[i], 1], alpha * colortable[pointsc[i], 2]);
            }
            return(TransferFunction);
        }
示例#4
0
 public void setColorTransferFunction(vtk.vtkColorTransferFunction TransferFunction)
 {
     volumeProperty.SetColor(TransferFunction);
     renWin.Render();
 }
示例#5
0
        public void render3Dplanes(vtk.vtkImageData VoxelData)
        {
            renWin.AddRenderer(ren2);

            iren.SetRenderWindow(renWin);

            vtk.vtkOutlineFilter outline = new vtk.vtkOutlineFilter();
            outline.SetInput(VoxelData);

            vtk.vtkPolyDataMapper outlineMapper = new vtk.vtkPolyDataMapper();
            outlineMapper.SetInputConnection(outline.GetOutputPort());

            vtk.vtkActor outlineActor = new vtk.vtkActor();
            outlineActor.SetMapper(outlineMapper);

            vtk.vtkCellPicker picker = new vtk.vtkCellPicker();
            picker.SetTolerance(0.005);

            vtk.vtkColorTransferFunction colorTransferFunction = new vtk.vtkColorTransferFunction();

            double[] inputRange = VoxelData.GetScalarRange();
            colorTransferFunction.AddRGBPoint(inputRange[0], 0.0, 0.0, 0.0);
            colorTransferFunction.AddRGBPoint(inputRange[1], 1.0, 1.0, 1.0);

            sColorsX.SetLookupTable(colorTransferFunction);
            sColorsY.SetLookupTable(colorTransferFunction);
            sColorsZ.SetLookupTable(colorTransferFunction);

            planeWidgetX.SetColorMap(sColorsX);
            planeWidgetX.SetInteractor(iren);
            planeWidgetX.DisplayTextOff();
            planeWidgetX.SetInput(VoxelData);
            planeWidgetX.SetPlaneOrientationToXAxes();
            planeWidgetX.SetSliceIndex(slizex);
            planeWidgetX.SetPicker(picker);
            planeWidgetX.On();
            planeWidgetX.InteractionOff();

            planeWidgetY.SetColorMap(sColorsY);
            planeWidgetY.SetInteractor(iren);
            planeWidgetY.DisplayTextOff();
            planeWidgetY.SetInput(VoxelData);
            planeWidgetY.SetPlaneOrientationToYAxes();
            planeWidgetY.SetSliceIndex(slizey);
            planeWidgetY.SetPicker(picker);
            planeWidgetY.On();
            planeWidgetY.InteractionOff();


            planeWidgetZ.SetColorMap(sColorsZ);
            planeWidgetZ.SetInteractor(iren);
            planeWidgetZ.DisplayTextOff();
            planeWidgetZ.SetInput(VoxelData);
            planeWidgetZ.SetPlaneOrientationToZAxes();
            planeWidgetZ.SetSliceIndex(slizez);
            planeWidgetZ.SetPicker(picker);
            planeWidgetZ.On();
            planeWidgetZ.InteractionOff();
            ren2.ResetCamera();
            renWin.Render();
            iren.Initialize(); iren.Enable();
        }
示例#6
0
        // Function: Calculate en render Histogram in window
        public void renderHistogram(vtk.vtkImageData VoxelData)
        {
            // Get size of histogram window
            int[] size = renHist.GetSize();
            width = size[0]; height = size[1];


            //Setup parameters histogram Accumulate Filter
            numBins    = width / 2;
            inputRange = VoxelData.GetScalarRange();
            double origin  = inputRange[0];
            double spacing = 1.0 * (inputRange[1] - origin) / numBins;

            // Setup Accumulate filter
            vtk.vtkImageAccumulate accumulate = new vtk.vtkImageAccumulate();
            accumulate.SetInput(VoxelData); //Get input voxeldata
            accumulate.SetComponentExtent(0, numBins - 1, 0, 0, 0, 0);
            accumulate.SetComponentOrigin(origin, 0.0, 0.0);
            accumulate.SetComponentSpacing(spacing, 1.0, 1.0);

            // Make Data object from Accumulated object
            data = accumulate.GetOutput();
            data.Update();

            // Initialize first and last point of the transferfunction.
            npoints    = 2;
            pointsx[0] = 0; pointsy[0] = 0;
            pointsx[1] = width - 1; pointsy[1] = height - 1;
            pointsc[0] = 1; pointsc[1] = 1;

            // Draw the histogram in a canvas and add the transferfunction to it
            drawhisto();
            drawcurve();

            // Create a color table
            vtk.vtkColorTransferFunction colorTransferFunction = new vtk.vtkColorTransferFunction();
            for (int i = 0; i < 14; i++)
            {
                colorTransferFunction.AddRGBPoint(i, colortable[i, 0], colortable[i, 1], colortable[i, 2]);
            }



            // Use the color table to color the histogram window objects
            vtk.vtkImageMapToColors sColors = new vtk.vtkImageMapToColors();
            sColors.SetInputConnection(canvas.GetOutputPort());
            sColors.SetLookupTable(colorTransferFunction);

            // Convert the histogram image to a histogram imagemap
            vtk.vtkImageMapper histmap = new vtk.vtkImageMapper();
            histmap.SetInputConnection(sColors.GetOutputPort());
            histmap.RenderToRectangleOn();
            histmap.SetColorWindow(256);
            histmap.SetColorLevel(127);

            // Create the actor needed to draw the histogram image
            vtk.vtkActor2D imageactor = new vtk.vtkActor2D();
            imageactor.SetMapper(histmap);
            imageactor.SetPosition(0, 0); // Fit the histogram to the window
            imageactor.SetPosition2(1, 1);

            // Add the Histogram Image Render to the window object
            ren1.AddActor(imageactor);
            ren1.SetViewport(0, 0, 1, 1); // Fit the histogram to the window
            renHist.AddRenderer(ren1);

            // Add a Window (mouse) interactor to the window
            iren.SetRenderWindow(renHist);

            // Add mouse events to the window
            iren.RemoveObserver((uint)vtk.EventIds.LeftButtonPressEvent);
            iren.AddObserver((uint)vtk.EventIds.LeftButtonPressEvent, new vtk.vtkDotNetCallback(LeftButtonPress));

            iren.RemoveObserver((uint)vtk.EventIds.LeftButtonReleaseEvent);
            iren.AddObserver((uint)vtk.EventIds.LeftButtonReleaseEvent, new vtk.vtkDotNetCallback(LeftButtonRelease));

            iren.RemoveObserver((uint)vtk.EventIds.MouseMoveEvent);
            iren.AddObserver((uint)vtk.EventIds.MouseMoveEvent, new vtk.vtkDotNetCallback(MouseMove));

            iren.RemoveObserver((uint)vtk.EventIds.RightButtonPressEvent);
            iren.AddObserver((uint)vtk.EventIds.RightButtonPressEvent, new vtk.vtkDotNetCallback(RightButtonPress));

            iren.RemoveObserver((uint)vtk.EventIds.MiddleButtonPressEvent);
            iren.AddObserver((uint)vtk.EventIds.MiddleButtonPressEvent, new vtk.vtkDotNetCallback(MiddleButtonPress));

            // Set the (display) update rate of the histogram
            iren.SetStillUpdateRate(5);
            iren.SetDesiredUpdateRate(5);

            // Initialize interactor and render histogram
            iren.Initialize();
            renHist.Render();

            // Debug output
            info = "Histogram is created \r\n";
        }