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

            vtkDataSetReader dataReader = vtkDataSetReader.New();
            vtkDataSetMapper dataMapper = vtkDataSetMapper.New();

            imgProp = vtkActor.New();
            dataReader.SetFileName(m_FileName);
            dataReader.Update();
            dataMapper.SetInput(dataReader.GetOutput());
            ((vtkActor)imgProp).SetMapper(dataMapper);
            dataMapper.Dispose();
            dataMapper = null;
            dataReader.Dispose();
            dataReader = null;

            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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clean up the global variables
        /// </summary>
        public void DeleteAllVTKObjects()
        {
            animalActor.Dispose();
            deciAnimalActor.Dispose();
            eyeActor1.Dispose();
            eyeActor2.Dispose();
            deciEyeActor1.Dispose();
            deciEyeActor2.Dispose();
            textAfter.Dispose();
            textBefore.Dispose();

            deciAnimalMapper.Dispose();
            deciEyeMapper1.Dispose();
            deciEyeMapper2.Dispose();
            cleanAnimal.Dispose();
            smoothAnimal.Dispose();
            normalsAnimal.Dispose();
            triangleAnimal.Dispose();
            decimateAnimal.Dispose();

            animalMapper.Dispose();
            eyeMapper1.Dispose();
            eyeMapper2.Dispose();
            clean.Dispose();
            smooth.Dispose();
            normals.Dispose();
            triangles.Dispose();
            decimate.Dispose();

            rabbitReader.Dispose();
            eyeReader.Dispose();
            rabbitColorReader.Dispose();
            eyeColorReader.Dispose();
            squirrelReader.Dispose();
            squirrelEyeReader.Dispose();
            squirrelEyeReader2.Dispose();
            squirrelColorReader.Dispose();
            squirrelEyeColorReader.Dispose();
            squirrelEyeColorReader2.Dispose();
            flyingSquirrelReader.Dispose();
            flyingSquirreleyeReader.Dispose();
            flyingSquirrelColorReader.Dispose();
            flyingSquirrelEyeColorReader.Dispose();
            chinchillaReader.Dispose();
            chinchillaEyeReader.Dispose();
            chinchillaColorReader.Dispose();
            chinchillaEyeColorReader.Dispose();
        }
Ejemplo n.º 3
0
 ///<summary>Deletes all static objects created</summary>
 public static void deleteAllVTKObjects()
 {
     //clean up vtk objects
     if (reader != null)
     {
         reader.Dispose();
     }
     if (elev != null)
     {
         elev.Dispose();
     }
     if (outline != null)
     {
         outline.Dispose();
     }
     if (outlineMapper != null)
     {
         outlineMapper.Dispose();
     }
     if (outlineActor != null)
     {
         outlineActor.Dispose();
     }
     if (ren1 != null)
     {
         ren1.Dispose();
     }
     if (renWin != null)
     {
         renWin.Dispose();
     }
     if (iren != null)
     {
         iren.Dispose();
     }
     if (cam1 != null)
     {
         cam1.Dispose();
     }
 }
        private void RenderVTK()
        {
            vtkDataSetReader dataReader = vtkDataSetReader.New();
            vtkDataSetMapper dataMapper = vtkDataSetMapper.New();
            vtkProp3D        imgProp    = vtkActor.New();

            dataReader.SetFileName(m_FileName);
            dataReader.Update();
            dataMapper.SetInput(dataReader.GetOutput());
            ((vtkActor)imgProp).SetMapper(dataMapper);
            dataMapper.Dispose();
            dataMapper = null;
            dataReader.Dispose();
            dataReader = null;

            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();
        }
