<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hello<br>I am using VTK to visualize a stack of binary data ((.raw )see
code below).&nbsp; Now I would like to interactively manipulate the data;
e.g., when the left mouse button is pressed, I would like to divide all
data values by two (i.e. if v(x,y,z) is the value of the data in the
file at position (x,y,z), I want to perform the operation
v(x,y,z)=v(x,y,z)/2 for all x,y,z). I know how to write a callback
function, but I don't know how to access data that have been read in
with vtkVolume16 reader.&nbsp; Is it maybe possible to introduce a new
element into the VTK pipeline between the vtkVolume16Reader and the
vtkContourFilter, some kind of container that allows data manipulation?<br><br>Thank you,<br><br>Frency Varghese<br><br>Here is the code:<br><br>#include "vtkRenderer.h"<br>#include "vtkRenderWindow.h"<br>#include
 "vtkRenderWindowInteractor.h"<br>#include "vtkVolume16Reader.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkActor.h"<br>#include "vtkOutlineFilter.h"<br>#include "vtkCamera.h"<br>#include "vtkProperty.h"<br>#include "vtkPolyDataNormals.h"<br>#include "vtkContourFilter.h"<br>#include "vtkPolyDataWriter.h"<br><br>#include "vtkStructuredPointsWriter.h"<br><br><br><br>int main (int argc, char **argv)<br>{<br>&nbsp;if (argc &lt; 2)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " " &lt;&lt; endl;<br>&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp; }<br><br>&nbsp;// Create the renderer, the render window, and the interactor. The renderer<br>&nbsp;// draws into the render window, the interactor enables mouse- and<br>&nbsp;// keyboard-based interaction with the data within the render window.<br><br>&nbsp;vtkRenderer *aRenderer = vtkRenderer::New();<br>&nbsp;vtkRenderWindow *renWin =
 vtkRenderWindow::New();<br>&nbsp;&nbsp; renWin-&gt;AddRenderer(aRenderer);<br>&nbsp;&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>&nbsp;&nbsp; iren-&gt;SetRenderWindow(renWin);<br><br>&nbsp;// The following reader is used to read a series of 2D slices (images)<br>&nbsp;// that compose the volume. The slice dimensions are set, and the pixel spacing.<br><br>&nbsp;vtkVolume16Reader *v16 = vtkVolume16Reader::New();<br>&nbsp;&nbsp; v16-&gt;SetDataDimensions (54,47);<br>&nbsp;&nbsp; v16-&gt;SetImageRange (1,63);<br>&nbsp;&nbsp; v16-&gt;SetDataByteOrderToLittleEndian();<br>&nbsp;&nbsp; v16-&gt;SetFilePrefix (argv[1]);<br>&nbsp;&nbsp; v16-&gt;SetDataSpacing (1,1,1.5);<br><br>// An isosurface, or contour value of 100 is known to correspond to the<br>&nbsp;//skin of the patient. Once generated, a vtkPolyDataNormals filter is<br>&nbsp;// is used to create normals for smooth surface shading during
 rendering.<br><br>&nbsp;vtkContourFilter *skinExtractor = vtkContourFilter::New();<br>&nbsp;&nbsp; skinExtractor-&gt;SetInputConnection(v16-&gt;GetOutputPort());<br>&nbsp; skinExtractor-&gt;SetValue(100,100);<br>&nbsp;vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();<br>&nbsp;&nbsp; skinNormals-&gt;SetInputConnection(skinExtractor-&gt;GetOutputPort());<br>&nbsp;&nbsp; skinNormals-&gt;SetFeatureAngle(60);<br>&nbsp;vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();<br>&nbsp;&nbsp; skinMapper-&gt;SetInputConnection(skinNormals-&gt;GetOutputPort());<br>&nbsp;&nbsp; skinMapper-&gt;ScalarVisibilityOff();<br>&nbsp;vtkActor *skin = vtkActor::New();<br>&nbsp; skin-&gt;SetMapper(skinMapper);<br><br>// An outline provides context around the data.<br><br>&nbsp;vtkOutlineFilter *outlineData = vtkOutlineFilter::New();<br>&nbsp;&nbsp; outlineData-&gt;SetInputConnection(v16-&gt;GetOutputPort());<br>&nbsp;vtkPolyDataMapper *mapOutline =
 vtkPolyDataMapper::New();<br>&nbsp;&nbsp; mapOutline-&gt;SetInputConnection(outlineData-&gt;GetOutputPort());<br>&nbsp;vtkActor *outline = vtkActor::New();<br>&nbsp;&nbsp; outline-&gt;SetMapper(mapOutline);<br>&nbsp;&nbsp; outline-&gt;GetProperty()-&gt;SetColor(0,0,0);<br><br><br>&nbsp;vtkCamera *aCamera = vtkCamera::New();<br>&nbsp;&nbsp; aCamera-&gt;SetViewUp (0, 0, -1);<br>&nbsp;&nbsp; aCamera-&gt;SetPosition (0, 1, 0);<br>&nbsp;&nbsp; aCamera-&gt;SetFocalPoint (0, 0, 0);<br>&nbsp;&nbsp; aCamera-&gt;ComputeViewPlaneNormal();<br><br><br><br>&nbsp;// Actors are added to the renderer. An initial camera view is created.<br>&nbsp;// The Dolly() method moves the camera towards the FocalPoint,thereby //enlarging the image.<br>&nbsp;aRenderer-&gt;AddActor(outline);<br>&nbsp;aRenderer-&gt;AddActor(skin);<br>&nbsp;aRenderer-&gt;SetActiveCamera(aCamera);<br>&nbsp;aRenderer-&gt;ResetCamera ();<br>&nbsp;aCamera-&gt;Dolly(1.5);<br><br>&nbsp;// Set a background
 color for the renderer and set the size of the render //window<br>(expressed in pixels).<br>&nbsp;aRenderer-&gt;SetBackground(1,1,1);<br>&nbsp;renWin-&gt;SetSize(500, 500);<br><br>&nbsp;// Note that when camera movement occurs (as it does in the Dolly() method), the<br>// clipping planes often need adjusting. Clipping planes<br>&nbsp;// consist of two planes: near and far along the view direction. The near plane //clips out objects in front of the plane; the far plane clips out objects behind the //plane. This way only what is drawn between the planes is actually rendered.<br>&nbsp;<br>aRenderer-&gt;ResetCameraClippingRange ();<br><br>&nbsp;// Initialize the event loop and then start it.<br>&nbsp;&nbsp; iren-&gt;Initialize();<br>&nbsp;&nbsp; iren-&gt;Start();<br><br>// It is important to delete all objects created previously to prevent<br>&nbsp;// memory leaks. In this case, since the program is on its way
 to<br>&nbsp;// exiting, it is not so important. But in applications it is essential.<br>&nbsp;v16-&gt;Delete();<br>&nbsp;skinExtractor-&gt;Delete();<br>&nbsp;skinMapper-&gt;Delete();<br>&nbsp;skin-&gt;Delete();<br>&nbsp;outlineData-&gt;Delete();<br>&nbsp;mapOutline-&gt;Delete();<br>&nbsp;outline-&gt;Delete();<br>&nbsp;aCamera-&gt;Delete();<br>&nbsp;iren-&gt;Delete();<br>&nbsp;renWin-&gt;Delete();<br>&nbsp;aRenderer-&gt;Delete();<br>&nbsp; writer-&gt;Delete();<br>&nbsp;return 0;<br>}<input name="flag" value="" type="hidden">
<table style="width: 527px; height: 42px;" cellspacing="0"><tbody><tr>
<td colspan="3" class="control leftAlign"><br></td>
</tr>
<tr class="control">
  <td class="leftAlign" nowrap="nowrap"><br></td>
  <td class="leftAlign" nowrap="nowrap"><br></td>
  <td class="rightAlign" width="65%" nowrap="nowrap"><br></td></tr></tbody></table></td></tr></table><br>