<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hi, and thanks for the response.<br><br>I'm guessing there must be several versions of vtk in use and large differences between them.&nbsp; I'm using (or trying to use) version 5.4 on windows and the wrapper class for .net and C# (company orders, not my choice).....<br><br><span>I don't see vtkStructuredPointsAlgorithm on this system or anything else obvious which has requestdata or requestinformation methods.&nbsp; Google searches on the two methods turn up mostly suggestions to look at a description of the new vtk pipeline architecture ( <a target="_blank" href="http://www.cmake.org/cgi-bin/viewcvs.cgi/*checkout*/Utilities/Upgrading/TheNewVTKPipeline.pdf?revision=1.5">http://www.cmake.org/cgi-bin/viewcvs.cgi/*checkout*/Utilities/Upgrading/TheNewVTKPipeline.pdf?revision=1.5</a>
 ).</span><br><br>It would solve most of my basic problem if I knew a way to adjust opacity of an image on the fly without having to re-read any data.&nbsp; It might also solve my problem if I could figure out what the "coordinate" array is in the GetArrayPointer function for vtkStructuredPoints objects.<br><br>Again thanks, and any/all information is appreciated.<br><br><br>Ted<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Mike Jackson &lt;mike.jackson@bluequartz.net&gt;<br><b><span style="font-weight: bold;">To:</span></b> Theodore Holden &lt;theodoreholden@yahoo.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> vtkusers@vtk.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 5, 2009 1:51:36 PM<br><b><span
 style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] How to set data programmatically...<br></font><br>
You probably want to write your own custom reader object. There are<br>lots of examples floating around the internet on that. The basics are:<br><br>Select a vtk class in which to inherit from. In your case probably<br>vtkStructuredPointsAlgorithm?<br>programatically set the "numberOfInputs=0".<br>Implement the RequestInformation and RequestData methods.<br><br>In the RequestInformation method you should read just enough<br>information from your file to be able to setup the output type with<br>its extents&nbsp; and all that.<br><br>In the RequestData method do the actual reading of data from your file<br>and convert it into a vtk object as appropriate.<br><br>HTH<br>Mike<br><br>On Tue, May 5, 2009 at 11:26 AM, Theodore Holden<br>&lt;<a ymailto="mailto:theodoreholden@yahoo.com" href="mailto:theodoreholden@yahoo.com">theodoreholden@yahoo.com</a>&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I have an 3d visualization application which reads data from a file
 which<br>&gt; isn't related to vtk and at present I'm having to write the data out in vtk<br>&gt; format to disk and then let a vtk reader read it a second time.<br>&gt;<br>&gt; It would help considerably if I was able to simply pass the data to vtk<br>&gt; internally but thus far I've not been able to figure out how to do it and<br>&gt; nothing I see on the web helps.&nbsp; The data is unsigned char and the piece of<br>&gt; code which presents it looks like this:<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void AddBagVolumeToWindow4(vtk.vtkRenderWindow renWin)<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 3d texture map<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkStructuredPointsReader reader = new<br>&gt; vtkStructuredPointsReader();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkVolume
 volume = new vtkVolume();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkVolumeProperty volumeProperty = new vtkVolumeProperty();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkRenderer renderer = new vtkRenderer();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor interactor = new<br>&gt; vtkRenderWindowInteractor();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkVolumeTextureMapper3D volumeMapper = new<br>&gt; vtkVolumeTextureMapper3D();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //vtkVolumeRayCastCompositeFunction compositeFunction = new<br>&gt; vtkVolumeRayCastCompositeFunction();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkPiecewiseFunction opacity = new vtkPiecewiseFunction();<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkColorTransferFunction color = new vtkColorTransferFunction();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader.SetFileName("c:\\zz.vtk");<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader.Update();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opacity.AddPoint(0, 0);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opacity.AddPoint(64, .005);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opacity.AddPoint(128, .01);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opacity.AddPoint(200, .05);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opacity.AddPoint(220, .4);<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color.AddRGBPoint(64,
 .665, .84, .88);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color.AddRGBPoint(128, 0, .746, .95);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color.AddRGBPoint(220, 0, 1, 0);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; color.AddRGBPoint(230, 1, 0, 0);<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty.SetColor(color);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty.SetScalarOpacity(opacity);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty.SetInterpolationTypeToLinear();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeProperty.ShadeOn();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volumeMapper.SetInput(reader.GetOutput());<br>&gt;<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //int[] iiex = reader.GetOutput().GetExtent();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volume.SetMapper(volumeMapper);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volume.SetProperty(volumeProperty);<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.SetBackground(1, 1, 1);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.AddVolume(volume);<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interactor.SetRenderWindow(renWin);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.AddRenderer(renderer);<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renx = renderer;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; volx =
 volume;<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.Render();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interactor.Start();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtk.vtkWin32OpenGLRenderWindow win32win =<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtk.vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; win32win.Clean();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt; That's after the data has been written out to "c:\\zz.vtk" of course.&nbsp; What<br>&gt; it looks like I'd want to do, rather than use the vtkStructuredPointsReader,<br>&gt; is to set up my own vtkStructuredPoints object something like:<br>&gt;<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkStructuredPoints bsp = new vtkStructuredPoints();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsp.SetScalarTypeToUnsignedChar();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsp.SetDimensions(Width, Height, NumSlices);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsp.SetOrigin(0, 0, 0);<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsp.SetExtent(0, Width - 1, 0, Height - 1, 0, NumSlices - 1);<br>&gt;<br>&gt; &nbsp;and then set the data array but, again, I've no clue as to how to do that.<br>&gt; Any help would be apreciated.<br>&gt;<br>&gt;<br>&gt; Ted<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; Powered by <a target="_blank" href="http://www.kitware.com">www.kitware.com</a><br>&gt;<br>&gt; Visit
 other Kitware open-source projects at<br><span>&gt; <a target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br>&gt;<br>&gt; Please keep messages on-topic and check the VTK FAQ at:<br><span>&gt; <a target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a></span><br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br><span>&gt; <a target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a></span><br>&gt;<br>&gt;<br></div></div></div><br>

      </body></html>