Ejemplo n.º 5
0
        public void ImportVTK()
        {
            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.myRenderWindowControl.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"))
                {
                    vtkImageReader2 rdr = vtkImageReader2Factory.CreateImageReader2(fileName);
                    rdr.SetFileName(fileName);
                    rdr.Update();
                    imgProp = vtkImageActor.New();

                    ((vtkImageActor)imgProp).SetInput(rdr.GetOutput());
                    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") || fileName.Contains(".VTK"))
                {
                    vtkDataSetReader dataReader = vtkDataSetReader.New();
                    dataReader.SetFileName(fileName);
                    dataReader.Update();

                    vtkDataSetMapper dataMapper = vtkDataSetMapper.New();
                    dataMapper.SetInput(dataReader.GetOutput());

                    imgProp = vtkActor.New();
                    ((vtkActor)imgProp).SetMapper(dataMapper);

                    dataMapper.Dispose();
                    dataMapper = null;

                    dataReader.Dispose();
                    dataReader = null;
                }
                else
                {
                    return;
                }

                ren.RemoveAllViewProps();
                ren.AddActor(imgProp);
                ren.ResetCamera();
                ren.SetBackground(0.0, 0.46, 0.5);

                //Rerender the screen
                //NOTE: sometimes you have to drag the mouse
                //a little before the image shows up
                ren.Render();
                myRenderWindowControl.RenderWindow.Render();
                myRenderWindowControl.Refresh();
            }
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
 ///<summary>Deletes all static objects created</summary>
 public static void deleteAllVTKObjects()
 {
     //clean up vtk objects
     if (reader != null)
     {
         reader.Dispose();
     }
     if (toRectilinearGrid != null)
     {
         toRectilinearGrid.Dispose();
     }
     if (plane != null)
     {
         plane.Dispose();
     }
     if (warper != null)
     {
         warper.Dispose();
     }
     if (planeMapper != null)
     {
         planeMapper.Dispose();
     }
     if (planeActor != null)
     {
         planeActor.Dispose();
     }
     if (cutPlane != null)
     {
         cutPlane.Dispose();
     }
     if (planeCut != null)
     {
         planeCut.Dispose();
     }
     if (cutMapper != null)
     {
         cutMapper.Dispose();
     }
     if (cutActor != null)
     {
         cutActor.Dispose();
     }
     if (iso != null)
     {
         iso.Dispose();
     }
     if (normals != null)
     {
         normals.Dispose();
     }
     if (isoMapper != null)
     {
         isoMapper.Dispose();
     }
     if (isoActor != null)
     {
         isoActor.Dispose();
     }
     if (streamer != null)
     {
         streamer.Dispose();
     }
     if (streamTube != null)
     {
         streamTube.Dispose();
     }
     if (mapStreamTube != null)
     {
         mapStreamTube.Dispose();
     }
     if (streamTubeActor != null)
     {
         streamTubeActor.Dispose();
     }
     if (outline != null)
     {
         outline.Dispose();
     }
     if (outlineMapper != null)
     {
         outlineMapper.Dispose();
     }
     if (outlineActor != null)
     {
         outlineActor.Dispose();
     }
     if (ren1 != null)
     {
         ren1.Dispose();
     }
     if (renWin != null)
     {
         renWin.Dispose();
     }
     if (iren != null)
     {
         iren.Dispose();
     }
     if (cam1 != null)
     {
         cam1.Dispose();
     }
 }
Ejemplo n.º 8
0
 ///<summary>Deletes all static objects created</summary>
 public static void deleteAllVTKObjects()
 {
     //clean up vtk objects
     if (ren1 != null)
     {
         ren1.Dispose();
     }
     if (renWin != null)
     {
         renWin.Dispose();
     }
     if (iren != null)
     {
         iren.Dispose();
     }
     if (ptLoad != null)
     {
         ptLoad.Dispose();
     }
     if (wSP != null)
     {
         wSP.Dispose();
     }
     if (rSP != null)
     {
         rSP.Dispose();
     }
     if (input != null)
     {
         input.Dispose();
     }
     if (s1 != null)
     {
         s1.Dispose();
     }
     if (lut != null)
     {
         lut.Dispose();
     }
     if (s1Mapper != null)
     {
         s1Mapper.Dispose();
     }
     if (s1Actor != null)
     {
         s1Actor.Dispose();
     }
     if (s2 != null)
     {
         s2.Dispose();
     }
     if (s2Mapper != null)
     {
         s2Mapper.Dispose();
     }
     if (s2Actor != null)
     {
         s2Actor.Dispose();
     }
     if (s3 != null)
     {
         s3.Dispose();
     }
     if (s3Mapper != null)
     {
         s3Mapper.Dispose();
     }
     if (s3Actor != null)
     {
         s3Actor.Dispose();
     }
     if (s4 != null)
     {
         s4.Dispose();
     }
     if (s4Mapper != null)
     {
         s4Mapper.Dispose();
     }
     if (s4Actor != null)
     {
         s4Actor.Dispose();
     }
     if (g != null)
     {
         g.Dispose();
     }
     if (gm != null)
     {
         gm.Dispose();
     }
     if (ga != null)
     {
         ga.Dispose();
     }
     if (outline != null)
     {
         outline.Dispose();
     }
     if (outlineMapper != null)
     {
         outlineMapper.Dispose();
     }
     if (outlineActor != null)
     {
         outlineActor.Dispose();
     }
     if (coneSrc != null)
     {
         coneSrc.Dispose();
     }
     if (coneMap != null)
     {
         coneMap.Dispose();
     }
     if (coneActor != null)
     {
         coneActor.Dispose();
     }
     if (camera != null)
     {
         camera.Dispose();
     }
 }
Ejemplo n.º 9
0
 ///<summary>Deletes all static objects created</summary>
 public static void deleteAllVTKObjects()
 {
     //clean up vtk objects
     if (reader != null)
     {
         reader.Dispose();
     }
     if (ds2do != null)
     {
         ds2do.Dispose();
     }
     if (writer != null)
     {
         writer.Dispose();
     }
     if (dor != null)
     {
         dor.Dispose();
     }
     if (do2ds != null)
     {
         do2ds.Dispose();
     }
     if (fd2ad != null)
     {
         fd2ad.Dispose();
     }
     if (plane != null)
     {
         plane.Dispose();
     }
     if (warper != null)
     {
         warper.Dispose();
     }
     if (planeMapper != null)
     {
         planeMapper.Dispose();
     }
     if (planeActor != null)
     {
         planeActor.Dispose();
     }
     if (cutPlane != null)
     {
         cutPlane.Dispose();
     }
     if (planeCut != null)
     {
         planeCut.Dispose();
     }
     if (cutMapper != null)
     {
         cutMapper.Dispose();
     }
     if (cutActor != null)
     {
         cutActor.Dispose();
     }
     if (iso != null)
     {
         iso.Dispose();
     }
     if (normals != null)
     {
         normals.Dispose();
     }
     if (isoMapper != null)
     {
         isoMapper.Dispose();
     }
     if (isoActor != null)
     {
         isoActor.Dispose();
     }
     if (streamer != null)
     {
         streamer.Dispose();
     }
     if (streamTube != null)
     {
         streamTube.Dispose();
     }
     if (mapStreamTube != null)
     {
         mapStreamTube.Dispose();
     }
     if (streamTubeActor != null)
     {
         streamTubeActor.Dispose();
     }
     if (outline != null)
     {
         outline.Dispose();
     }
     if (outlineMapper != null)
     {
         outlineMapper.Dispose();
     }
     if (outlineActor != null)
     {
         outlineActor.Dispose();
     }
     if (ren1 != null)
     {
         ren1.Dispose();
     }
     if (renWin != null)
     {
         renWin.Dispose();
     }
     if (iren != null)
     {
         iren.Dispose();
     }
 }