<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,<br><br>I have an 3d visualization application which reads data from a file which isn't related to vtk and at present I'm having to write the data out in vtk format to disk and then let a vtk reader read it a second time. <br><br>It would help considerably if I was able to simply pass the data to vtk internally but thus far I've not been able to figure out how to do it and nothing I see on the web helps. The data is unsigned char and the piece of code which presents it looks like this:<br><br><div style="margin-left: 80px;"><font size="1"> <span style="color: rgb(0, 128, 255);"> void AddBagVolumeToWindow4(vtk.vtkRenderWindow renWin)</span></font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);"
size="1"> {</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> // 3d texture map</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkStructuredPointsReader reader = new vtkStructuredPointsReader();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkVolume volume = new vtkVolume();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkVolumeProperty volumeProperty = new vtkVolumeProperty();</font><br style="color: rgb(0, 128, 255);"><br style="color:
rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkRenderer renderer = new vtkRenderer();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkRenderWindowInteractor interactor = new vtkRenderWindowInteractor();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkVolumeTextureMapper3D volumeMapper = new vtkVolumeTextureMapper3D();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> //vtkVolumeRayCastCompositeFunction compositeFunction = new vtkVolumeRayCastCompositeFunction();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128,
255);" size="1"> </font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkPiecewiseFunction opacity = new vtkPiecewiseFunction();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtkColorTransferFunction color = new vtkColorTransferFunction();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> reader.SetFileName("c:\\zz.vtk");</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> reader.Update();</font><br style="color: rgb(0, 128,
255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> opacity.AddPoint(0, 0);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> opacity.AddPoint(64, .005);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> opacity.AddPoint(128, .01);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> opacity.AddPoint(200, .05);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> opacity.AddPoint(220, .4);</font><br style="color: rgb(0, 128,
255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> color.AddRGBPoint(64, .665, .84, .88);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> color.AddRGBPoint(128, 0, .746, .95);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> color.AddRGBPoint(220, 0, 1, 0);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> color.AddRGBPoint(230, 1, 0, 0);</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);"
size="1"> volumeProperty.SetColor(color);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volumeProperty.SetScalarOpacity(opacity);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volumeProperty.SetInterpolationTypeToLinear();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volumeProperty.ShadeOn();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volumeMapper.SetInput(reader.GetOutput());</font><br style="color: rgb(0,
128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> //int[] iiex = reader.GetOutput().GetExtent();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volume.SetMapper(volumeMapper);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volume.SetProperty(volumeProperty);</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> renderer.SetBackground(1, 1, 1);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);"
size="1"> renderer.AddVolume(volume);</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> interactor.SetRenderWindow(renWin);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> renWin.AddRenderer(renderer);</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> renx = renderer;</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> volx = volume;
</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> renWin.Render();</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> interactor.Start();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtk.vtkWin32OpenGLRenderWindow win32win =</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> vtk.vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);</font><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);"
size="1"> win32win.Clean();</font><br style="color: rgb(0, 128, 255);"><br style="color: rgb(0, 128, 255);"><font style="color: rgb(0, 128, 255);" size="1"> }</font><br style="color: rgb(0, 128, 255);"></div><font size="3"><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">That's after the data has been written out to </span></font><font style="color: rgb(0, 0, 0);" size="3">"c:\\zz.vtk</font>" of course. What it looks like I'd want to do, rather <font size="3">than use the </font><font style="color: rgb(0, 0, 0);" size="3">vtkStructuredPointsReader, is to set up my own vtkStructuredPoints object something like:<br><br> </font><font style="color: rgb(0, 0, 0);" size="3">vtkStructuredPoints </font><font style="color: rgb(0, 0, 0);" size="3">bsp = new
vtkStructuredPoints();<br> bsp.SetScalarTypeToUnsignedChar();<br> bsp.SetDimensions(Width, Height, NumSlices);<br> bsp.SetOrigin(0, 0, 0);<br> bsp.SetExtent(0, Width - 1, 0, Height - 1, 0, NumSlices - 1);<br><br> </font>and then set the data array but, again, I've no clue as to how to do that. Any help would be apreciated.<br><br><br>Ted<br><br><br><br><br></div></div><br>
</body></html>