<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">Den 28 sep. 2017 11:07 em skrev "Nick Torenvliet" <<a href="mailto:natorenvliet@gmail.com">natorenvliet@gmail.com</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi there, <br><br></div>I've attached a python script and a small pickle with associated data. </div><div><br></div><div>A code snippet, from the file, is found below and some debug output is found below.<br></div><div><br></div><div>My code is a quick hack of a working use of vtkImageData() from the mailing list archives. <br></div><div><br></div><div>I've taken out the original author's (thanks quentan) data source and put in place my pickle file. <br></div><div><br></div><div>When I run the script I get a window, but nothing visible in it except a black back-ground. <br></div></div></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I haven't looked in detail at the code, but it looks like you're trying to use a vtkPolyDataMapper to visualize a vtkImageData. <span style="font-family:sans-serif">vtkPolyDataMapper is for visualizing polygonal data. Normally to visualize a vtkImageData (a volume) you'd use a volume mapper such as vtkSmartVolumeMapper or vtkGPUVolumeRayCastMapper. Also, in order to do that I think the volume needs to be > 1 in all dimensions, as VTK interpolates between datapoints to form a visual voxel.</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">But I may of course be misunderstanding, I'm somewhat new to VTK myself.</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Elvis</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div></div><div><br></div><div>I'm not sure if its data representation issues,  viewport/camera issues, or pipeline issues; I'm open to all three actually - but I think its probably pipeline... the full extent of which is in the attached script. <br></div><div><br></div><div>The original author has an (n1, n2, n3) matrix generated with a bunch of trig, but I am using an (n1, n2, 1) matrix that I can view in matplotlib as an image.  My data numpy array on a grid generated by mlab.griddata.  <br></div><div><br></div><div>bscan_grid graphs well, as an image, in other packages, so I believe the issue is somewhere in the block below(with the missing pipeline).<br></div><div><br></div><div>I was hoping to get a surface plot, or height map of my bscan_grid, with z mapped onto xy</div><div><br></div><div>The attached script has a bunch of debug statements, the output when used on the attached pickle is underneath the code snippet. <br></div><div><br></div><div>I've stripped the code out and put a subsection below to illustrate my question, which is how do I get my lovely vtkImdateData objectto chain over and into the mapper and render my surface?</div><div><br></div><div></div><div>Thanks, <br></div><div><br></div><div>Nick<br></div><br><br><br><br>data_matrix = bscan_grid   #bscan_grid comes from the attached pickle and is 997x148x1</div><div><br></div><div>vtk_data_array = numpy_support.numpy_to_vtk(<wbr>num_array=data_matrix.ravel(),<br>                              <wbr>              deep=True,<br>                              <wbr>              array_type=vtk.VTK_FLOAT<br>                              <wbr>              )<br><br>img_vtk = vtk.vtkImageData()<br>img_vtk.SetOrigin(minax, minrot, 0)<br>img_vtk.SetSpacing(bscan_<wbr>adelta, bscan_rdelta, 1)<br>img_vtk.SetDimensions(data_<wbr>matrix.shape)<br>img_vtk.GetPointData().<wbr>SetScalars(vtk_data_array)<br><br></div>** Insert the magic filter widget view or transfrom thingy that connects a vtkImage to a mapper here **<br></div>** Or alternatively, is there something wrong with the line below ***<br><div><div><br>mapper = vtk.vtkPolyDataMapper()<br>mapper.SetInputConnection(<wbr>magic.GetOutputPort())<br>mapper.SetScalarVisibility(0)<br><br>actor = vtk.vtkActor()<br>actor.SetMapper(mapper)<br><br>actor.SetMapper(mapper)<br>renderer = vtk.vtkRenderer()<br>renderer.AddActor(actor)<br><br>xmins = [8830]<br>xmaxs = [8930]<br>ymins = [34]<br>ymaxs = [50]<br><br>render_window = vtk.vtkRenderWindow()<br>render_window.AddRenderer(<wbr>renderer)<br>renderer.ResetCamera()<br><br>renderer.SetViewport(xmins[0], ymins[0], xmaxs[0], ymaxs[0])<br><br>render_window.SetSize(600, 600)<br><br>iren = vtk.vtkRenderWindowInteractor(<wbr>)<br>iren.SetRenderWindow(render_<wbr>window)<br><br>interactor_style = vtk.<wbr>vtkInteractorStyleTrackballCam<wbr>era()<br>iren.SetInteractorStyle(<wbr>interactor_style)<br><br>iren.Initialize()<br>iren.Start()</div><div><br></div><div><br></div><div><br></div><div><br></div><div>####DEBUG STATEMENTS####<br></div><div>data_matrix intended x axis length 396<br>data_matrix intended x axis structured grid delta 0.100386432911<br>data_matrix intended x axis lower bound 8839.26083655<br>data_matrix intended x axis upper bound 8878.91347755 <br><br>data_matrix intended y axis length 48<br>data_matrix intended y axis structured grid delta 0.104253241356<br>data_matrix intended y axis lower bound 34.1994628906<br>data_matrix intended y axis upper bound 39.0993652344 <br><br>data_matrix intended z/scalar min -9.41352769373<br>data_matrix intended z/scalar max 19.<a href="tel:(561)%20877-0894" value="+15618770894" target="_blank">5618770894</a><br>data_matrix dimensions (396, 48, 1)<br><br></div></div></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div></div></div>