<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><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(num_array=data_matrix.ravel(),<br>                                            deep=True,<br>                                            array_type=vtk.VTK_FLOAT<br>                                            )<br><br>img_vtk = vtk.vtkImageData()<br>img_vtk.SetOrigin(minax, minrot, 0)<br>img_vtk.SetSpacing(bscan_adelta, bscan_rdelta, 1)<br>img_vtk.SetDimensions(data_matrix.shape)<br>img_vtk.GetPointData().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(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(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()<br>iren.SetRenderWindow(render_window)<br><br>interactor_style = vtk.vtkInteractorStyleTrackballCamera()<br>iren.SetInteractorStyle(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.5618770894<br>data_matrix dimensions (396, 48, 1)<br><br></div></div></div>