Ejemplo n.º 1
0
        /// <summary>
        /// Loads the Squirrel model and textures
        /// into the algorithms and textures
        /// </summary>
        public void loadSquirrel()
        {
            //Set a predefined position for the eyes
            //that matches the .blend file
            eyeX = 0.076;
            eyeY = -0.178;
            eyeZ = 0.675;

            //load the squirrel model and textures if
            //they are not already loaded
            if (!squirrelLoaded)
            {
                squirrelReader.SetFileName("../../../models/squirrel.vtk");
                squirrelReader.Update();
                squirrelEyeReader.SetFileName("../../../models/squirrel_eyeR.vtk");
                squirrelEyeReader.Update();
                squirrelEyeReader2.SetFileName("../../../models/squirrel_eyeL.vtk");
                squirrelEyeReader2.Update();
                squirrelColorReader.SetFileName("../../../textures/squirrel_skin_col.png");
                squirrelColorReader.Update();
                squirrelEyeColorReader.SetFileName("../../../textures/squirrel_eyeR.png");
                squirrelEyeColorReader.Update();
                squirrelEyeColorReader2.SetFileName("../../../textures/squirrel_eyeL.png");
                squirrelEyeColorReader2.Update();
                squirrelLoaded = true;
            }

            //Set the algorithms and textures to the
            //ouput of the readers
            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInputConnection(squirrelEyeColorReader.GetOutputPort());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInputConnection(squirrelEyeColorReader.GetOutputPort());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInputConnection(squirrelEyeColorReader2.GetOutputPort());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInputConnection(squirrelEyeColorReader2.GetOutputPort());

            animalColorTexture.InterpolateOn();
            animalColorTexture.SetInputConnection(squirrelColorReader.GetOutputPort());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInputConnection(squirrelColorReader.GetOutputPort());

            eyeData2 = squirrelEyeReader2.GetOutputPort();
            eyeData1 = squirrelEyeReader.GetOutputPort();

            animalData = squirrelReader.GetOutputPort();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the Chinchilla model and textures
        /// into the algorithms and textures
        /// </summary>
        public void loadChinchilla()
        {
            //Set a predefined position for the eyes
            //that matches the .blend file
            eyeX = 0.052;
            eyeY = -0.144;
            eyeZ = 0.424;

            //load the chinchilla model and textures if
            //they are not already loaded
            if (!chinchillaLoaded)
            {
                chinchillaReader.SetFileName("../../../models/chinchilla.vtk");
                chinchillaReader.Update();
                chinchillaEyeReader.SetFileName("../../../models/chinchilla_eye.vtk");
                chinchillaEyeReader.Update();
                chinchillaColorReader.SetFileName("../../../textures/chinchilla_skin_col.png");
                chinchillaColorReader.Update();
                chinchillaEyeColorReader.SetFileName("../../../textures/chinchilla_eye.png");
                chinchillaEyeColorReader.Update();
                chinchillaLoaded = true;
            }

            //Set the algorithms and textures to the
            //ouput of the readers
            animalData = chinchillaReader.GetOutputPort();

            eyeData1 = chinchillaEyeReader.GetOutputPort();
            eyeData2 = eyeData1;

            animalColorTexture.InterpolateOn();
            animalColorTexture.SetInputConnection(chinchillaColorReader.GetOutputPort());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInputConnection(chinchillaColorReader.GetOutputPort());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInputConnection(chinchillaEyeColorReader.GetOutputPort());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInputConnection(chinchillaEyeColorReader.GetOutputPort());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInputConnection(chinchillaEyeColorReader.GetOutputPort());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInputConnection(chinchillaEyeColorReader.GetOutputPort());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the Flying Squirrel model and textures
        /// into the algorithms and textures
        /// </summary>
        public void loadFlyingSquirrel()
        {
            //Set a predefined position for the eyes
            //that matches the .blend file
            eyeX = 0.054;
            eyeY = -0.189;
            eyeZ = 0.427;

            //load the flyingsquirrel model and textures if
            //they are not already loaded
            if (!flyingSquirrelLoaded)
            {
                flyingSquirrelReader.SetFileName("../../../models/flyingsquirrel.vtk");
                flyingSquirrelReader.Update();
                flyingSquirreleyeReader.SetFileName("../../../models/flyingsquirrel_eye.vtk");
                flyingSquirreleyeReader.Update();
                flyingSquirrelColorReader.SetFileName("../../../textures/flyingsquirrel_skin_col.png");
                flyingSquirrelColorReader.Update();
                flyingSquirrelEyeColorReader.SetFileName("../../../textures/flyingsquirrel_eye.png");
                flyingSquirrelEyeColorReader.Update();
                flyingSquirrelLoaded = true;
            }

            //Set the algorithms and textures to the
            //ouput of the readers
            animalData = flyingSquirrelReader.GetOutputPort();

            eyeData1 = flyingSquirreleyeReader.GetOutputPort();
            eyeData2 = eyeData1;

            animalColorTexture.InterpolateOn();
            animalColorTexture.SetInputConnection(flyingSquirrelColorReader.GetOutputPort());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInputConnection(flyingSquirrelColorReader.GetOutputPort());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInputConnection(flyingSquirrelEyeColorReader.GetOutputPort());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInputConnection(flyingSquirrelEyeColorReader.GetOutputPort());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInputConnection(flyingSquirrelEyeColorReader.GetOutputPort());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInputConnection(flyingSquirrelEyeColorReader.GetOutputPort());
        }
Ejemplo n.º 4
0
        private void ReadPNG()
        {
            // 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\camscene.png");
            //Read the image
            vtkPNGReader reader = vtkPNGReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update();
            // Visualize
            vtkImageViewer2 imageViewer = vtkImageViewer2.New();

            imageViewer.SetInputConnection(reader.GetOutputPort());
            // 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);
            imageViewer.SetRenderer(renderer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads the Rabbit model and textures
        /// into the algorithms and textures
        /// </summary>
        public void loadRabbit()
        {
            //Set a predefined position for the eyes
            //that matches the .blend file
            eyeX = 0.057;
            eyeY = -0.311;
            eyeZ = 1.879;

            //load the rabbit model and textures if
            //they are not already loaded
            if (!rabbitLoaded)
            {
                rabbitReader.SetFileName("../../../models/rabbit.vtk");
                rabbitReader.Update();
                eyeReader.SetFileName("../../../models/rabbit_eye.vtk");
                eyeReader.Update();
                rabbitColorReader.SetFileName("../../../textures/rabbit_skin_col.png");
                rabbitColorReader.Update();
                eyeColorReader.SetFileName("../../../textures/rabbit_eye.png");
                eyeColorReader.Update();
                rabbitLoaded = true;
            }
            //Set the algorithms and textures to the
            //ouput of the readers
            animalData = rabbitReader.GetOutputPort();

            eyeData1 = eyeReader.GetOutputPort();
            eyeData2 = eyeData1;

            animalColorTexture.InterpolateOn();
            animalColorTexture.SetInputConnection(rabbitColorReader.GetOutputPort());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInputConnection(rabbitColorReader.GetOutputPort());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInputConnection(eyeColorReader.GetOutputPort());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInputConnection(eyeColorReader.GetOutputPort());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInputConnection(eyeColorReader.GetOutputPort());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInputConnection(eyeColorReader.GetOutputPort());
        }
Ejemplo n.º 6
0
        private void WritePNG()
        {
            // 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\test_png.png");

            int[] extent = new int[] { 0, 99, 0, 99, 0, 0 };
            vtkImageCanvasSource2D imageSource = vtkImageCanvasSource2D.New();

            imageSource.SetExtent(extent[0], extent[1], extent[2], extent[3], extent[4], extent[5]);
            imageSource.SetScalarTypeToUnsignedChar();
            imageSource.SetNumberOfScalarComponents(3);
            imageSource.SetDrawColor(127, 45, 255);
            imageSource.FillBox(0, 99, 0, 99);
            imageSource.SetDrawColor(255, 255, 255);
            imageSource.FillBox(40, 70, 20, 50);
            imageSource.Update();

            vtkImageCast castFilter = vtkImageCast.New();

            castFilter.SetOutputScalarTypeToUnsignedChar();
            castFilter.SetInputConnection(imageSource.GetOutputPort());
            castFilter.Update();

            vtkPNGWriter writer = vtkPNGWriter.New();

            writer.SetFileName(filePath);
            writer.SetInputConnection(castFilter.GetOutputPort());
            writer.Write();
            // Read and display file for verification that it was written correctly
            vtkPNGReader reader = vtkPNGReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update();

            // Visualize
            vtkImageViewer2 imageViewer = vtkImageViewer2.New();

            imageViewer.SetInputConnection(reader.GetOutputPort());
            // 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);
            imageViewer.SetRenderer(renderer);
            renderer.ResetCamera();
        }