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.SetInput(squirrelEyeColorReader.GetOutput());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInput(squirrelEyeColorReader.GetOutput());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInput(squirrelEyeColorReader2.GetOutput());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInput(squirrelEyeColorReader2.GetOutput());

            animalColorTexture.InterpolateOn();
            animalColorTexture.SetInput(squirrelColorReader.GetOutput());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInput(squirrelColorReader.GetOutput());

            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.SetInput(chinchillaColorReader.GetOutput());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInput(chinchillaColorReader.GetOutput());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInput(chinchillaEyeColorReader.GetOutput());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInput(chinchillaEyeColorReader.GetOutput());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInput(chinchillaEyeColorReader.GetOutput());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInput(chinchillaEyeColorReader.GetOutput());
        }
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.SetInput(flyingSquirrelColorReader.GetOutput());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInput(flyingSquirrelColorReader.GetOutput());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInput(flyingSquirrelEyeColorReader.GetOutput());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInput(flyingSquirrelEyeColorReader.GetOutput());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInput(flyingSquirrelEyeColorReader.GetOutput());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInput(flyingSquirrelEyeColorReader.GetOutput());
        }
Ejemplo n.º 4
0
    public static int Main(string[] args)
    {
        string filename    = args[0];
        string outfilename = args[1];

        // Step 1. Test SWIG -> Activiz
        vtkGDCMImageReader reader = vtkGDCMImageReader.New();

        reader.SetFileName(filename);
        //reader.Update(); // DO NOT call Update to check pipeline execution

        Kitware.VTK.vtkImageData imgout = ConnectSWIGToActiviz(reader.GetOutput());

        System.Console.WriteLine(imgout.ToString()); // not initialized as expected

        vtkPNGWriter writer = new vtkPNGWriter();

        writer.SetInput(imgout);
        writer.SetFileName(outfilename);
        writer.Write();

        // Step 2. Test Activiz -> SWIG
        vtkPNGReader bmpreader = new vtkPNGReader();

        bmpreader.SetFileName(outfilename);
        //bmpreader.Update(); // DO NOT update to check pipeline execution

        System.Console.WriteLine(bmpreader.GetOutput().ToString()); // not initialized as expected

        vtkgdcm.vtkImageData imgout2 = ConnectActivizToSWIG(bmpreader.GetOutput());

        System.Console.WriteLine(imgout2.ToString()); // not initialized as expected


        Kitware.VTK.vtkMedicalImageProperties prop = new Kitware.VTK.vtkMedicalImageProperties();
        prop.SetModality("MR");

        string             outfilename2 = args[2];
        vtkGDCMImageWriter writer2      = vtkGDCMImageWriter.New();

        writer2.SetMedicalImageProperties(prop.CastToActiviz());
        writer2.SetFileName(outfilename2);
        writer2.SetInput(imgout2);
        writer2.Write();

        return(0);
    }
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.SetInput(rabbitColorReader.GetOutput());

            deciAnimalColorTexture.InterpolateOn();
            deciAnimalColorTexture.SetInput(rabbitColorReader.GetOutput());

            eyeColorTexture1.InterpolateOn();
            eyeColorTexture1.SetInput(eyeColorReader.GetOutput());

            deciEyeColorTexture1.InterpolateOn();
            deciEyeColorTexture1.SetInput(eyeColorReader.GetOutput());

            eyeColorTexture2.InterpolateOn();
            eyeColorTexture2.SetInput(eyeColorReader.GetOutput());

            deciEyeColorTexture2.InterpolateOn();
            deciEyeColorTexture2.SetInput(eyeColorReader.GetOutput());
        }
Ejemplo n.º 6
0
  public static int Main(string[] args)
    {
    string filename = args[0];
    string outfilename = args[1];
    string outfilename2 = args[2];

    vtkGDCMImageReader reader = new Kitware.VTK.GDCM.vtkGDCMImageReader();
    reader.SetFileName( filename );

    // When calling multiple times creation of C# object from the same C++ object it triggers a:
//error: potential refcounting error: Duplicate rawCppThis - weak reference that is still alive. Attempting to add '0x00b2dc10' again.
//       Allowing new wrapped object to take over table key...
//       Original object should *not* have been destroyed while we still had it in our table without notifying us...
    //reader.GetOutput();
    //reader.GetOutput();

    System.Console.WriteLine( reader.ToString() ); // Test the ToString compat with Activiz

    vtkGDCMImageWriter writer = new vtkGDCMImageWriter();
    writer.SetInput( reader.GetOutput() );
    writer.SetFileName( outfilename2 );
    writer.Write();

    System.Console.WriteLine( reader.GetOutput().ToString() ); // Test the ToString compat with Activiz

    System.Console.WriteLine( writer.ToString() ); // Test the ToString compat with Activiz

    vtkPNGWriter pngwriter = new vtkPNGWriter();
    pngwriter.SetInput( reader.GetOutput() );
    pngwriter.SetFileName( outfilename );
    pngwriter.Write();

    // at that point the .Write() should have triggered an Update() on the reader:
    if( reader.GetImageFormat() == vtkgdcm.VTK_LUMINANCE ) // MONOCHROME2
      {
      System.Console.WriteLine( "Image is MONOCHROME2" ); //
      }

    vtkPNGReader bmpreader = new vtkPNGReader();
    bmpreader.SetFileName( outfilename );

    vtkMedicalImageProperties prop = new vtkMedicalImageProperties();
    prop.SetModality( "MR" );

    vtkMatrix4x4 dircos = reader.GetDirectionCosines();
    dircos.Invert();

    vtkGDCMImageWriter writer2 = new vtkGDCMImageWriter();
    writer2.SetFileName( outfilename2 );
    writer2.SetDirectionCosines( dircos );
    writer2.SetMedicalImageProperties( prop );
    writer2.SetInput( bmpreader.GetOutput() );
    writer2.Write();

    return 0;
    }
