[vtkusers] generate 3D images from 2D bmp files in java
Jonathan Ruiz Peinado
jonathan.ruiz3 at gmail.com
Thu Jun 14 11:36:54 EDT 2012
mmm
try this to refresh it , it works for me
VtkPanel().Render()
also
you can try
vtkPanel.repaint();
2012/6/14 Rémi DUCCESCHI <remi.ducceschi at gmail.com>
> Hello again!
>
> To answer myself (it will maybe help someone later): it's much easier to
> use vtk 5.10 to do what I want thanks to this :
> http://www.cmake.org/Wiki/VTK/Image_Rendering_Classes
>
> I still have a problem for updating the vtkRenderWindowPanel: I change the
> slice by changing the position of the actor
> actor.SetPosition(pos); // pos is a double[]
> panel.Render();
> it does exactly what I want, but the Panel isn't updated until I create an
> event with my mouse.
> if you know what I can do, you would be welcome!!!
>
> from the beginning to the end, we have the following source code to create
> and display a 3D image (see bellow)
>
>
> ------------------------------------- SOURCE CODE
> ----------------------------------
> public class PrintPix extends JFrame
> {
> public PrintPix (File[] paths)
> {
> int size = paths.length;
> vtkStringArray array = new vtkStringArray();
>
> array.SetNumberOfValues(size);
> for (int i = 0; i < size; i++)
> {
> array.SetValue(i, paths[i].getAbsolutePath());
> }
>
> reader = new vtkBMPReader();
> actor = new vtkImageSlice();
> int numberOfFile = paths.GetNumberOfValues() - 1; // number of
> open pictures - 1
>
> // open pictures and create a 3D picture
> // reader.SetFileNames(paths);
> reader.SetDataExtent(0, numberOfFile, 0, numberOfFile, 0,
> numberOfFile);
> reader.SetDataSpacing(1, 1, 40);
> reader.SetFileNames(array);
> reader.Update();
>
> // put it in a mapper
> vtkImageResliceMapper mapper = new vtkImageResliceMapper();
> mapper.SetInputConnection(reader.GetOutputPort());
> mapper.SliceFacesCameraOn();
> mapper.SliceAtFocalPointOn();
>
> // on créél les propriétés de l'image
> vtkImageProperty props = new vtkImageProperty();
> props.SetInterpolationTypeToLinear();
>
> // put all in an actor
> actor.SetMapper(mapper);
> actor.SetProperty(props);
> mapper.UpdateInformation();
>
> panel = new vtkRenderWindowPanel();
> vtkInteractorStyleImage it = new vtkInteractorStyleImage();
> it.SetInteractionModeToImage3D();
> panel.GetRenderer().AddActor(actor);
> panel.setInteractorStyle(it);
>
> panel.setPreferredSize(new Dimension(728, 728));
> panel.Render();
>
> add(panel, BorderLayout.CENTER);
>
> setTitle("image");
> setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> pack();
> setVisible(true);
>
> panel.Render();
> }
> }
>
> public static void main (String[] args)
> {
> File paths[];
> // we initialize "paths" with all the pictures we want to open
> (with a JFileChooser for instance)
>
> PrintPix principal = new PrintPix(paths);
> }
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120614/3c46219d/attachment.htm>
More information about the vtkusers
mailing list