[vtkusers] How to get an image-slice from vtkImplicitPlaneWidget

mailagentrus mailagentrus at mail.ru
Mon May 9 10:14:10 EDT 2011


Hello! I use code:

vtkImplicitPlaneWidget planeWidget = vtkImplicitPlaneWidget.New();
vtkRenderWindow renWin1 = renderWindowControl1.RenderWindow;

            vtkRenderer ren11 =
renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();

            renWin1.AddRenderer(ren11);
            iren1.SetRenderWindow(renWin1);



            vtkPlane plane = vtkPlane.New();
           

            vtkDICOMImageReader reader = vtkDICOMImageReader.New();
            reader.SetDataByteOrderToLittleEndian();
            reader.SetDirectoryName("C:\\go");
            vtkImageCast readerImageCast = vtkImageCast.New();
            readerImageCast.SetInput((vtkDataObject)reader.GetOutput());
            readerImageCast.SetOutputScalarTypeToUnsignedShort();
            readerImageCast.ClampOverflowOn();

            vtkPiecewiseFunction opacityTransferFunction =
vtkPiecewiseFunction.New();
            opacityTransferFunction.AddPoint(0, 0.0);
            opacityTransferFunction.AddPoint(80, 0.1);
            opacityTransferFunction.AddPoint(128, 0.2);
            opacityTransferFunction.AddPoint(200, 0.7);
            opacityTransferFunction.AddPoint(1150, 1.0);

            vtkColorTransferFunction colorTransferFunction =
vtkColorTransferFunction.New();
            colorTransferFunction.SetColorSpaceToRGB();
//ЙиЦГОЄrgbЈ¬ИзИфrgbИэёц·ЦБїПаµИЈ¬ФтОЄ»Т¶ИЦµ
            colorTransferFunction.AddRGBPoint(0, 0.0, 0.0, 0.0); 
            colorTransferFunction.AddRGBPoint(80, 1.0, 0.0, 0.0); 
            colorTransferFunction.AddRGBPoint(128, 0.2, 0.1, 0.0);
            colorTransferFunction.AddRGBPoint(200, 1.0, 1.0, 1.0);
            colorTransferFunction.AddRGBPoint(1150, 1.0, 1.0, 1.0);

            vtkVolumeProperty volumeProperty = vtkVolumeProperty.New();
            volumeProperty.SetColor(colorTransferFunction);
            volumeProperty.SetScalarOpacity(opacityTransferFunction);
            volumeProperty.ShadeOn();
            volumeProperty.SetInterpolationTypeToLinear();

            vtkVolumeRayCastCompositeFunction compositeFunction =
                vtkVolumeRayCastCompositeFunction.New();
            vtkVolumeRayCastMapper volumeMapper =
vtkVolumeRayCastMapper.New();
            volumeMapper.SetVolumeRayCastFunction(compositeFunction);
            volumeMapper.SetInput(readerImageCast.GetOutput());

           
            planeWidget.SetInteractor(iren1);
            planeWidget.SetPlaceFactor(1.25);
            planeWidget.SetInput((vtkDataSet)readerImageCast.GetOutput());
            planeWidget.PlaceWidget();
            planeWidget.GetPlane(plane);
            planeWidget.EndInteractionEvt += Posle;
            planeWidget.SetDrawPlane(1);
            planeWidget.On();
            
             volumeMapper.AddClippingPlane(plane);

            vtkVolume volume = vtkVolume.New();
            volume.SetMapper(volumeMapper);
            volume.SetProperty(volumeProperty);

            vtkCamera camera = vtkCamera.New();
            camera.SetViewUp(0, 0, 1);
            camera.SetPosition(0, 2, 0);
            camera.SetFocalPoint(0, 0, 0);
            camera.Dolly(1.8);

            ren11.AddVolume(volume);
            ren11.SetBackground(0.1, 0.2, 0.3);
             ren11.ResetCamera();
            renWin1.Render();

            iren1.Initialize();

But now, how to get an image from planeWidget? and how make
vtkImplicitPlaneWidget non white?
http://vtk.1045678.n5.nabble.com/file/n4381970/%D0%91%D0%B5%D0%B7%D1%8B%D0%BC%D1%8F%D0%BD%D0%BD%D1%8B%D0%B9.png 


--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-get-an-image-slice-from-vtkImplicitPlaneWidget-tp4381970p4381970.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list