[vtkusers] ActiViz | WindowColor | Memory Corrupt..

Matias Montroull matimontg at gmail.com
Mon Feb 17 17:59:01 EST 2014


I think I solved it...

Instead of declaring the variables in the function, I declared them at the
Public Partial Class level and then initialized at the function level.


On Mon, Feb 17, 2014 at 7:22 PM, Matias Montroull <matimontg at gmail.com>wrote:

> Hi,
>
> Currently, I have an array of vtkImageViewer and an array of
> vtkRenderWindow to display 12 images in a mosaic. When I switch tabs and
> come back to the mosaic, I can zoom, move, pan, rotate, but when I try
> ColorWindow  change then I get this:
> *Attempted to read or write protected memory. This is often an indication
> that other memory is corrupt.*
>
> I've read that when using ActiViz, it is important to hold .NET managed
> references to vtk objects or objects used by vtk objects. Skipping this
> step often will result in AccessViolationExceptions or other type of errors
> where .NET performs garbage collection on memory that is still being used
> by VTK but this only happens to me when trying to perform WindowColor
> change so I'm lost..
>
> Here's my code:
>
>   vtkImageViewer2[] _ImageViewer; _ImageViewer = new vtkImageViewer2[12];
> vtkRenderWindow[] ren; ren = new vtkRenderWindow[12]; for (int i = 0; i <
> 12; i++) { _ImageViewer[i] = new vtkImageViewer2(); vtkDICOMImageReader
> reader = vtkDICOMImageReader.New();
> reader.SetFileName(ofdmulti.FileNames[i]); reader.Update();
> _ImageViewer[i].SetInputConnection(reader.GetOutputPort()); ren[i] =
> renderWindowControl[i].RenderWindow; vtkRenderWindowInteractor interactor =
> new vtkRenderWindowInteractor();
> interactor.SetInteractorStyle(vtkInteractorStyleImage.New());
> _ImageViewer[i].SetupInteractor(interactor);
> _ImageViewer[i].SetRenderWindow(ren[i]); _ImageViewer[i].Render(); }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140217/0665daaa/attachment.html>


More information about the vtkusers mailing list