<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi All,<br><br>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.<br><br>An unexpected error has been detected by Java Runtime Environment:<br>#<br>#&nbsp; EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x59bf3b3f, pid=27652, tid=27836<br>#<br># Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode, sharing)<br># Problematic frame:<br># C&nbsp; [vtkVolumeRendering.dll+0x313b3f]<br>#<br># An error report file with more information is saved as hs_err_pid27652.log<br>#<br># If you would like to submit a bug report, please visit:<br>#&nbsp;&nbsp; http://java.sun.com/webapps/bugreport/crash.jsp<br><br>Looks like a memory leak somewhere but am not able to figure out where it is.<br><br>Here is the main class : <br><br>import vtk.*;<br><br>public
 class WrapperVtkRenderVolume {<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; vtkRenderer renderer = new vtkRenderer();<br>&nbsp;&nbsp;&nbsp; vtkRenderWindow renderWindow = new vtkRenderWindow();<br>&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor renInteractor = new vtkRenderWindowInteractor();<br>&nbsp;&nbsp;&nbsp; vtkImageData imageData = new vtkImageData();<br>&nbsp;&nbsp;&nbsp; vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();<br>&nbsp;&nbsp;&nbsp; vtkVolumeProperty volumeProperty = new vtkVolumeProperty();<br>&nbsp;&nbsp;&nbsp; vtkVolume volume = new vtkVolume();<br>&nbsp;&nbsp;&nbsp; vtkVolumeTextureMapper3D volumeMapper = new vtkVolumeTextureMapper3D();<br>&nbsp;&nbsp;&nbsp; vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();<br>&nbsp;&nbsp;&nbsp; vtkFixedPointVolumeRayCastMapper volumeMapperSoftware = new vtkFixedPointVolumeRayCastMapper();<br><br>&nbsp;&nbsp;&nbsp; public
 WrapperVtkRenderVolume(int width, int height) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ResetSize(width, height);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetupSceneBasics();<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; private void ResetSize(int width, int height) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderWindow.SetSize(width, height);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; private void SetupSceneBasics() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderer.SetBackground(0, 0, 0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderWindow.AddRenderer(renderer);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renInteractor.SetRenderWindow(renderWindow);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public boolean LoadVolumeFromFolder(String strFolderPath)
 {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkDICOMImageReader imageReader = new vtkDICOMImageReader();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int channels = imageReader.GetNumberOfScalarComponents();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (channels == 1) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; loadGrayScaleDataSet(imageReader.GetOutput());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setupRendererMIP();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("unsupported number of channels in dicom dataset");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return false;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 imageReader.Delete();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderer.ResetCamera();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; private boolean setupRendererMIP() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeProperty.SetColor(colorTransferFunction);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeProperty.SetScalarOpacity(opacityTransferFunction);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeProperty.SetInterpolationTypeToLinear();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeProperty.ShadeOff();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volume.SetProperty(volumeProperty);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeMapperSoftware.SetInput(imageData);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volumeMapperSoftware.SetSampleDistance(1.0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 volumeMapperSoftware.SetBlendModeToMaximumIntensity();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; volume.SetMapper(volumeMapperSoftware);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renderer.AddVolume(volume);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; private void loadGrayScaleDataSet(vtkImageData getOutput) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; imageData.DeepCopy(getOutput);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double initialWindow = imageData.GetScalarRange()[1] - imageData.GetScalarRange()[0];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double initialLevel = initialWindow/2.0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; VtkObserverWindowLevel observerWindowLevel = new VtkObserverWindowLevel(initialWindow, initialLevel, renInteractor, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; opacityTransferFunction, colorTransferFunction);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public void Start() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renInteractor.Initialize();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renInteractor.Start();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br><br>}<br><br>the other class VtkObserverWindowLevel is :<br><br>import vtk.*;<br><br>public class VtkObserverWindowLevel {<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; private vtkRenderWindowInteractor renInteractor;<br>&nbsp;&nbsp;&nbsp; private vtkPiecewiseFunction opacityTransferFunction;<br>&nbsp;&nbsp;&nbsp; private vtkColorTransferFunction colorTransferFunction;<br>&nbsp;&nbsp;&nbsp; private double initialLevel;<br>&nbsp;&nbsp;&nbsp; private double initialWindow;<br>&nbsp;&nbsp;&nbsp; private int lastMouseY;<br>&nbsp;&nbsp;&nbsp;
 private int lastMouseX;<br><br>&nbsp;&nbsp;&nbsp; public VtkObserverWindowLevel(double initialWindow, double initialLevel,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor renInteractor,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkPiecewiseFunction opacityTransferFunction,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkColorTransferFunction colorTransferFunction) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.renInteractor = renInteractor;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.opacityTransferFunction = opacityTransferFunction;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.colorTransferFunction = colorTransferFunction;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.initialLevel = initialLevel;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.initialWindow = initialWindow;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int lastMouseX = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int
 lastMouseY = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; doWindowLevel();<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; private void doWindowLevel() {<br>int[] currPosition;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; currPosition = renInteractor.GetEventPosition();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; initialLevel -= (currPosition[1] - lastMouseY);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; initialWindow += (&nbsp;&nbsp;&nbsp; currPosition[0] - lastMouseX);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lastMouseX = currPosition[0];//current x<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lastMouseY = currPosition[1];//current y<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Alter the color and opacity transfer functions <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 opacityTransferFunction.RemoveAllPoints();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; opacityTransferFunction.AddPoint(initialLevel - 0.5 * initialWindow, 0.0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; opacityTransferFunction.AddPoint(initialLevel + 0.5 * initialWindow, 1.0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; colorTransferFunction.RemoveAllPoints();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; colorTransferFunction.AddRGBSegment(initialLevel - 0.5 * initialWindow, 0.0, 0.0, 0.0,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; initialLevel + 0.5 * initialWindow, 1.0, 1.0, 1.0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Re-render.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renInteractor.Modified();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renInteractor.Render();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;
 }<br><br>}<br><br><br>Can anyone please help me figuring out the cause.<br></td></tr></table><br>