コード例 #1
0
        private vtkProp CreateVolumeRendering()
        {
            _opacityTransferFunction = new vtkPiecewiseFunction();
            _opacityTransferFunction.ClampingOff();

            _colorTransferFunction = new vtkColorTransferFunction();
            _colorTransferFunction.SetColorSpaceToRGB();
            _colorTransferFunction.ClampingOff();

            SetOpacityTransferFunction();
            SetColorTransferFunction();

            vtkVolumeProperty volumeProperty = new vtkVolumeProperty();

            volumeProperty.ShadeOn();
            volumeProperty.SetInterpolationTypeToLinear();
            volumeProperty.SetColor(_colorTransferFunction);
            volumeProperty.SetScalarOpacity(_opacityTransferFunction);
            volumeProperty.SetDiffuse(0.7);
            volumeProperty.SetAmbient(0.1);
            volumeProperty.SetSpecular(.3);
            volumeProperty.SetSpecularPower(20);

            //vtkOpenGLVolumeTextureMapper2D volumeMapper = new vtkOpenGLVolumeTextureMapper2D();
            //vtkOpenGLVolumeTextureMapper3D volumeMapper = new vtkOpenGLVolumeTextureMapper3D();
            //volumeMapper.SetPreferredMethodToNVidia();
            //volumeMapper.SetSampleDistance(1.0f);
            //int supported = volumeMapper.IsRenderSupported(volumeProperty);

            vtkFixedPointVolumeRayCastMapper volumeMapper = new vtkFixedPointVolumeRayCastMapper();

            //vtkVolumeRayCastMapper volumeMapper = new vtkVolumeRayCastMapper();
            volumeMapper.SetInput(_volumeLayer.GetImageData());
            ////vtkVolumeRayCastCompositeFunction rayCastFunction = new vtkVolumeRayCastCompositeFunction();
            ////volumeMapper.SetVolumeRayCastFunction(rayCastFunction);
            //vtkVolumeRayCastIsosurfaceFunction rayCastFunction = new vtkVolumeRayCastIsosurfaceFunction();
            //volumeMapper.SetVolumeRayCastFunction(rayCastFunction);

            _vtkVolume = new vtkVolume();
            _vtkVolume.SetMapper(volumeMapper);
            _vtkVolume.SetProperty(volumeProperty);

            return(_vtkVolume);
        }
コード例 #2
0
ファイル: VolumeProp.cs プロジェクト: nhannd/Xian
		private vtkProp CreateVolumeRendering()
		{
			_opacityTransferFunction = new vtkPiecewiseFunction();
			_opacityTransferFunction.ClampingOff();

			_colorTransferFunction = new vtkColorTransferFunction();
			_colorTransferFunction.SetColorSpaceToRGB();
			_colorTransferFunction.ClampingOff();

			SetOpacityTransferFunction();
			SetColorTransferFunction();

			vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
			volumeProperty.ShadeOn();
			volumeProperty.SetInterpolationTypeToLinear();
			volumeProperty.SetColor(_colorTransferFunction);
			volumeProperty.SetScalarOpacity(_opacityTransferFunction);
			volumeProperty.SetDiffuse(0.7);
			volumeProperty.SetAmbient(0.1);
			volumeProperty.SetSpecular(.3);
			volumeProperty.SetSpecularPower(20);

			//vtkOpenGLVolumeTextureMapper2D volumeMapper = new vtkOpenGLVolumeTextureMapper2D();
			//vtkOpenGLVolumeTextureMapper3D volumeMapper = new vtkOpenGLVolumeTextureMapper3D();
			//volumeMapper.SetPreferredMethodToNVidia();
			//volumeMapper.SetSampleDistance(1.0f);
			//int supported = volumeMapper.IsRenderSupported(volumeProperty);

			vtkFixedPointVolumeRayCastMapper volumeMapper = new vtkFixedPointVolumeRayCastMapper();
			//vtkVolumeRayCastMapper volumeMapper = new vtkVolumeRayCastMapper();
			volumeMapper.SetInput(_volumeLayer.GetImageData());
			////vtkVolumeRayCastCompositeFunction rayCastFunction = new vtkVolumeRayCastCompositeFunction();
			////volumeMapper.SetVolumeRayCastFunction(rayCastFunction);
			//vtkVolumeRayCastIsosurfaceFunction rayCastFunction = new vtkVolumeRayCastIsosurfaceFunction();
			//volumeMapper.SetVolumeRayCastFunction(rayCastFunction);

			_vtkVolume = new vtkVolume();
			_vtkVolume.SetMapper(volumeMapper);
			_vtkVolume.SetProperty(volumeProperty);

			return _vtkVolume;
		}
コード例 #3
0
        /// <summary>
        /// Set up the new PlaneWidget.
        /// </summary>
        /// <param name="planeWidget">Plane to set up.</param>
        private void SetupPlane(PlaneWidget planeWidget)
        {
            planeWidget.DisplayTextOff();
            planeWidget.SetInput(_dicomLoader.GetOutput());
            planeWidget.SetPlaneOrientationToXAxes();
            planeWidget.SetSliceIndex(250);
            planeWidget.SetInteractor(_renderWindowInteractor);
            planeWidget.SetLeftButtonAction(99);
            planeWidget.SetRightButtonAction(0);
            planeWidget.SetMarginSizeX(0);
            planeWidget.SetMarginSizeY(0);

            planeWidget.GetMarginProperty().SetColor(1, 0, 0);
            planeWidget.GetSelectedPlaneProperty().SetOpacity(0);
            planeWidget.GetCursorProperty().SetOpacity(0);
            planeWidget.GetPlaneProperty().SetOpacity(0);

            vtkColorTransferFunction colors = vtkColorTransferFunction.New();

            if (planeWidget.Axis == Axis.X)
            {
                planeWidget.SetPlaneOrientationToXAxes();
                colors.AddRGBPoint(0, 1, 0, 0); //red
            }
            else if (planeWidget.Axis == Axis.Y)
            {
                planeWidget.SetPlaneOrientationToYAxes();
                colors.AddRGBPoint(0, 0, 1, 0);
            }
            else if (planeWidget.Axis == Axis.Z)
            {
                planeWidget.SetPlaneOrientationToZAxes();
                colors.AddRGBPoint(0, 0, 0, 1);
            }
            colors.SetAlpha(0.4);
            colors.SetColorSpaceToRGB();
            colors.Build();
            planeWidget.GetColorMap().SetLookupTable(colors);
        }