Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public void ShowVTKV3d()
        {
            renWin.AddRenderer(aRenderer);
            iren.SetRenderWindow(renWin);

            vtk.vtkSmoothPolyDataFilter smoother = new vtk.vtkSmoothPolyDataFilter();
            smoother.SetInputConnection(mc.GetOutputPort());
            smoother.SetRelaxationFactor(0.05);
            smoother.SetNumberOfIterations(30);

            vtk.vtkDecimatePro deci = new vtk.vtkDecimatePro();
            deci.SetInputConnection(smoother.GetOutputPort());
            deci.SetTargetReduction(0.9);
            deci.PreserveTopologyOn();
            deci.Update();

            int marchingNumberOfPoints = deci.GetOutput().GetNumberOfPoints();
            int marchingNumberOfPolys  = deci.GetOutput().GetNumberOfPolys();

            info += "marching number of points : " + marchingNumberOfPoints + "\r\n";
            info += "marching number of polys : " + marchingNumberOfPolys + "\r\n";

            vtk.vtkSmoothPolyDataFilter smoother2 = new vtk.vtkSmoothPolyDataFilter();
            smoother2.SetInputConnection(deci.GetOutputPort());
            smoother2.SetRelaxationFactor(0.05);
            smoother2.SetNumberOfIterations(30);

            mcmap.SetInputConnection(smoother2.GetOutputPort());
            mcmap.ScalarVisibilityOff();
            mcactor.SetMapper(mcmap);
            mcactor.GetProperty().SetColor(1, 1, 1);

            aRenderer.AddActor(mcactor);
            aRenderer.SetBackground(0.0f, 0.0f, 0.0f);
            aRenderer.ResetCamera();
            renWin.Render();
            addBusyObservers();
            iren.Initialize(); iren.Enable();
        }
Ejemplo n.º 3
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();
        }