[vtkusers] converting java array to vtkimage data

Sebastien Jourdain sebastien.jourdain at kitware.com
Fri Apr 23 15:02:52 EDT 2010


Hi Nikhil,

You forgot to load the system library.

You have to add the following line in your code as well as having depending
on your system the directory that content the vtk library inside the
environment vairiable PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH (win/unix/mac).

static {
    System.loadLibrary("vtkCommonJava");
    System.loadLibrary("vtkFilteringJava");
    System.loadLibrary("vtkIOJava");
    System.loadLibrary("vtkImagingJava");
    System.loadLibrary("vtkGraphicsJava");
    System.loadLibrary("vtkRenderingJava");
    try {
      System.loadLibrary("vtkHybridJava");
    } catch (Throwable e) {
      System.out.println("cannot load vtkHybrid, skipping...");
    }
    try {
      System.loadLibrary("vtkVolumeRenderingJava");
    } catch (Throwable e) {
      System.out.println("cannot load vtkVolumeRendering, skipping...");
    }
  }

Seb

On Fri, Apr 23, 2010 at 2:57 PM, nikhil singhania <niksinghania at gmail.com>wrote:

> Sir,
> I am writing a code to convert java array to image data..but getting an
> error:
>
> "Exception in thread "main" java.lang.UnsatisfiedLinkError:
> vtk.vtkImageData.VTKInit()J
>        at vtk.vtkImageData.VTKInit(Native Method)
>        at vtk.vtkObject.<init>(vtkObject.java:96)
>        at vtk.vtkDataObject.<init>(vtkDataObject.java:1206)
>        at vtk.vtkDataSet.<init>(vtkDataSet.java:225)
>        at vtk.vtkImageData.<init>(vtkImageData.java:347)
>        at javaapplication2.fileread.main(fileread.java:49)"
>
> here is some part of code...
>
>  vtkImageData image = new vtkImageData();
>  image.SetDimensions(500, 500, 50);
>  image.SetOrigin(0.0, 0.0, 0.0);
>  image.SetSpacing(0.33,0.33,0.33);
>  image.SetScalarTypeToChar();
>  image.AllocateScalars();
>  vtkDataArray array = image.GetPointData().GetScalars();
>
>  for(int iZ = 0; iZ < 50; iZ++){
>            for(int iY= 0; iY < 500; iY++){
>                      for(int iX = 0; iX < 500; iX++){
>                                 array.InsertNextTuple1(arr[iZ][iY][iX]);
>                        }
>               }
>   }
>
> Please help.
>
> Thank You.
> --
> Nikhil Kumar
> rit2007033
> b.tech IT 6th sem
> IIIT Allahabad
> contact at 9793905858
> email: rit2007033 at iiita.ac.in
>          niksinghania at gmail.com
> http://profile.iiita.ac.in/RIT2007033/
> _______________________________________________
> 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/20100423/be51b16e/attachment.htm>


More information about the vtkusers mailing list