//普通模式_绘制
        private void DrawMode_Normal()
        {
            #region 体属性 vtkVolumeProperty
            //设定体数据的属性:不透明性和颜色值映射标量值
            vtkVolumeProperty volumeProperty = vtkVolumeProperty.New();
            volumeProperty.SetColor(m_ColorTransferFunction);
            volumeProperty.SetScalarOpacity(m_PiecewiseFunction);
            //设置插值类型
            volumeProperty.SetInterpolationTypeToNearest();
            volumeProperty.SetDiffuse(0.7);
            volumeProperty.SetAmbient(0.01);
            volumeProperty.SetSpecular(0.5);
            volumeProperty.SetSpecularPower(100);
            #endregion

            //绘制方法:体射线投射
            vtkVolumeRayCastCompositeFunction compositeFunction = vtkVolumeRayCastCompositeFunction.New();

            #region 体数据映射器 vtkVolumeRayCastMapper
            //体数据映射器
            vtkVolumeRayCastMapper volumeMapper = vtkVolumeRayCastMapper.New();
            volumeMapper.SetInput(m_ImageData);
            volumeMapper.SetVolumeRayCastFunction(compositeFunction);
            #endregion

            #region 体 vtkVolume
            //体
            vtkVolume volume = vtkVolume.New();
            volume.SetMapper(volumeMapper);
            volume.SetProperty(volumeProperty);
            #endregion

            //模型体放入Renerer
            m_Renderer.AddVolume(volume);
        }
Пример #2
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);
        }
Пример #3
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;
		}
Пример #4
0
        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);
        }