[vtkusers] Java EXCEPTION_ACCESS_VIOLATION
Divye
zombi2_84 at yahoo.com
Sun Oct 25 14:03:24 EDT 2009
Hi All,
I am trying to run a program for 3d rendering of DICOM images , using java on win vista 32 - bit using vtk 5.4.2 and am getting the following EXCEPTION_ACCESS_VIOLATION.
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x59bf3b3f, pid=27652, tid=27836
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode, sharing)
# Problematic frame:
# C [vtkVolumeRendering.dll+0x313b3f]
#
# An error report file with more information is saved as hs_err_pid27652.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
Looks like a memory leak somewhere but am not able to figure out where it is.
Here is the main class :
import vtk.*;
public class WrapperVtkRenderVolume {
vtkRenderer renderer = new vtkRenderer();
vtkRenderWindow renderWindow = new vtkRenderWindow();
vtkRenderWindowInteractor renInteractor = new vtkRenderWindowInteractor();
vtkImageData imageData = new vtkImageData();
vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();
vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
vtkVolume volume = new vtkVolume();
vtkVolumeTextureMapper3D volumeMapper = new vtkVolumeTextureMapper3D();
vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();
vtkFixedPointVolumeRayCastMapper volumeMapperSoftware = new vtkFixedPointVolumeRayCastMapper();
public WrapperVtkRenderVolume(int width, int height) {
ResetSize(width, height);
SetupSceneBasics();
}
private void ResetSize(int width, int height) {
renderWindow.SetSize(width, height);
}
private void SetupSceneBasics() {
renderer.SetBackground(0, 0, 0);
renderWindow.AddRenderer(renderer);
renInteractor.SetRenderWindow(renderWindow);
}
public boolean LoadVolumeFromFolder(String strFolderPath) {
vtkDICOMImageReader imageReader = new vtkDICOMImageReader();
int channels = imageReader.GetNumberOfScalarComponents();
if (channels == 1) {
loadGrayScaleDataSet(imageReader.GetOutput());
setupRendererMIP();
} else {
System.out.println("unsupported number of channels in dicom dataset");
return false;
}
imageReader.Delete();
renderer.ResetCamera();
return true;
}
private boolean setupRendererMIP() {
volumeProperty.SetColor(colorTransferFunction);
volumeProperty.SetScalarOpacity(opacityTransferFunction);
volumeProperty.SetInterpolationTypeToLinear();
volumeProperty.ShadeOff();
volume.SetProperty(volumeProperty);
volumeMapperSoftware.SetInput(imageData);
volumeMapperSoftware.SetSampleDistance(1.0);
volumeMapperSoftware.SetBlendModeToMaximumIntensity();
volume.SetMapper(volumeMapperSoftware);
renderer.AddVolume(volume);
return true;
}
private void loadGrayScaleDataSet(vtkImageData getOutput) {
imageData.DeepCopy(getOutput);
double initialWindow = imageData.GetScalarRange()[1] - imageData.GetScalarRange()[0];
double initialLevel = initialWindow/2.0;
VtkObserverWindowLevel observerWindowLevel = new VtkObserverWindowLevel(initialWindow, initialLevel, renInteractor,
opacityTransferFunction, colorTransferFunction);
}
public void Start() {
renInteractor.Initialize();
renInteractor.Start();
}
}
the other class VtkObserverWindowLevel is :
import vtk.*;
public class VtkObserverWindowLevel {
private vtkRenderWindowInteractor renInteractor;
private vtkPiecewiseFunction opacityTransferFunction;
private vtkColorTransferFunction colorTransferFunction;
private double initialLevel;
private double initialWindow;
private int lastMouseY;
private int lastMouseX;
public VtkObserverWindowLevel(double initialWindow, double initialLevel,
vtkRenderWindowInteractor renInteractor,
vtkPiecewiseFunction opacityTransferFunction,
vtkColorTransferFunction colorTransferFunction) {
this.renInteractor = renInteractor;
this.opacityTransferFunction = opacityTransferFunction;
this.colorTransferFunction = colorTransferFunction;
this.initialLevel = initialLevel;
this.initialWindow = initialWindow;
int lastMouseX = 0;
int lastMouseY = 0;
doWindowLevel();
}
private void doWindowLevel() {
int[] currPosition;
currPosition = renInteractor.GetEventPosition();
initialLevel -= (currPosition[1] - lastMouseY);
initialWindow += ( currPosition[0] - lastMouseX);
lastMouseX = currPosition[0];//current x
lastMouseY = currPosition[1];//current y
// Alter the color and opacity transfer functions
opacityTransferFunction.RemoveAllPoints();
opacityTransferFunction.AddPoint(initialLevel - 0.5 * initialWindow, 0.0);
opacityTransferFunction.AddPoint(initialLevel + 0.5 * initialWindow, 1.0);
colorTransferFunction.RemoveAllPoints();
colorTransferFunction.AddRGBSegment(initialLevel - 0.5 * initialWindow, 0.0, 0.0, 0.0,
initialLevel + 0.5 * initialWindow, 1.0, 1.0, 1.0);
// Re-render.
renInteractor.Modified();
renInteractor.Render();
}
}
Can anyone please help me figuring out the cause.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091025/a5808df7/attachment.htm>
More information about the vtkusers
mailing list