<div dir="ltr">Hi Nicholas,<div><br></div><div>At a first glance, it appears that you could try doing the following changes:</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80); "> import-&gt;SetImportVoidPointer(pm);<br>
 import-&gt;SetWholeExtent(0,Nxp-1,0,Nyp-1,0,0);<br> import-&gt;SetDataExtent(0,Nxp-1,0,Nyp-1,0,0);</span></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><font class="Apple-style-span" color="#000000">Also, your lookupTable does not appear to be connected to the imageActor.</font></span></font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><font class="Apple-style-span" color="#000000"><br></font></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Prathamesh</span></font></div>
<div><br><div class="gmail_quote">On Sat, Aug 14, 2010 at 12:49 PM, Nicholas Kinar <span dir="ltr">&lt;<a href="mailto:n.kinar@usask.ca">n.kinar@usask.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



  
  

<div bgcolor="#ffffff" text="#000000"><div class="im">
<br>
<blockquote type="cite">
  <div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">
  <div><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><br>
  </span></div>
  <div>I think, the same code should work fine if you use a 1D double
array instead of 2D.</div>
  <div><br>
  </div>
  <div>Prathamesh</div>
  <div><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><br>
  </span></div>
  <br>
  </span></div>
</blockquote>
<br></div>
Prathamesh,<br>
<br>
Thank you very much for your response; this is greatly appreciated!  I
tried changing my example code to use a 1D double array, but I still
receive a similar result.  The window that is displayed by VTK shows
only &quot;garbage&quot; data.  The rendered data appears as a series of white
lines which I believe to be indicative of uninitialized memory.<br>
<br>
What am I doing wrong with my example code?  Perhaps I am not utilizing
the SetWholeExtent() and SetDataExtent() functions properly?  Might
there be another way to display the matrix?<br>
<br>
Here is the example function that I am now attempting to run.  What I
now do is copy the data into a 1D array before passing it into the
SetImportVoidPointer() function:<div class="im"><br>
<br>
void test_VTK()<br>
{<br>
    std::string fileName = &quot;M.txt&quot;;<br></div>
    double deltax = 1.0e-3;<br>
    double deltay = 1.0e-3;<div class="im"><br>
    int Nx = 1000;<br>
    int Ny = 1000;<br>
    int PML_num = 20;<br>
<br>
    int Nxp = Nx + 2 * PML_num;<br>
    int Nyp = Ny + 2 * PML_num;<br>
<br>
    TNT::Array2D&lt;double&gt; M(Nxp, Nyp);<br>
    //double **pm;<br>
    load_matrix( fileName, &amp;M );<br>
<br></div><div class="im">
    vtkSmartPointer&lt;vtkImageImport&gt; import =<br>
            vtkSmartPointer&lt;vtkImageImport&gt;::New();<br>
<br></div>
    // copy into 1D Array<br>
    std::cout &lt;&lt; &quot;Copying data &quot; &lt;&lt; std::endl;<br>
    int num = Nxp * Nyp;<br>
    TNT::Array1D&lt;double&gt; pm(num);<br>
    std::cout &lt;&lt; &quot;Have now created the matrix&quot; &lt;&lt; std::endl;<br>
    int counter = 0;<br>
    for(int i = 0; i &lt; Nxp; i++)<br>
    {<br>
        for(int j = 0; j &lt; Nyp; j++)<br>
        {<br>
            pm[counter++] = M[i][j];<br>
<br>
        }<br>
    }<br>
    std::cout &lt;&lt; &quot;Finishing copying data&quot; &lt;&lt; std::endl;<div class="im"><br>
<br>
    import-&gt;SetImportVoidPointer((void*)pm);<br>
    import-&gt;SetWholeExtent(0,Nxp,0,Nyp,0,0);<br>
    import-&gt;SetDataExtent(0,Nxp,0,Nyp,0,0);<br>
<br></div>
    //vtkSmartPointer&lt;vtkImageData&gt; data =<br>
    //        vtkSmartPointer&lt;vtkImageData&gt;::New();<br>
    //data-&gt;setDimensions( 1040, 1040, 0 );<div class="im"><br>
<br>
    vtkSmartPointer&lt;vtkLookupTable&gt; lookupTable =<br>
            vtkSmartPointer&lt;vtkLookupTable&gt;::New();<br>
<br>
    vtkSmartPointer&lt;vtkScalarBarActor&gt; colorbar =<br>
                vtkSmartPointer&lt;vtkScalarBarActor&gt;::New();<br>
<br></div>
    // add a colorbar<div class="im"><br>
    lookupTable-&gt;SetNumberOfColors(9344);<br>
    lookupTable-&gt;SetTableRange(0,10);<br>
    lookupTable-&gt;ForceBuild();<br>
<br>
    colorbar-&gt;SetLookupTable(lookupTable);<br>
    colorbar-&gt;SetWidth(0.05);<br>
    colorbar-&gt;SetPosition(0.95, 0.1);<br>
    colorbar-&gt;SetLabelFormat(&quot;%.3g&quot;);<br>
    colorbar-&gt;PickableOff();<br>
    colorbar-&gt;VisibilityOn();<br>
<br></div>
    //std::string bunny = &quot;633px-Bunny.jpg&quot;;<br>
<br>
    //read the image<br>
    //vtkSmartPointer&lt;vtkJPEGReader&gt; jPEGReader =<br>
    //        vtkSmartPointer&lt;vtkJPEGReader&gt;::New();<br>
    //jPEGReader-&gt;SetFileName ( bunny.c_str() );<br>
    //jPEGReader-&gt;Update();<div class="im"><br>
<br>
    vtkSmartPointer&lt;vtkImageViewer2&gt; viewer =<br>
             vtkSmartPointer&lt;vtkImageViewer2&gt;::New();<br>
    viewer-&gt;SetInput(import-&gt;GetOutput());<br>
    viewer-&gt;SetInput( import-&gt;GetOutput() );<br>
<br></div>
    //setup renderer<div class="im"><br>
    vtkSmartPointer&lt;vtkRenderer&gt; renderer =<br>
          vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
    renderer-&gt;AddActor ( viewer-&gt;GetImageActor() );<br>
    renderer-&gt;AddActor(colorbar);<br>
    renderer-&gt;ResetCamera();<br>
<br></div>
    //setup render window<div class="im"><br>
    vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =<br>
          vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<br>
    renderWindow-&gt;AddRenderer ( renderer );<br>
<br></div>
    //setup render window interactor<div class="im"><br>
    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;
renderWindowInteractor =<br>
          vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
    vtkSmartPointer&lt;vtkInteractorStyleImage&gt; style =<br>
          vtkSmartPointer&lt;vtkInteractorStyleImage&gt;::New();<br>
<br>
    renderWindowInteractor-&gt;SetInteractorStyle( style );<br>
<br></div>
    //render and start interaction<div class="im"><br>
    renderWindowInteractor-&gt;SetRenderWindow ( renderWindow );<br>
    renderWindowInteractor-&gt;Initialize();<br>
    renderWindowInteractor-&gt;Start();<br>
<br>
<br>
} // end function<br>
<br>
</div></div>

</blockquote></div><br></div></div>