[vtkusers] How to reconstruct sequence tif slices to 3D graph ?

chopinwzc wang chopinwzc at gmail.com
Wed Apr 18 01:20:39 EDT 2007


How to reconstruct sequence  tif   slices to 3D graph ?

I open a tif files and save as slice then get 31 tif slices and they are
about a medical graph.

My code as follow, when I run them I get a black cube only.

I think the mapper and the actor are used uncorrectly.

Some can help me ? tell me your email address and I will send the tif files
to you.

Thanks a lot !

Regards !

                                             Wang zucheng

*
*

//Here is my code .

import vtk.*;

public class ReBuild {

     static {

        System.loadLibrary("vtkCommonJava");

        System.loadLibrary("vtkFilteringJava");

        System.loadLibrary("vtkIOJava");

        System.loadLibrary("vtkImagingJava");

        System.loadLibrary("vtkGraphicsJava");

        System.loadLibrary ("vtkRenderingJava");

    }

        // the main function

    public static void main(String[] args) {

        vtkTIFFReader tifReader = new vtkTIFFReader();

        tifReader.SetDataExtent(0,512,0,512,0,30);// 512*512 tif images

        tifReader.SetFilePrefix("f:/tifimage/tiffiles");

        tifReader.SetFilePattern("%s%02d.tif");

        tifReader.SetDataSpacing(2.0,2.0,2.0);//x,y,z pixel spacing

        tifReader.SetDataOrigin(0,0,0);

        tifReader.ReleaseDataFlagOn();

        tifReader.Update();



        //map to image objects

        vtkDataSetMapper aMapper = new vtkDataSetMapper();

        aMapper.SetInput(tifReader.GetOutput());

        aMapper.ScalarVisibilityOn();



        vtkActor skin = new vtkActor();

        skin.SetMapper(aMapper);



        // a renderer for the data

        vtkRenderer aRenderer = new vtkRenderer();    //create a renderer
named aRenderer

        vtkRenderWindow reWin = new vtkRenderWindow(); //create a render
window reWin

        aRenderer.AddActor(skin);

        reWin.AddRenderer(aRenderer);     //add the  renderer into render
window reWin

        reWin.SetSize(400,400);



        //an interactor to allow control of the objects

        vtkRenderWindowInteractor aInterActor = new
vtkRenderWindowInteractor();

        aInterActor.SetRenderWindow(reWin);



        //camera

        vtkCamera tifCamera = new vtkCamera();

        tifCamera.SetViewUp(0,1,0);//0 1 0 default

        tifCamera.SetPosition(0,0,1);//0 0 1 default

        aRenderer.SetActiveCamera(tifCamera);

        aRenderer.ResetCamera();

        aRenderer.SetBackground(1,1,1);



        //aInterActor.Initialize(); ?

        reWin.Render();

        aInterActor.Start();

    }

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070418/b954527f/attachment.htm>


More information about the vtkusers mailing list