Exemplo n.º 1
0
        private void RenderImage()
        {
            //Get rid of any props already there
            if (imgProp != null)
            {
                m_Renderer.RemoveActor(imgProp);
                imgProp.Dispose();
                imgProp = null;
            }

            Kitware.VTK.vtkImageReader2 rdr =
                Kitware.VTK.vtkImageReader2Factory.CreateImageReader2(m_FileName);
            rdr.SetFileName(m_FileName);
            rdr.Update();
            imgProp = vtkImageActor.New();
            ((vtkImageActor)imgProp).SetInput(rdr.GetOutput());
            rdr.Dispose();

            m_Renderer.AddActor(imgProp);
            //Reset the camera to show the image
            //Equivilant of pressing 'r'
            m_Renderer.ResetCamera();
            //Rerender the screen
            //NOTE: sometimes you have to drag the mouse
            //a little before the image shows up
            renderWindowControl1.RenderWindow.Render();
            m_Renderer.Render();
        }
Exemplo n.º 2
0
        public new vtkImageReader2 NewInstance()
        {
            vtkImageReader2 result      = null;
            uint            mteStatus   = 0u;
            uint            mteIndex    = 4294967295u;
            uint            rawRefCount = 0u;
            IntPtr          intPtr      = vtkImageReader2.vtkImageReader2_NewInstance_37(base.GetCppThis(), ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                result = (vtkImageReader2)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
            }
            return(result);
        }
        public static vtkImageReader2 CreateImageReader2(string path)
        {
            vtkImageReader2 result      = null;
            uint            mteStatus   = 0u;
            uint            mteIndex    = 4294967295u;
            uint            rawRefCount = 0u;
            IntPtr          intPtr      = vtkImageReader2Factory.vtkImageReader2Factory_CreateImageReader2_01(path, ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                result = (vtkImageReader2)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
            }
            return(result);
        }
Exemplo n.º 4
0
        public vtkImageReader2 GetNextItem()
        {
            vtkImageReader2 vtkImageReader = null;
            uint            mteStatus      = 0u;
            uint            mteIndex       = 4294967295u;
            uint            rawRefCount    = 0u;
            IntPtr          intPtr         = vtkImageReader2Collection.vtkImageReader2Collection_GetNextItem_02(base.GetCppThis(), ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                vtkImageReader = (vtkImageReader2)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
                if (flag)
                {
                    vtkImageReader.Register(null);
                }
            }
            return(vtkImageReader);
        }
Exemplo n.º 5
0
        public new static vtkImageReader2 SafeDownCast(vtkObjectBase o)
        {
            vtkImageReader2 vtkImageReader = null;
            uint            mteStatus      = 0u;
            uint            mteIndex       = 4294967295u;
            uint            rawRefCount    = 0u;
            IntPtr          intPtr         = vtkImageReader2.vtkImageReader2_SafeDownCast_39((o == null) ? default(HandleRef) : o.GetCppThis(), ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                vtkImageReader = (vtkImageReader2)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
                if (flag)
                {
                    vtkImageReader.Register(null);
                }
            }
            return(vtkImageReader);
        }
        private void RenderImage()
        {
            Kitware.VTK.vtkImageReader2 rdr =
                Kitware.VTK.vtkImageReader2Factory.CreateImageReader2(m_FileName);
            rdr.SetFileName(m_FileName);
            rdr.Update();
            vtkProp3D imgProp = vtkImageActor.New();

            ((vtkImageActor)imgProp).SetInput(rdr.GetOutput());
            rdr.Dispose();

            imgPropList.Add(imgProp);
            m_Renderer.AddActor(imgProp);
            //Reset the camera to show the image
            //Equivilant of pressing 'r'
            m_Renderer.ResetCamera();
            //Rerender the screen
            m_RenderWindow.Render();
            m_Renderer.Render();
        }
Exemplo n.º 7
0
 public void AddItem(vtkImageReader2 arg0)
 {
     vtkImageReader2Collection.vtkImageReader2Collection_AddItem_01(base.GetCppThis(), (arg0 == null) ? default(HandleRef) : arg0.GetCppThis());
 }
 public static void RegisterReader(vtkImageReader2 r)
 {
     vtkImageReader2Factory.vtkImageReader2Factory_RegisterReader_07((r == null) ? default(HandleRef) : r.GetCppThis());
 }
Exemplo n.º 9
0
        /// <summary>
        /// Load an image with an open dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                // Get the name of the file you want to open from the dialog
                string fileName = openFileDialog1.FileName;

                vtkRenderer ren = (vtkRenderer)this.renderWindowControl1.RenderWindow.GetRenderers().GetItemAsObject(0);

                //Get rid of any props already there
                if (imgProp != null)
                {
                    ren.RemoveActor(imgProp);
                    imgProp.Dispose();
                    imgProp = null;
                }

                //Look at known file types to see if they are readable
                if (fileName.Contains(".png") ||
                    fileName.Contains(".jpg") ||
                    fileName.Contains(".jpeg") ||
                    fileName.Contains(".tif") ||
                    fileName.Contains(".slc") ||
                    fileName.Contains(".dicom") ||
                    fileName.Contains(".minc") ||
                    fileName.Contains(".bmp") ||
                    fileName.Contains(".pmn"))
                {
                    Kitware.VTK.vtkImageReader2 rdr =
                        Kitware.VTK.vtkImageReader2Factory.CreateImageReader2(fileName);
                    rdr.SetFileName(fileName);
                    rdr.Update();
                    imgProp = vtkImageActor.New();
                    ((vtkImageActor)imgProp).SetInputConnection(rdr.GetOutputPort());
                    rdr.Dispose();
                }

                //.vtk files need a DataSetReader instead of a ImageReader2
                //some .vtk files need a different kind of reader, but this
                //will read most and serve our purposes
                else if (fileName.Contains(".vtk"))
                {
                    vtkDataSetReader dataReader = vtkDataSetReader.New();
                    vtkDataSetMapper dataMapper = vtkDataSetMapper.New();
                    imgProp = vtkActor.New();
                    dataReader.SetFileName(fileName);
                    dataReader.Update();
                    dataMapper.SetInputConnection(dataReader.GetOutputPort());
                    ((vtkActor)imgProp).SetMapper(dataMapper);
                    dataMapper.Dispose();
                    dataMapper = null;
                    dataReader.Dispose();
                    dataReader = null;
                }
                else
                {
                    return;
                }
                ren.AddActor(imgProp);
                //Reset the camera to show the image
                //Equivilant of pressing 'r'
                ren.ResetCamera();
                //Rerender the screen
                //NOTE: sometimes you have to drag the mouse
                //a little before the image shows up
                renderWindowControl1.RenderWindow.Render();
                ren.Render();
            }
        }