//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);
        }
예제 #2
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageStreamer(String [] argv)
    {
        //Prefix Content is: ""

        reader = new vtkImageReader();
        reader.ReleaseDataFlagOff();
        reader.SetDataByteOrderToLittleEndian();
        reader.SetDataExtent((int)0, (int)63, (int)0, (int)63, (int)1, (int)93);
        reader.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
        reader.SetDataMask((int)0x7fff);
        rangeStart = 0.0;
        rangeEnd   = 0.2;
        LUT        = new vtkLookupTable();
        LUT.SetTableRange((double)0, (double)1800);
        LUT.SetSaturationRange((double)1, (double)1);
        LUT.SetHueRange((double)rangeStart, (double)rangeEnd);
        LUT.SetValueRange((double)1, (double)1);
        LUT.SetAlphaRange((double)1, (double)1);
        LUT.Build();
        // added these unused default arguments so that the prototype[]
        // matches as required in python.[]
        //method moved
        mapToRGBA = new vtkImageMapToColors();
        mapToRGBA.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        mapToRGBA.SetOutputFormatToRGBA();
        mapToRGBA.SetLookupTable((vtkScalarsToColors)LUT);

        mapToRGBA.EndEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(changeLUT_Command.Execute);

        streamer = new vtkMemoryLimitImageDataStreamer();
        streamer.SetInputConnection((vtkAlgorithmOutput)mapToRGBA.GetOutputPort());
        streamer.SetMemoryLimit((uint)100);
        streamer.UpdateWholeExtent();
        // set the window/level to 255.0/127.5 to view full range[]
        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        viewer.SetColorWindow((double)255.0);
        viewer.SetColorLevel((double)127.5);
        viewer.SetZSlice((int)50);
        viewer.Render();

//deleteAllVTKObjects();
    }
예제 #3
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageStreamer(String [] argv)
    {
        //Prefix Content is: ""

          reader = new vtkImageReader();
          reader.ReleaseDataFlagOff();
          reader.SetDataByteOrderToLittleEndian();
          reader.SetDataExtent((int)0,(int)63,(int)0,(int)63,(int)1,(int)93);
          reader.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
          reader.SetDataMask((int)0x7fff);
          rangeStart = 0.0;
          rangeEnd = 0.2;
          LUT = new vtkLookupTable();
          LUT.SetTableRange((double)0,(double)1800);
          LUT.SetSaturationRange((double)1,(double)1);
          LUT.SetHueRange((double)rangeStart,(double)rangeEnd);
          LUT.SetValueRange((double)1,(double)1);
          LUT.SetAlphaRange((double)1,(double)1);
          LUT.Build();
          // added these unused default arguments so that the prototype[]
          // matches as required in python.[]
          //method moved
          mapToRGBA = new vtkImageMapToColors();
          mapToRGBA.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          mapToRGBA.SetOutputFormatToRGBA();
          mapToRGBA.SetLookupTable((vtkScalarsToColors)LUT);

          mapToRGBA.EndEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(changeLUT_Command.Execute);

          streamer = new vtkMemoryLimitImageDataStreamer();
          streamer.SetInputConnection((vtkAlgorithmOutput)mapToRGBA.GetOutputPort());
          streamer.SetMemoryLimit((uint)100);
          streamer.UpdateWholeExtent();
          // set the window/level to 255.0/127.5 to view full range[]
          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          viewer.SetColorWindow((double)255.0);
          viewer.SetColorLevel((double)127.5);
          viewer.SetZSlice((int)50);
          viewer.Render();

        //deleteAllVTKObjects();
    }