Ejemplo n.º 7
0
    public static int Main(string[] args)
    {
        string filename = args[0];
        string outfilename = args[1];

        // Step 1. Test SWIG -> Activiz
        vtkGDCMImageReader reader = vtkGDCMImageReader.New();
        reader.SetFileName( filename );
        //reader.Update(); // DO NOT call Update to check pipeline execution

        Kitware.VTK.vtkImageData imgout = ConnectSWIGToActiviz(reader.GetOutput());

        System.Console.WriteLine( imgout.ToString() ); // not initialized as expected

        vtkPNGWriter writer = new vtkPNGWriter();
        writer.SetInput( imgout );
        writer.SetFileName( outfilename );
        writer.Write();

        // Step 2. Test Activiz -> SWIG
        vtkPNGReader bmpreader = new vtkPNGReader();
        bmpreader.SetFileName( outfilename );
        //bmpreader.Update(); // DO NOT update to check pipeline execution

        System.Console.WriteLine( bmpreader.GetOutput().ToString() ); // not initialized as expected

        vtkgdcm.vtkImageData imgout2 = ConnectActivizToSWIG(bmpreader.GetOutput());

        System.Console.WriteLine( imgout2.ToString() ); // not initialized as expected

        Kitware.VTK.vtkMedicalImageProperties prop = new Kitware.VTK.vtkMedicalImageProperties();
        prop.SetModality( "MR" );

        string outfilename2 = args[2];
        vtkGDCMImageWriter writer2 = vtkGDCMImageWriter.New();
        writer2.SetMedicalImageProperties( prop.CastToActiviz() );
        writer2.SetFileName( outfilename2 );
        writer2.SetInput( imgout2 );
        writer2.Write();

        return 0;
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Load image files into vtkImageData.
        /// </summary>
        /// <param name="path">Path to images.</param>
        /// <param name="extension">Image extension.</param>
        /// <returns></returns>
        public static vtkImageData VTKLoader(string path, string extension)
        {
            /*DEPRECATED!!*/
            //Output
            vtkImageData data = vtkImageData.New();
            //Get files from path
            DirectoryInfo d = new DirectoryInfo(@path);

            FileInfo[] files = d.GetFiles();

            vtkStringArray allfiles = vtkStringArray.New();

            //Iterate over files and read image data
            foreach (FileInfo file in files)
            {
                //Fullfile
                string fullfile = Path.Combine(path, file.Name);
                allfiles.InsertNextValue(fullfile);
            }
            if (extension == ".png")
            {
                vtkPNGReader reader = vtkPNGReader.New();
                reader.SetFileNames(allfiles);
                reader.Update();
                data = reader.GetOutput();
                reader.Dispose();
            }
            if (extension == ".jpg")
            {
                vtkJPEGReader reader = vtkJPEGReader.New();
                reader.SetFileNames(allfiles);
                reader.Update();
                data = reader.GetOutput();
                reader.Dispose();
            }
            if (extension == ".bmp")
            {
                vtkBMPReader reader = vtkBMPReader.New();
                reader.SetFileNames(allfiles);
                reader.Update();
                data = reader.GetOutput();
                reader.Dispose();
            }
            data.SetScalarTypeToUnsignedChar();
            data.Update();
            return(data);
        }
Ejemplo n.º 9
0
    public static int Main(string[] args)
    {
        string filename     = args[0];
        string outfilename  = args[1];
        string outfilename2 = args[2];

        vtkgdcm.vtkGDCMImageReader reader = new vtkgdcm.vtkGDCMImageReader();
        reader.SetFileName(filename);

        // When calling multiple times creation of C# object from the same C++ object it triggers a:
//error: potential refcounting error: Duplicate rawCppThis - weak reference that is still alive. Attempting to add '0x00b2dc10' again.
//       Allowing new wrapped object to take over table key...
//       Original object should *not* have been destroyed while we still had it in our table without notifying us...
        //reader.GetOutput();
        //reader.GetOutput();

        System.Console.WriteLine(reader.ToString()); // Test the ToString compat with Activiz

        vtkGDCMImageWriter writer = new vtkGDCMImageWriter();

        writer.SetInput(reader.GetOutput());
        writer.SetFileName(outfilename2);
        writer.Write();

        System.Console.WriteLine(reader.GetOutput().ToString()); // Test the ToString compat with Activiz

        System.Console.WriteLine(writer.ToString());             // Test the ToString compat with Activiz

        vtkPNGWriter pngwriter = new vtkPNGWriter();

        pngwriter.SetInput(reader.GetOutput());
        pngwriter.SetFileName(outfilename);
        pngwriter.Write();

        // at that point the .Write() should have triggered an Update() on the reader:
        if (reader.GetImageFormat() == vtkgdcm.vtkgdcm.VTK_LUMINANCE) // MONOCHROME2
        {
            System.Console.WriteLine("Image is MONOCHROME2");         //
        }

        vtkPNGReader bmpreader = new vtkPNGReader();

        bmpreader.SetFileName(outfilename);

        vtkMedicalImageProperties prop = new vtkMedicalImageProperties();

        prop.SetModality("MR");

        vtkMatrix4x4 dircos = reader.GetDirectionCosines();

        dircos.Invert();

        vtkGDCMImageWriter writer2 = new vtkGDCMImageWriter();

        writer2.SetFileName(outfilename2);
        writer2.SetDirectionCosines(dircos);
        writer2.SetMedicalImageProperties(prop);
        writer2.SetInput(bmpreader.GetOutput());
        writer2.Write();

        return(0);
    }