GDCM  2.2.0
ReadSeriesIntoVTK.java
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// We are required to call the package 'vtk' eventhough I (MM) would have prefered
// an import statement along the line of:
// import vtkgdcm.*;
import vtk.*;
/*
* Usage:
* export LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/xawt:.
* java -classpath `pwd`/vtkgdcm.jar:/usr/share/java/vtk.jar:. ReadSeriesIntoVTK
*/
public class ReadSeriesIntoVTK
{
static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkgdcmJava");
try {
System.loadLibrary("vtkRenderingJava");
} catch (Throwable e) {
System.out.println("cannot load vtkHybrid, skipping...");
}
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...");
}
}
public static void main(String[] args)
{
vtkFileOutputWindow outWin = new vtkFileOutputWindow();
outWin.SetInstance(outWin);
outWin.SetFileName("MVSVTKViewer.log");
// See: http://review.source.kitware.com/#change,888
// vtkWrapJava does not handle static keyword
// String directory = vtkGDCMTesting.GetGDCMDataRoot();
String directory = t.GetGDCMDataRoot();
String file0 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq0.dcm";
String file1 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq1.dcm";
String file2 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq2.dcm";
String file3 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq3.dcm";
vtkStringArray s = new vtkStringArray();
System.out.println("adding : " + file0 );
s.InsertNextValue( file0 );
s.InsertNextValue( file1 );
s.InsertNextValue( file2 );
s.InsertNextValue( file3 );
reader.SetFileNames( s );
reader.Update();
System.out.println("Success reading: " + file0 );
vtkMetaImageWriter writer = new vtkMetaImageWriter();
writer.DebugOn();
writer.SetCompression( false );
writer.SetInput( reader.GetOutput() );
writer.SetFileName( "ReadSeriesIntoVTK.mhd" );
writer.Write();
System.out.println("Success writing: " + writer.GetFileName() );
}
}

Generated on Wed Jun 13 2012 20:40:36 for GDCM by doxygen 1.8.1
SourceForge.net Logo