<div class="gmail_quote">On Fri, Mar 19, 2010 at 11:40 PM, Asad Mahmood <span dir="ltr"><<a href="mailto:asadthemahmood@gmail.com">asadthemahmood@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I'm fairly new to VTK so I was wondering what was the best way to visualize a 1D array of doubles in a grid format. Thinking that a 3D grid would be the best way to represent the data, I first converted the 1D array to a 3D array:<br>
<br> double V1array[ ][ ][ ] = new double[numRows][numColumns][1];<br> int k = 0;<br> for (int a=0; a<numRows; a++){<br> for (int b=0; b<numColumns; b++){<br> for (int c=0; c<1; c++){<br>
V1array[a][b][c] = Varr1[k];<br> k+=1; <br> }<br> }<br> }<br><br>I then created an instance of vtkStructuredGrid, set its dimensions as numRows, numColumns and 0 and then added the data to the grid through vtkPoints:<br>
<br> vtkStructuredGrid V1 = new vtkStructuredGrid();<br> V1.SetDimensions(numRows, numColumns, 0);<br> vtkPoints points = new vtkPoints();<br> for (int a=0; a<numRows; a++){<br> for (int b=0; b<numColumns; b++){<br>
for(int c=0; c<1; c++){<br> points.InsertNextPoint(V1array[a][b][c],0,0);<br> }<br> }<br> }<br> V1.SetPoints(points);<br><br>I then set the geometry of the grid with StructuredGridGeometryFilter and a gridMapper and set the Actor, Renderer and Render Window:<br>
<br> vtkStructuredGridGeometryFilter plane = new vtkStructuredGridGeometryFilter();<br> plane.SetInput(V1);<br> <br> <br> vtkPolyDataMapper sgridMapper = new vtkPolyDataMapper();<br> sgridMapper.SetInputConnection(plane.GetOutputPort());<br>
<br> vtkActor sgridActor = new vtkActor();<br> sgridActor.SetMapper(sgridMapper);<br> sgridActor.GetProperty().SetRepresentationToWireframe();<br> sgridActor.GetProperty().SetColor(0, 0, 0);<br> <br> vtkRenderer renderer = new vtkRenderer();<br>
vtkRenderWindow renWin = new vtkRenderWindow();<br> renWin.AddRenderer(renderer);<br> <br> vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();<br> iren.SetRenderWindow(renWin);<br> <br> renderer.AddActor(sgridActor);<br>
renderer.SetBackground(1,1,1);<br> renderer.ResetCamera();<br> renWin.SetSize(500,500);<br> <br> renWin.Render();<br> iren.Start();<br> <br>However, all I get is a white screen for my render window and not a numRows X numColumns grid containing my data points. Any suggestions on how to fix my code and get a properly dimensioned grid of data? I intend on then using a LookUp Table to color code the data points in the grid so I first need a grid filled with all the data.<br>
<br>Thanks!<br><br>
</blockquote></div><div><br></div>Have a read of this:<div><a href="http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology">http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology</a></div><div><br></div><div>It looks like you only have geometry, and no topology. An easy way to get vertex (1D) topology is to apply:</div>
<div><br></div><div><div><a href="http://www.vtk.org/Wiki/VTK/Examples/vtkVertexGlyphFilter">http://www.vtk.org/Wiki/VTK/Examples/vtkVertexGlyphFilter</a></div><div><br></div><div>to your StructuredGrid.</div><div><br></div>
<div>Hope that helps,</div><div><br>David</div></div>