[vtk-developers] Activiz Error Attempted to read or write protected memory

serseri serhattural12 at gmail.com
Wed Dec 3 07:35:12 EST 2014


Hi I have a codeblock as below and getting very strange errors:

//-------------------------------------------------------------------------------------
var vtkImg = vtkImageData.New();
vtkImg.SetDimensions(10, 10 , 1);
vtkImg.SetNumberOfScalarComponents(1);
vtkImg.SetScalarTypeToLong();
int[] dims = vtkImg.GetDimensions();
unsafe
{
    for (int y = 0; y < dims[1]; y++)
    {
        for (int x = 0; x < dims[0]; x++)
        {
            long* pixel = (long*)vtkImg.GetScalarPointer(x, y,
0).ToPointer();
            pixel[0] = 0L;
        }
    }
}
vtkXMLImageDataWriter writer = vtkXMLImageDataWriter.New();
writer.SetFileName("x.vti");
writer.SetInputConnection(vtkImg.GetProducerPort());
writer.Write();
//-------------------------------------------------------------------------------------

It gives error like:
- Unable to load DLL 'Kitware.VTK.vtkIO.Unmanaged.dll'
- Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

If I increce z extent size like vtkImg.SetDimensions(10, 10 , 2) it runs :)
If I use int type it runs. vtkImg.SetScalarTypeToInt();

I think there is some bugs. I need help. 

Thanks.



--
View this message in context: http://vtk.1045678.n5.nabble.com/Activiz-Error-Attempted-to-read-or-write-protected-memory-tp5729647.html
Sent from the VTK - Dev mailing list archive at Nabble.com.


More information about the vtk-developers mailing list