<div dir="ltr">I think I solved it...<div><br></div><div>Instead of declaring the variables in the function, I declared them at the Public Partial Class level and then initialized at the function level.</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Feb 17, 2014 at 7:22 PM, Matias Montroull <span dir="ltr"><<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)">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:</span><br>
</div><div><span style="background-color:rgb(254,254,254)"><font color="#000000"><span style="font-size:12px;letter-spacing:0.36000001430511475px;line-height:16.799999237060547px;white-space:pre-line"><i>Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</i></span></font><br>
</span></div><div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)"><br></span></div><div><div>I've read that w<span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)">hen 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..</span></div>
<div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)"><br></span></div><div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)">Here's my code:</span><br>
</div></div><div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)"><br></span></div><div><span style="line-height:16.799999237060547px;letter-spacing:0.03em;font-size:12px;white-space:pre-line;background-color:rgb(254,254,254)"> </span><span style="background-color:rgb(254,254,254)"><font color="#000000"><span style="font-size:12px;letter-spacing:0.36000001430511475px;line-height:16.799999237060547px;white-space:pre-line">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();
}</span></font><br></span></div><div><span style="background-color:rgb(254,254,254)"><font color="#000000"><span style="font-size:12px;letter-spacing:0.36000001430511475px;line-height:16.799999237060547px;white-space:pre-line"><br>
</span></font></span></div></div>
</blockquote></div><br></div>