void RenderSlicer()
        {
            //Create all the objects for the pipeline
            vtkXMLImageDataReader reader  = vtkXMLImageDataReader.New();
            vtkImageActor         iactor  = vtkImageActor.New();
            vtkImageClip          clip    = vtkImageClip.New();
            vtkContourFilter      contour = vtkContourFilter.New();
            vtkPolyDataMapper     mapper  = vtkPolyDataMapper.New();
            vtkActor actor = vtkActor.New();
            vtkInteractorStyleImage style = vtkInteractorStyleImage.New();

            vtkRenderer renderer = renderWindowControl2.RenderWindow.GetRenderers().GetFirstRenderer();

            //Read the Image
            reader.SetFileName(m_FileName);

            //Go through the visulization pipeline
            iactor.SetInput(reader.GetOutput());
            renderer.AddActor(iactor);
            reader.Update();
            int[] extent = reader.GetOutput().GetWholeExtent();
            iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3],
                                    (extent[4] + extent[5]) / 2,
                                    (extent[4] + extent[5]) / 2);

            clip.SetInputConnection(reader.GetOutputPort());
            clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3],
                                      (extent[4] + extent[5]) / 2,
                                      (extent[4] + extent[5]) / 2);

            contour.SetInputConnection(clip.GetOutputPort());
            contour.SetValue(0, 100);

            mapper.SetInputConnection(contour.GetOutputPort());
            mapper.SetScalarVisibility(1);

            //Go through the graphics pipeline
            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(0, 1, 0);

            renderer.AddActor(actor);

            //Give a new style to the interactor
            //vtkRenderWindowInteractor iren = renderWindowControl2.RenderWindow.GetInteractor();
            //iren.SetInteractorStyle(style);


            //Update global variables
            this.trackBar1.Maximum = extent[5];
            this.trackBar1.Minimum = extent[4];
            //this.Interactor = iren;
            this.m_SliceRenderWindow = renderWindowControl2.RenderWindow;
            this.m_SliceRenderer     = renderer;
            this.m_SliceClip         = clip;
            this.m_SliceImageActor   = iactor;

            renderer.ResetCamera();
            this.m_SliceRenderer.ResetCameraClippingRange();
            this.m_SliceRenderWindow.Render();
        }
        //wizualizacja 3d -----------------------------------------------------------------
        public Visualization3D(RenderWindowControl window, vtkDICOMImageReader dicomReader)
        {
            this.window       = window;
            this.dicomReader  = dicomReader;
            this.presetMapper = new PresetMapper();

            vtkRenderer renderer = window.RenderWindow.GetRenderers().GetFirstRenderer();

            vtkSmartVolumeMapper mapper = vtkSmartVolumeMapper.New();

            vol = vtkVolume.New();

            vtkLookupTable bwLut = vtkLookupTable.New();

            bwLut.SetTableRange(0, 2000);
            bwLut.SetSaturationRange(0, 0);
            bwLut.SetHueRange(0, 0);
            bwLut.SetValueRange(0, 1);
            bwLut.Build(); //effective built

            vtkImageMapToColors sagittalColors = vtkImageMapToColors.New();

            sagittalColors.SetInputConnection(dicomReader.GetOutputPort());
            sagittalColors.SetLookupTable(bwLut);
            sagittalColors.Update();
            vtkImageActor sagittal = vtkImageActor.New();

            sagittal.SetInput(sagittalColors.GetOutput());
            sagittal.SetDisplayExtent(117, 117, 0, 173, 1, 180);

            vtkImageReslice reslicer = vtkImageReslice.New();

            reslicer.SetResliceAxesDirectionCosines(1, 0, 0, 2, 0, 0, 0, 0, 0);

            mapper.SetInputConnection(dicomReader.GetOutputPort());

            this.setColorFunction();
            this.setOpacityFunction();
            this.setGradientOpacity();

            vol.SetMapper(mapper);

            renderer.AddActor(sagittal);
            renderer.AddVolume(vol);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Display the render window with the slice in it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            //Get the name of the Unsigned Char volume that you want to load
            fileName = "../../../head.vti";

            //Create all the objects for the pipeline
            vtkXMLImageDataReader reader  = vtkXMLImageDataReader.New();
            vtkImageActor         iactor  = vtkImageActor.New();
            vtkImageClip          clip    = vtkImageClip.New();
            vtkContourFilter      contour = vtkContourFilter.New();
            vtkPolyDataMapper     mapper  = vtkPolyDataMapper.New();
            vtkActor actor = vtkActor.New();
            vtkInteractorStyleImage style = vtkInteractorStyleImage.New();

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

            //Read the Image
            reader.SetFileName(fileName);

            //Go through the visulization pipeline
            iactor.SetInputData(reader.GetOutput());
            renderer.AddActor(iactor);
            reader.Update();
            int[] extent = reader.GetOutput().GetExtent();
            iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3],
                                    (extent[4] + extent[5]) / 2,
                                    (extent[4] + extent[5]) / 2);

            clip.SetInputConnection(reader.GetOutputPort());
            clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3],
                                      (extent[4] + extent[5]) / 2,
                                      (extent[4] + extent[5]) / 2);

            contour.SetInputConnection(clip.GetOutputPort());
            contour.SetValue(0, 100);

            mapper.SetInputConnection(contour.GetOutputPort());
            mapper.SetScalarVisibility(1);

            //Go through the graphics pipeline
            actor.SetMapper(mapper);
            actor.GetProperty().SetColor(0, 1, 0);

            renderer.AddActor(actor);

            //Give a new style to the interactor
            vtkRenderWindowInteractor iren = renderWindowControl1.RenderWindow.GetInteractor();

            iren.SetInteractorStyle(style);

            //Add new events to the interactor style
            style.LeftButtonPressEvt   += new vtkObject.vtkObjectEventHandler(iren_LeftButtonPressEvt);
            style.LeftButtonReleaseEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonReleaseEvt);
            style.MouseMoveEvt         += new vtkObject.vtkObjectEventHandler(iren_MouseMoveEvt);

            //Update global variables
            this.trackBar1.Maximum = extent[5];
            this.trackBar1.Minimum = extent[4];
            this.Interactor        = iren;
            this.RenderWindow      = renderWindowControl1.RenderWindow;
            this.Renderer          = renderer;
            this.Clip       = clip;
            this.ImageActor = iactor;
        }