예제 #4
0
        private void ReadDEM()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test     = vtkTesting.New();
            string     root     = test.GetDataRoot();
            string     filePath = System.IO.Path.Combine(root, @"Data\SainteHelens.dem");

            vtkDEMReader reader = vtkDEMReader.New();

            reader.SetFileName(filePath);
            reader.Update();

            vtkLookupTable lut = vtkLookupTable.New();

            lut.SetHueRange(0.6, 0);
            lut.SetSaturationRange(1.0, 0);
            lut.SetValueRange(0.5, 1.0);
            double[] range = reader.GetOutput().GetScalarRange();
            lut.SetTableRange(range[0], range[1]);

            // Visualize
            vtkImageMapToColors mapColors = vtkImageMapToColors.New();

            mapColors.SetLookupTable(lut);
            mapColors.SetInputConnection(reader.GetOutputPort());

            // Create an actor
            vtkImageActor actor = vtkImageActor.New();

            actor.SetInput(mapColors.GetOutput());
            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            // renderer
            vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();

            // set background color
            renderer.SetBackground(0.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
        private void RenderDEM()
        {
            vtkDEMReader reader = vtkDEMReader.New();

            reader.SetFileName(m_FileName);
            reader.Update();

            vtkLookupTable lut = vtkLookupTable.New();

            lut.SetHueRange(0.6, 0);
            lut.SetSaturationRange(1.0, 0);
            lut.SetValueRange(0.5, 1.0);
            double[] range = reader.GetOutput().GetScalarRange();
            lut.SetTableRange(range[0], range[1]);

            // Visualize
            vtkImageMapToColors mapColors = vtkImageMapToColors.New();

            mapColors.SetLookupTable(lut);
            mapColors.SetInputConnection(reader.GetOutputPort());

            // Create an actor
            vtkImageActor actor = vtkImageActor.New();

            actor.SetInput(mapColors.GetOutput());

            // add our actor to the renderer
            m_Renderer.AddActor(actor);
            imgPropList.Add(actor);

            m_Renderer.ResetCamera();

            //Rerender the screen
            m_RenderWindow.Render();
            m_Renderer.Render();
        }
예제 #6
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetmapToRGBA(vtkImageMapToColors toSet)
 {
     mapToRGBA = toSet;
 }
예제 #7
0
        static public vtkProp3D genFieldActor(FieldBase data)
        {
            int    N_width = data.Ex.Count;
            int    M_depth = data.Ex.Count;
            double ds      = data.ds_x;
            double width   = N_width * ds;
            double depth   = M_depth * ds;

            vtkImageData img = vtkImageData.New();

            img.SetDimensions(N_width, M_depth, 1);
            img.SetSpacing(0.01 * ds / 0.01, 0.01 * ds / 0.01, 1);
            img.SetScalarTypeToDouble();
            img.SetNumberOfScalarComponents(1);

            double max = -100000000, min = 0;
            List <List <Complex> > tempEH = null;

            int          content          = 1;
            bool         isPhs            = false;
            bool         isLinear         = true;
            const double dB_RABNGE        = 60;

            switch (content)
            {
            case 0:
                tempEH = data.Ex;
                break;

            case 1:
                tempEH = data.Ey;
                break;

            case 2:
                tempEH = data.Ez;
                break;

            case 3:
                tempEH = data.Hx;
                break;

            case 4:
                tempEH = data.Hy;
                break;

            case 5:
                tempEH = data.Hz;
                break;

            default:
                break;
            }
            double[] data_tmp = new double[M_depth * N_width];
            int      count    = 0;

            for (int j = 0; j < M_depth; j++)
            {
                for (int i = 0; i < N_width; i++)
                {
                    double  tempD;
                    Complex temp;
                    temp = tempEH[i][j];

                    if (isPhs)
                    {
                        if (temp.real != 0)
                        {
                            tempD = Math.Atan2(temp.imag, temp.real);
                        }
                        else
                        {
                            tempD = 0;
                        }
                    }
                    else
                    {
                        tempD = Math.Pow((temp.real * temp.real + temp.imag * temp.imag), 0.5);
                    }
                    if (!isLinear && !isPhs)
                    {
                        tempD = 20 * Math.Log(tempD + 0.000000001);
                        if (min > tempD)
                        {
                            min = tempD;
                        }
                        if (max < tempD)
                        {
                            max = tempD;
                        }
                    }
                    else
                    {
                        if (max < tempD)
                        {
                            max = tempD;
                        }
                        if (min > tempD)
                        {
                            min = tempD;
                        }
                    }
                    data_tmp[count++] = tempD;
                }
            }

            //ptr = img.GetScalarPointer();
            vtkLookupTable colorTable = vtkLookupTable.New();

            if (!isLinear && !isPhs)
            {
                min = max - dB_RABNGE;
            }
            if (!isPhs)
            {
                for (int i = 0; i < N_width * M_depth * 1; i++)
                {
                    data_tmp[i] = max - data_tmp[i];
                }
                colorTable.SetRange(0, max - min);
            }
            else
            {
                colorTable.SetRange(min, max);
            }

            IntPtr ptr = img.GetScalarPointer();

            System.Runtime.InteropServices.Marshal.Copy(data_tmp, 0, ptr, M_depth * N_width);
            colorTable.Build();

            vtkImageMapToColors colorMap = vtkImageMapToColors.New();

            colorMap.SetInput(img);
            colorMap.SetLookupTable(colorTable);
            colorMap.Update();

            vtkTransform transform = vtkTransform.New();

            transform.Translate(data.coordinate.pos.x, data.coordinate.pos.y, data.coordinate.pos.z);
            transform.RotateWXYZ(data.coordinate.rotate_theta, data.coordinate.rotate_axis.x,
                                 data.coordinate.rotate_axis.y, data.coordinate.rotate_axis.z);
            transform.Translate(-width / 2, -depth / 2, 0);

            vtkImageActor actor = vtkImageActor.New();

            actor.SetInput(colorMap.GetOutput());
            actor.SetUserTransform(transform);

            return(actor);
        }
예제 #8
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetmapToRGBA(vtkImageMapToColors toSet)
 {
     mapToRGBA = toSet;
 }